Skip to content

Commit

Permalink
Merge pull request #510 from bounswe/mobile/feature/chatbot-implement…
Browse files Browse the repository at this point in the history
…ation-#465

Mobile/feature/chatbot implementation #465
  • Loading branch information
bbenginbestas authored Dec 26, 2022
2 parents 936d70f + 7fc7ef9 commit 57f4c74
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 20 deletions.
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

0 comments on commit 57f4c74

Please sign in to comment.