Skip to content

Commit

Permalink
update gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
ArpitAswal committed Jan 11, 2025
1 parent 29f2797 commit 2558fef
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 129 deletions.
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
4 changes: 2 additions & 2 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
id "com.android.application" version "8.5.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.0" apply false
}

include ":app"
37 changes: 19 additions & 18 deletions lib/presentation/controllers/home_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ class HomeController extends GetxController {
final GenerateContentUseCase _generateContent;

// Observable variables for UI updates
final RxInt currentIndex = 0.obs; // to update the index of pages
final RxInt initialAllChatBoxes = 0
.obs; // indicate how many chat boxes already created whenever the app start
final RxInt currentIndex =
0.obs; // to update the index of pages
final RxInt initialAllChatBoxes =
0.obs; // indicate how many chat boxes already created whenever the app start
final RxString greetingMessage =
"".obs; // Stores the greeting message for display
final RxString _userVoiceMsg =
Expand All @@ -41,7 +42,8 @@ class HomeController extends GetxController {
"".obs; // Store the image response that will received by gemini model
final RxString _currentChatBoxID =
"".obs; // to store current chat box where user send prompt
final RxString filePath = "".obs; // file path of selected pdf file
final RxString filePath =
"".obs; // file path of selected pdf file
final RxBool _speechEnabled =
false.obs; // Flag to track if speech recognition is enabled
final RxBool speechListen =
Expand All @@ -56,8 +58,8 @@ class HomeController extends GetxController {
false.obs; // Flag to indicate the response text should re animate or not
final RxBool isStopped =
true.obs; // Flag to determine if text-to-speech should stop
final RxBool isNewPrompt = true
.obs; // Flag to determine whether current prompt is new or old chat prompt
final RxBool isNewPrompt =
true.obs; // Flag to determine whether current prompt is new or old chat prompt
final RxList<HiveChatBoxMessages> messages =
<HiveChatBoxMessages>[].obs; // List to hold conversation messages
final RxList<HiveChatBox> totalChatBoxes =
Expand Down Expand Up @@ -178,7 +180,7 @@ class HomeController extends GetxController {
// Initializes the message queue for speaking and starts TTS
void playTTs() async {
for (var message in messages) {
if (message.imagePath != null) _messageQueue.add(message.text);
if (message.imagePath == null && message.filePath == null) _messageQueue.add(message.text);
}
isStopped.value = false;
_flutterTts.setCompletionHandler(_onSpeakCompleted);
Expand Down Expand Up @@ -288,6 +290,8 @@ class HomeController extends GetxController {
isUser: true));
_messageQueue.add(
"Please provide me with some context or a question so I can assist you.");
isStopped.value = false;
await _speakNextMessage();
shouldTextAnimate.value = true;
messages.add(HiveChatBoxMessages(
text: "For example: Give me some Interview Tips.", isUser: false));
Expand Down Expand Up @@ -334,9 +338,9 @@ class HomeController extends GetxController {
if (visionResponse.value.isNotEmpty) {
messages.add(
HiveChatBoxMessages(text: visionResponse.value, isUser: false));
speakTTs(visionResponse.value);
visionResponse.value = "";
}
speakTTs(visionResponse.value);
visionResponse.value = "";
if (isNewPrompt.value &&
messages.length == 2 &&
_chatBoxTitle.isEmpty) {
Expand All @@ -347,7 +351,8 @@ class HomeController extends GetxController {
}).onError((error, stackTrace) {
isLoading.value = false; // Ends loading state
AlertMessages.showSnackBar(error.toString());
messages.add(HiveChatBoxMessages(text: "Failed", isUser: false));
messages.add(HiveChatBoxMessages(text: error.toString(), isUser: false));
speakTTs(error.toString());
});
} catch (e) {
isLoading.value = false;
Expand All @@ -364,11 +369,9 @@ class HomeController extends GetxController {
final data = await _service.imagineAPI(input);
isLoading.value = false;
messages.add(HiveChatBoxMessages(
text: "Here, is a comprehensive desire image output of your prompt.",
isUser: false));
messages.add(HiveChatBoxMessages(
text: "", isUser: false, imagePath: [data], filePath: null));
if (isNewPrompt.value && messages.length == 3 && _chatBoxTitle.isEmpty) {
text: "Here, is a comprehensive desire image output of your prompt.", isUser: false, imagePath: [data], filePath: null));
speakTTs("Here, is a comprehensive desire image output of your prompt.");
if (isNewPrompt.value && messages.length == 2 && _chatBoxTitle.isEmpty) {
setChatBoxTitle();
}
saveMessagesInDB();
Expand Down Expand Up @@ -454,7 +457,7 @@ class HomeController extends GetxController {
if (filePath.value.isNotEmpty) {
filePath.value = "";
}
} else {}
}
}

Future<void> pickFile() async {
Expand All @@ -470,8 +473,6 @@ class HomeController extends GetxController {
if (imagesFileList.isNotEmpty) {
imagesFileList.value = [];
}
} else {
// User canceled the picker
}
}

Expand Down
244 changes: 137 additions & 107 deletions lib/widgets/prompt_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,104 +26,123 @@ class PromptMessagesWidget extends StatelessWidget {
final isLastMessage = index == message.length - 1;

if (msg.isUser && (msg.imagePath != null || msg.filePath != null)) {
return Align(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Align(
alignment: Alignment.centerRight,
child: Container(
width: (msg.imagePath != null &&
msg.imagePath!.length == 1)
? width * 0.25
: (msg.filePath != null && msg.filePath!.length == 1)
? width * 0.25
: width * 0.5,
margin: const EdgeInsets.only(bottom: 12.0),
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
boxShadow: const [
BoxShadow(
color: Colors.grey,
spreadRadius: 1.0,
blurRadius: 6.0,
),
],
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Colors.blue.shade300,
Colors.lightGreenAccent.shade100
],
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Align(
alignment: Alignment.centerRight,
child: Container(
width: (msg.imagePath != null && msg.imagePath!.length == 1)
? width * 0.25
: (msg.filePath != null)
? width * 0.25
: width * 0.5,
margin: const EdgeInsets.only(bottom: 12.0),
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
boxShadow: const [
BoxShadow(
color: Colors.grey,
spreadRadius: 1.0,
blurRadius: 6.0,
),
borderRadius: BorderRadius.circular(24).copyWith(
topLeft: Radius.zero, bottomRight: Radius.zero),
],
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Colors.blue.shade300,
Colors.lightGreenAccent.shade100
],
),
child: (msg.imagePath != null)
? ImageGridView(images: msg.imagePath!)
: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: width * 0.015,
),
Icon(
Icons.picture_as_pdf,
color: Colors.red.shade300,
size: 30,
),
SizedBox(
width: width * 0.015,
),
Flexible(
child: Text(
ctrl.filePath.value
.split('/')
.last
.split('-')
.last,
style: const TextStyle(
color: Colors.white,
fontFamily: "Cera"),
),
borderRadius: BorderRadius.circular(24).copyWith(
topLeft: Radius.zero, bottomRight: Radius.zero),
),
child: (msg.imagePath != null)
? ImageGridView(images: msg.imagePath!)
: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: width * 0.015,
),
Icon(
Icons.picture_as_pdf,
color: Colors.red.shade300,
size: 30,
),
SizedBox(
width: width * 0.015,
),
Flexible(
child: Text(
ctrl.filePath.value
.split('/')
.last
.split('-')
.last,
style: const TextStyle(
color: Colors.white, fontFamily: "Cera"),
),
],
)),
),
],
)),
),
Text(
"Prompt: ${msg.text}",
softWrap: true,
style: const TextStyle(
fontFamily: 'Cera',
color: Colors.black87,
fontSize: 16,
),
Text(
"Prompt: ${msg.text}",
softWrap: true,
style: const TextStyle(
fontFamily: 'Cera',
color: Colors.black87,
fontSize: 16,
),
),
],
),
),
],
);
} else {
return (isLastMessage && ctrl.shouldTextAnimate.value)
? AnimatedTextKit(
onFinished: () {
ctrl.shouldTextAnimate.value = false;
},
onTap: () {
ctrl.shouldTextAnimate.value = false;
},
displayFullTextOnTap: true,
animatedTexts: [
TyperAnimatedText(
speed: const Duration(milliseconds: 55),
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(isLastMessage && ctrl.shouldTextAnimate.value)
? AnimatedTextKit(
onFinished: () {
ctrl.shouldTextAnimate.value = false;
},
onTap: () {
ctrl.shouldTextAnimate.value = false;
},
displayFullTextOnTap: true,
animatedTexts: [
TyperAnimatedText(
speed: const Duration(milliseconds: 55),
msg.isUser
? "Prompt: ${msg.text}"
: "Response: ${msg.text}",
textStyle: TextStyle(
fontFamily: 'Cera',
color: msg.isUser
? Colors.black87
: (msg.text == "Failed")
? Colors.red
: Colors.grey,
fontSize: 16,
),
textAlign: (!msg.isUser && msg.text == "Failed")
? TextAlign.end
: TextAlign.start,
),
],
isRepeatingAnimation: false,
)
: Text(
msg.isUser
? "Prompt: ${msg.text}"
: "Response: ${msg.text}",
textStyle: TextStyle(
style: TextStyle(
fontFamily: 'Cera',
color: msg.isUser
? Colors.black87
Expand All @@ -136,24 +155,35 @@ class PromptMessagesWidget extends StatelessWidget {
? TextAlign.end
: TextAlign.start,
),
],
isRepeatingAnimation: false,
)
: Text(
msg.isUser ? "Prompt: ${msg.text}" : "Response: ${msg.text}",
style: TextStyle(
fontFamily: 'Cera',
color: msg.isUser
? Colors.black87
: (msg.text == "Failed")
? Colors.red
: Colors.grey,
fontSize: 16,
),
textAlign: (!msg.isUser && msg.text == "Failed")
? TextAlign.end
: TextAlign.start,
);
if (msg.imagePath != null)
Align(
alignment: Alignment.centerRight,
child: Container(
width: width * 0.5,
margin: const EdgeInsets.only(bottom: 12.0),
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
boxShadow: const [
BoxShadow(
color: Colors.grey,
spreadRadius: 1.0,
blurRadius: 6.0,
),
],
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Colors.blue.shade300,
Colors.lightGreenAccent.shade100
],
),
borderRadius: BorderRadius.circular(24).copyWith(
topLeft: Radius.zero, bottomRight: Radius.zero),
),
child: ImageGridView(images: msg.imagePath!)))
],
);
}
}).toList(),
);
Expand Down
Loading

0 comments on commit 2558fef

Please sign in to comment.