Skip to content

Commit efd35f6

Browse files
added copy button for AI response
1 parent 321d1c2 commit efd35f6

19 files changed

+215
-38
lines changed

android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ subprojects {
2626
project.evaluationDependsOn(':app')
2727
}
2828

29-
task clean(type: Delete) {
29+
tasks.register("clean", Delete) {
3030
delete rootProject.buildDir
3131
}

assets/akLogo.svg

+10
Loading

assets/babg.png

205 KB
Loading

assets/github1.png

6.24 KB
Loading

assets/linkedin.png

8.18 KB
Loading

lib/data/form_json.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ List<dynamic> formJSON = [
193193
"title": "MCQ Type Quiz",
194194
"disc": "Generate MCQs with Answer",
195195
"prompt":
196-
"Create a {number} multiple-choice quiz from text {topic}. The output should be in markdown format and include the question, options, and correct answer for each question. Each question should be based on a distinct concept within the text, and four options (including the correct answer) should be provided for each question. The correct answer should be indicated with an asterisk (*) immediately following the option. Ensure that each question and option is grammatically correct, semantically meaningful, and accurately reflects the content of the original text. To achieve this, we will leverage the expertise of an Instructional Designer, a Natural Language Processing Expert, a Quiz Creator, a Markdown Specialist, a Content Editor, a Domain Expert, a UX Designer, and a Data Analyst. The Domain Expert will work with us to identify key concepts in the text, the Data Analyst will use data analytics tools to analyze the results of the quiz and make improvements for future iterations.",
196+
"Create a {number} multiple-choice quiz for topic {topic}. The output include the question, options, and correct answer for each question. Each question should be based on a distinct concept within the topic. Ensure that each question and option is semantically meaningful, and accurately reflects the content of the original topic. To achieve this, we will leverage the expertise of a Quiz Creator, a Domain Expert, and a Data Analyst. The Domain Expert will work with us to identify key concepts in the topic, the Data Analyst will use data analytics tools to analyze the results of the quiz and make improvements for future iterations. Format: Each question must starts with 'Question' keyword ,all option must starts with (A, B, C, D) enclosed with parentheses and correct answer must starts with 'Answer' keyword.",
197197
"schema": {
198198
"properties": {
199199
"{topic}": {

lib/data/message_model.dart

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class MessageModel {
2+
String text;
3+
String sender;
4+
5+
MessageModel({required this.text, required this.sender});
6+
}

lib/screen/chat_screen.dart

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import 'package:flutter/foundation.dart';
22
import 'package:flutter/material.dart';
33
import 'package:student_ai/data/constants.dart';
44
import 'package:student_ai/data/globals.dart';
5+
import 'package:student_ai/data/message_model.dart';
56
import 'package:student_ai/services/api_service.dart';
67
import 'package:student_ai/widgets/message.dart';
7-
import 'package:student_ai/widgets/search_bar.dart';
8+
import 'package:student_ai/widgets/my_search_bar.dart';
89
import 'package:student_ai/widgets/typing_animation.dart';
910

1011
class ChatScreen extends StatefulWidget {
@@ -20,7 +21,7 @@ class ChatScreen extends StatefulWidget {
2021
}
2122

2223
class _ChatScreenState extends State<ChatScreen> {
23-
List<Message> msgList = [];
24+
List<MessageModel> msgList = [];
2425

2526
final TextEditingController newQueryController = TextEditingController();
2627
bool _isTyping = false;
@@ -33,7 +34,7 @@ class _ChatScreenState extends State<ChatScreen> {
3334
void sendMessage(String query) {
3435
if (widget.isFormRoute == false) {
3536
setState(() {
36-
msgList.insert(0, Message(text: query, sender: 'user'));
37+
msgList.insert(0, MessageModel(text: query, sender: 'user'));
3738
});
3839
}
3940
setState(() {
@@ -49,7 +50,7 @@ class _ChatScreenState extends State<ChatScreen> {
4950

5051
setState(() {
5152
_isTyping = false;
52-
msgList.insert(0, Message(text: fetchRes, sender: 'AI'));
53+
msgList.insert(0, MessageModel(text: fetchRes, sender: 'AI'));
5354
});
5455
} catch (e) {
5556
if (kDebugMode) {
@@ -120,7 +121,7 @@ class _ChatScreenState extends State<ChatScreen> {
120121
const SizedBox(
121122
height: 16,
122123
),
123-
SearchBar(
124+
MySearchBar(
124125
buttonColor: _isTyping ? kDarkWhite : kBlack,
125126
chatController: newQueryController,
126127
onTap: () {

lib/screen/home.dart

+28-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:async';
2+
import 'dart:ui';
23

34
import 'package:flutter/material.dart';
45
import 'package:flutter_svg/flutter_svg.dart';
@@ -7,7 +8,8 @@ import 'package:student_ai/screen/my_form.dart';
78
import 'package:student_ai/services/api_service.dart';
89
import 'package:student_ai/widgets/api_input.dart';
910
import 'package:student_ai/widgets/card_widget.dart';
10-
import 'package:student_ai/widgets/search_bar.dart';
11+
import 'package:student_ai/widgets/info_card.dart';
12+
import 'package:student_ai/widgets/my_search_bar.dart';
1113
import 'package:student_ai/widgets/server_indicator.dart';
1214

1315
import '../data/constants.dart';
@@ -56,10 +58,12 @@ class _HomeState extends State<Home> {
5658
Widget build(BuildContext context) {
5759
return Container(
5860
decoration: const BoxDecoration(
59-
gradient: LinearGradient(
60-
begin: Alignment.topCenter,
61-
end: Alignment.bottomCenter,
62-
colors: [Colors.blue, kBackGroundColor, kOrange])),
61+
gradient: LinearGradient(
62+
begin: Alignment.topCenter,
63+
end: Alignment.bottomCenter,
64+
colors: [Colors.blue, kBackGroundColor, kOrange],
65+
),
66+
),
6367
child: Scaffold(
6468
extendBodyBehindAppBar: true,
6569
backgroundColor: Colors.transparent,
@@ -70,9 +74,21 @@ class _HomeState extends State<Home> {
7074
centerTitle: true,
7175
title: Row(
7276
children: [
73-
SvgPicture.asset(
74-
'assets/logo.svg',
75-
width: 35,
77+
GestureDetector(
78+
onTap: () => showDialog(
79+
context: context,
80+
builder: (BuildContext context) {
81+
return BackdropFilter(
82+
filter: ImageFilter.blur(
83+
sigmaY: 5,
84+
sigmaX: 5,
85+
),
86+
child: const InfoCard());
87+
}),
88+
child: SvgPicture.asset(
89+
'assets/logo.svg',
90+
width: 35,
91+
),
7692
),
7793
const SizedBox(
7894
width: 10,
@@ -97,7 +113,9 @@ class _HomeState extends State<Home> {
97113
content: Text(
98114
"Server is Down 🔻. Try again later!",
99115
style: TextStyle(
100-
color: kBlack, fontWeight: FontWeight.bold),
116+
color: kBlack,
117+
fontWeight: FontWeight.bold,
118+
),
101119
),
102120
),
103121
);
@@ -130,7 +148,7 @@ class _HomeState extends State<Home> {
130148
),
131149
),
132150
),
133-
SearchBar(
151+
MySearchBar(
134152
buttonColor: kBlack,
135153
chatController: chatController,
136154
onTap: () {

lib/services/api_service.dart

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class ApiService {
4848
String content = choice['message']['content'];
4949
output += content;
5050
});
51+
print(resData);
5152

5253
return output;
5354
} catch (e) {

lib/widgets/info_card.dart

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_svg/flutter_svg.dart';
3+
import 'package:student_ai/data/constants.dart';
4+
import 'package:url_launcher/url_launcher.dart';
5+
6+
class InfoCard extends StatelessWidget {
7+
const InfoCard({Key? key}) : super(key: key);
8+
9+
_launchUrl(String url) async {
10+
try {
11+
await launchUrl(Uri.parse(url),
12+
mode: LaunchMode.externalNonBrowserApplication);
13+
} catch (e) {
14+
throw e.toString();
15+
}
16+
}
17+
18+
@override
19+
Widget build(BuildContext context) {
20+
return AlertDialog(
21+
backgroundColor: kWhite.withOpacity(0.8),
22+
title: SvgPicture.asset(
23+
'assets/akLogo.svg',
24+
height: 70,
25+
),
26+
content: Column(
27+
mainAxisSize: MainAxisSize.min,
28+
children: [
29+
Row(
30+
mainAxisAlignment: MainAxisAlignment.center,
31+
children: [
32+
GestureDetector(
33+
onTap: () =>
34+
_launchUrl('https://github.com/Avadhkumar-geek/StudentAI'),
35+
child: const Image(
36+
height: 30,
37+
image: AssetImage('assets/github1.png'),
38+
),
39+
),
40+
const SizedBox(
41+
width: 16,
42+
),
43+
GestureDetector(
44+
onTap: () => _launchUrl(
45+
'https://www.linkedin.com/in/avadhkumar-kachhadiya-022175204/'),
46+
child: const Image(
47+
height: 30,
48+
image: AssetImage('assets/linkedin.png'),
49+
),
50+
)
51+
],
52+
),
53+
const SizedBox(
54+
height: 15,
55+
),
56+
const Text(
57+
' © All Rights Reserved',
58+
style: TextStyle(fontWeight: FontWeight.bold),
59+
)
60+
],
61+
),
62+
);
63+
;
64+
}
65+
}

lib/widgets/search_bar.dart renamed to lib/widgets/my_search_bar.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import 'package:flutter_svg/flutter_svg.dart';
44
import 'package:student_ai/data/constants.dart';
55
import 'package:student_ai/data/globals.dart';
66

7-
class SearchBar extends StatefulWidget {
8-
const SearchBar({
7+
class MySearchBar extends StatefulWidget {
8+
const MySearchBar({
99
Key? key,
1010
required this.chatController,
1111
required this.onTap,
@@ -19,10 +19,10 @@ class SearchBar extends StatefulWidget {
1919
static const double borderWidth = 3.0;
2020

2121
@override
22-
State<SearchBar> createState() => _SearchBarState();
22+
State<MySearchBar> createState() => _MySearchBarState();
2323
}
2424

25-
class _SearchBarState extends State<SearchBar>
25+
class _MySearchBarState extends State<MySearchBar>
2626
with SingleTickerProviderStateMixin {
2727
late AnimationController _controller;
2828

linux/flutter/generated_plugin_registrant.cc

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
#include "generated_plugin_registrant.h"
88

9+
#include <url_launcher_linux/url_launcher_plugin.h>
910

1011
void fl_register_plugins(FlPluginRegistry* registry) {
12+
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
13+
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
14+
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
1115
}

linux/flutter/generated_plugins.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6+
url_launcher_linux
67
)
78

89
list(APPEND FLUTTER_FFI_PLUGIN_LIST

macos/Flutter/GeneratedPluginRegistrant.swift

+2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import Foundation
77

88
import path_provider_foundation
99
import shared_preferences_foundation
10+
import url_launcher_macos
1011

1112
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
1213
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
1314
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
15+
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
1416
}

0 commit comments

Comments
 (0)