Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mobile] Chatbot Implementation #510

Merged
merged 6 commits into from
Dec 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bounswe5_mobile">
package="com.example.bounswe5_mobile"
xmlns:tools="http://schemas.android.com/tools">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<application
tools:replace="android:label"
android:label="application@label"
>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<application
android:label="Hippocrates"
android:name="${applicationName}"
android:icon="@mipmap/launcher_icon">
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
Expand All @@ -18,9 +18,9 @@
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand All @@ -34,3 +34,4 @@
</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

37 changes: 37 additions & 0 deletions app/mobile/bounswe5_mobile/lib/screens/chatbotScreen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:kommunicate_flutter/kommunicate_flutter.dart';

void main() {
runApp(const MaterialApp(
title: 'Navigation Basics',
home: ChatbotScreen(),
));
}

class ChatbotScreen extends StatelessWidget {
const ChatbotScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
child: const Text('Start Conversation'),
onPressed: () async {
try {
dynamic conversationObject = {
'appId': '35f067c7290c8f7f05b2575bf22b44440',
'isSingleConversation' : false
};
dynamic result = await KommunicateFlutterPlugin.buildConversation(conversationObject);
print("Conversation builder success : " + result.toString());
} on Exception catch (e) {
print("Conversation builder error occurred : " + e.toString());
}
},
),
),
);
}
}

27 changes: 13 additions & 14 deletions app/mobile/bounswe5_mobile/lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import 'package:bounswe5_mobile/screens/createArticle.dart';
import 'package:bounswe5_mobile/screens/postOverviewScreen.dart';
import 'package:bounswe5_mobile/screens/articleOverviewScreen.dart';
import 'package:bounswe5_mobile/screens/searchPage.dart';
import 'package:bounswe5_mobile/screens/chatbotScreen.dart';
import 'package:bounswe5_mobile/models/post.dart';
import 'package:bounswe5_mobile/models/article.dart';
import 'package:kommunicate_flutter/kommunicate_flutter.dart';

/// This is the implementation of the home page.
class HomePage extends StatefulWidget {
Expand Down Expand Up @@ -61,6 +63,7 @@ class _HomePageState extends State<HomePage> {
List<Widget> bodies = [
PostsOverviewScreen(activeUser: activeUser,),
ArticlesOverviewScreen(activeUser: activeUser,),
ChatbotScreen()
];

// Session activity means that a registered user is entered
Expand All @@ -72,14 +75,11 @@ class _HomePageState extends State<HomePage> {
if (isSessionActive) {
if (widget.index == 0) {
floatingButton = FloatingActionButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
CreatePostPage(activeUser: activeUser)),
);
print("User create post");
onPressed: () async {
dynamic conversationObject = {
'appId': '',// The APP_ID obtained from kommunicate dashboard.
};
KommunicateFlutterPlugin.buildConversation(conversationObject);
},
backgroundColor: Theme.of(context).colorScheme.primary,
child: Icon(
Expand Down Expand Up @@ -152,20 +152,18 @@ class _HomePageState extends State<HomePage> {
label: 'Forum',
),
// For now, no chatbot implementation is available.
/*
BottomNavigationBarItem(
icon: Icon(Icons.library_books), label: 'Articles'),
BottomNavigationBarItem(
icon: Icon(Icons.chat_bubble),
label: 'Chatbot',
),
*/
BottomNavigationBarItem(
icon: Icon(Icons.library_books), label: 'Articles'),
],
),

// floating action button will be used for creating a new post or article later.
floatingActionButton:
floatingButton, // If user not signed in, do not show create post button in the forum
floatingButton, // If user not signed in, do not show create post button in the forum

body: bodies[widget.index],
);
Expand Down Expand Up @@ -199,4 +197,5 @@ class _HomePageState extends State<HomePage> {

}
}
*/
*/

3 changes: 2 additions & 1 deletion app/mobile/bounswe5_mobile/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies:
flutter_svg: ^0.22.0
flutter_html: ^2.2.1
flutter_launcher_icons: ^0.11.0
kommunicate_flutter: ^1.5.1

flutter_icons:
android: "launcher_icon"
Expand Down Expand Up @@ -111,4 +112,4 @@ flutter:
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
# see https://flutter.dev/custom-fonts/#from-packages