diff --git a/team_b/yappy/lib/audiowave_widget.dart b/team_b/yappy/lib/audiowave_widget.dart index ea242f69..c1426463 100644 --- a/team_b/yappy/lib/audiowave_widget.dart +++ b/team_b/yappy/lib/audiowave_widget.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'dart:math'; import 'services/speech_state.dart'; + class AudiowaveWidget extends StatelessWidget { final SpeechState speechState; diff --git a/team_b/yappy/lib/contact_page.dart b/team_b/yappy/lib/contact_page.dart index e69a2601..5742b3b2 100644 --- a/team_b/yappy/lib/contact_page.dart +++ b/team_b/yappy/lib/contact_page.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:yappy/tool_bar.dart'; +import 'package:yappy/theme_provider.dart'; //**************************************************************** */ //**************************************************************** */ @@ -10,6 +12,7 @@ import 'package:yappy/tool_bar.dart'; //**************************************************************** */ //**************************************************************** */ //**************************************************************** */ + class ContactApp extends StatelessWidget { const ContactApp({super.key}); @@ -25,13 +28,14 @@ class ContactPage extends StatelessWidget { final TextEditingController nameController = TextEditingController(); final TextEditingController emailController = TextEditingController(); final TextEditingController messageController = TextEditingController(); -//Creates a page for the Contact Us page -//The page will contain a form for the user to input their name, email, and message + ContactPage({super.key}); + @override Widget build(BuildContext context) { + final themeProvider = Provider.of(context); + return Scaffold( - backgroundColor: const Color.fromARGB(255, 0, 0, 0), appBar: PreferredSize( preferredSize: Size.fromHeight(140), child: ToolBar(), @@ -47,52 +51,65 @@ class ContactPage extends StatelessWidget { style: TextStyle( fontSize: 24, fontWeight: FontWeight.bold, - color: Colors.white, + color: themeProvider.isDarkMode ? Colors.white : Colors.black, ), ), + SizedBox(height: 16), TextField( controller: nameController, decoration: InputDecoration( labelText: 'Name', - labelStyle: TextStyle(color: Colors.white), + labelStyle: TextStyle( + color: themeProvider.isDarkMode ? Colors.white : Colors.black, + ), enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.white), + borderSide: BorderSide( + color: themeProvider.isDarkMode ? Colors.white : Colors.black, + ), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.blue), ), ), - style: TextStyle(color: Colors.white), + style: TextStyle(color: themeProvider.isDarkMode ? Colors.white : Colors.black), ), SizedBox(height: 16), TextField( controller: emailController, decoration: InputDecoration( labelText: 'Email', - labelStyle: TextStyle(color: Colors.white), + labelStyle: TextStyle( + color: themeProvider.isDarkMode ? Colors.white : Colors.black, + ), enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.white), + borderSide: BorderSide( + color: themeProvider.isDarkMode ? Colors.white : Colors.black, + ), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.blue), ), ), - style: TextStyle(color: Colors.white), + style: TextStyle(color: themeProvider.isDarkMode ? Colors.white : Colors.black), ), SizedBox(height: 16), TextField( controller: messageController, decoration: InputDecoration( labelText: 'Message', - labelStyle: TextStyle(color: Colors.white), + labelStyle: TextStyle( + color: themeProvider.isDarkMode ? Colors.white : Colors.black, + ), enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.white), + borderSide: BorderSide( + color: themeProvider.isDarkMode ? Colors.white : Colors.black, + ), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.blue), ), ), - style: TextStyle(color: Colors.white), + style: TextStyle(color: themeProvider.isDarkMode ? Colors.white : Colors.black), maxLines: 5, ), SizedBox(height: 20), diff --git a/team_b/yappy/lib/help.dart b/team_b/yappy/lib/help.dart index f1e3fb5b..d830c9c6 100644 --- a/team_b/yappy/lib/help.dart +++ b/team_b/yappy/lib/help.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; import 'package:yappy/tool_bar.dart'; import 'package:yappy/tutorial_page.dart'; - +import 'package:yappy/theme_provider.dart'; +import 'package:provider/provider.dart'; class HelpApp extends StatelessWidget { const HelpApp({super.key}); @@ -20,8 +21,9 @@ class HelpPage extends StatelessWidget { @override Widget build(BuildContext context) { + final themeProvider = Provider.of(context); + return Scaffold( - backgroundColor: const Color.fromARGB(255, 0, 0, 0), appBar: PreferredSize( preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.2), child: ToolBar() @@ -37,8 +39,9 @@ class HelpPage extends StatelessWidget { child: Text( 'Lets Yap about Yappy', style: TextStyle( - color: Colors.white, + color: themeProvider.isDarkMode ? Colors.white: Colors.black, fontSize: 24, + fontWeight: FontWeight.bold, ), ), ), @@ -52,8 +55,9 @@ class HelpPage extends StatelessWidget { Text( 'Welcome to Yappy! If this is your first time and need help with using Yappy, please select the button below.', style: TextStyle( - color: const Color.fromRGBO(255, 255, 255, 1), - fontSize: 12, + color: themeProvider.isDarkMode ? Colors.white: Colors.black, + fontSize: 14, + fontWeight: FontWeight.bold, ), ), SizedBox(height: 20), @@ -72,8 +76,9 @@ class HelpPage extends StatelessWidget { 'Reporting a Problem with Yappy\n' 'If something is not working on Yappy, please follow the instructions below to let us know.\n\n', style: TextStyle( - color: Colors.white, - fontSize: 12, + color: themeProvider.isDarkMode ? Colors.white: Colors.black, + fontSize: 14, + fontWeight: FontWeight.bold, ), ), SizedBox(height: 5), @@ -103,8 +108,9 @@ class HelpPage extends StatelessWidget { Text( '\n\nFeedback from the people who use Yappy has helped us redesign our products, improve our policies and fix technical problems. We really appreciate you taking the time to share your thoughts and suggestions with us.\n', style: TextStyle( - color: Colors.white, - fontSize: 12, + color: themeProvider.isDarkMode ? Colors.white: Colors.black, + fontSize: 16, + fontWeight: FontWeight.bold, ), ), SizedBox(height: 5), diff --git a/team_b/yappy/lib/home_page.dart b/team_b/yappy/lib/home_page.dart index 9c1e1be0..fde1243b 100644 --- a/team_b/yappy/lib/home_page.dart +++ b/team_b/yappy/lib/home_page.dart @@ -90,7 +90,6 @@ class _HomePageState extends State { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: const Color.fromARGB(255, 0, 0, 0), appBar: PreferredSize( preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.2), child: ToolBar(showHamburger: false), // Using the ToolBar widget @@ -125,7 +124,6 @@ class _HomePageState extends State { ); }, style: ElevatedButton.styleFrom( - backgroundColor: Colors.grey[900], padding: const EdgeInsets.symmetric(vertical: 15), ), child: Text( diff --git a/team_b/yappy/lib/industry_menu.dart b/team_b/yappy/lib/industry_menu.dart index 0217e665..bb0534ed 100644 --- a/team_b/yappy/lib/industry_menu.dart +++ b/team_b/yappy/lib/industry_menu.dart @@ -195,6 +195,8 @@ class _IndustryMenuState extends State { // Gets the width and height of the current screen double screenWidth = MediaQuery.of(context).size.width; double screenHeight = MediaQuery.of(context).size.height; + final isDarkMode = Theme.of(context).brightness == Brightness.dark; + return Padding( padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0), @@ -203,12 +205,12 @@ class _IndustryMenuState extends State { child: Column( children: [ Center( - // Creates the text box above the icons - child: Container( + // Creates the text box above the icons + child: Container( width: screenWidth * .75, decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), - color: const Color.fromARGB(255, 67, 67, 67), + color: isDarkMode ? Color.fromARGB(255, 79, 79, 83): Colors.green, ), padding: EdgeInsets.all(12), child: Center( @@ -232,7 +234,7 @@ class _IndustryMenuState extends State { color: !modelsExist ? Color.fromRGBO(128, 128, 128, 0.5) : (widget.speechState.recordState == RecordState.stop - ? Colors.grey + ? isDarkMode ? Colors.grey : Colors.green : Colors.red)), padding: EdgeInsets.all(5), child: Tooltip( @@ -247,7 +249,7 @@ class _IndustryMenuState extends State { ? Icons.mic : Icons.stop, color: !modelsExist - ? Color.fromRGBO(255, 255, 255, 0.5) + ? isDarkMode ? Colors.grey : Colors.green : Colors.white, size: screenHeight * .05, ), @@ -343,7 +345,7 @@ class _IndustryMenuState extends State { // Creates a industry specific icon based on user input Container( decoration: - BoxDecoration(shape: BoxShape.circle, color: Colors.grey), + BoxDecoration(shape: BoxShape.circle, color: isDarkMode ? Colors.grey : Colors.green), padding: EdgeInsets.all(5), child: IconButton( icon: Icon( @@ -361,7 +363,7 @@ class _IndustryMenuState extends State { // Creates a transcript history button Container( decoration: - BoxDecoration(shape: BoxShape.circle, color: Colors.grey), + BoxDecoration(shape: BoxShape.circle, color: isDarkMode ? Colors.grey : Colors.green), padding: EdgeInsets.all(5), child: IconButton( icon: Icon( @@ -379,7 +381,7 @@ class _IndustryMenuState extends State { // Creates a chatbot button Container( - decoration: BoxDecoration(shape: BoxShape.circle, color: Colors.grey), + decoration: BoxDecoration(shape: BoxShape.circle, color: isDarkMode ? Colors.grey : Colors.green), padding: EdgeInsets.all(5), child: IconButton( icon: Icon( @@ -483,7 +485,8 @@ class _IndustryMenuState extends State { void _showTranscriptsBottomSheet(BuildContext context) async { // Fetch transcripts first List> transcripts = await _fetchTranscripts(); - + if (!context.mounted) return; + final isDarkMode = Theme.of(context).brightness == Brightness.dark; // Check if the context is still valid if (!context.mounted) return; @@ -494,7 +497,7 @@ class _IndustryMenuState extends State { padding: EdgeInsets.all(16.0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), - color: const Color.fromARGB(255, 67, 67, 67), + color: isDarkMode ? const Color.fromARGB(255, 67, 67, 67) : Colors.green, ), child: Center( child: Column( @@ -595,6 +598,8 @@ class _IndustryMenuState extends State { void _showTranscriptsHistoryBottomSheet(BuildContext context) async { // Fetch transcripts first List> transcripts = await _fetchTranscripts(); + if (!context.mounted) return; + final isDarkMode = Theme.of(context).brightness == Brightness.dark; // Check if the context is still valid if (!context.mounted) return; @@ -606,7 +611,7 @@ class _IndustryMenuState extends State { padding: EdgeInsets.all(16.0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), - color: const Color.fromARGB(255, 67, 67, 67), + color: isDarkMode ? const Color.fromARGB(255, 67, 67, 67) : Colors.green, ), child: Center( child: Column( diff --git a/team_b/yappy/lib/main.dart b/team_b/yappy/lib/main.dart index b19706b7..70d1e011 100644 --- a/team_b/yappy/lib/main.dart +++ b/team_b/yappy/lib/main.dart @@ -5,16 +5,21 @@ import 'package:yappy/services/database_helper.dart'; import 'package:dart_openai/dart_openai.dart'; import 'package:yappy/env.dart'; import './toast_widget.dart'; +import 'package:provider/provider.dart'; +import 'theme_provider.dart'; // Create a global instance of DatabaseHelper final DatabaseHelper dbHelper = DatabaseHelper(); final GlobalKey navigatorKey = GlobalKey(); late SharedPreferences preferences; -void main() async{ +void main() async { WidgetsFlutterBinding.ensureInitialized(); preferences = await SharedPreferences.getInstance(); + // Load the theme preference from SharedPreferences + final isDarkMode = preferences.getBool('toggle_setting') ?? false; + // Env file setup for local development String apiKey = Env.apiKey; if (apiKey.isNotEmpty) { @@ -47,7 +52,13 @@ void main() async{ } }); - runApp(const MyApp()); + // Run the app and initialize ThemeProvider + runApp( + ChangeNotifierProvider( + create: (_) => ThemeProvider()..toggleTheme(isDarkMode), // Initialize with saved theme + child: const MyApp(), + ), + ); } class MyApp extends StatelessWidget { @@ -55,14 +66,15 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { + final themeProvider = Provider.of(context); + return MaterialApp( navigatorKey: navigatorKey, debugShowCheckedModeBanner: false, title: 'Yappy', - theme: ThemeData( - primarySwatch: Colors.lightGreen, - visualDensity: VisualDensity.adaptivePlatformDensity, - ), + theme: themeProvider.themeData, // Apply theme based on provider + darkTheme: ThemeProvider.darkTheme, // Provide dark theme separately + themeMode: themeProvider.isDarkMode ? ThemeMode.dark : ThemeMode.light, // Set theme mode based on isDarkMode home: HomePage(), builder: (context, child) { // Wrap every screen with ToastWidget @@ -70,4 +82,4 @@ class MyApp extends StatelessWidget { }, ); } -} \ No newline at end of file +} diff --git a/team_b/yappy/lib/mechanic.dart b/team_b/yappy/lib/mechanic.dart index 6029a25c..81d0b3d7 100644 --- a/team_b/yappy/lib/mechanic.dart +++ b/team_b/yappy/lib/mechanic.dart @@ -31,7 +31,6 @@ class MechanicalAidPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: const Color.fromARGB(255, 0, 0, 0), appBar: PreferredSize( preferredSize: Size.fromHeight(100), child: ToolBar(), diff --git a/team_b/yappy/lib/medical_doctor.dart b/team_b/yappy/lib/medical_doctor.dart index 7ae00cf4..0c035e5b 100644 --- a/team_b/yappy/lib/medical_doctor.dart +++ b/team_b/yappy/lib/medical_doctor.dart @@ -28,7 +28,6 @@ class MedicalDoctorPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: const Color.fromARGB(255, 0, 0, 0), appBar: PreferredSize( preferredSize: Size.fromHeight(100), child: ToolBar() diff --git a/team_b/yappy/lib/medical_patient.dart b/team_b/yappy/lib/medical_patient.dart index a5b7eaf5..52b4a970 100644 --- a/team_b/yappy/lib/medical_patient.dart +++ b/team_b/yappy/lib/medical_patient.dart @@ -28,7 +28,6 @@ class MedicalPatientPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: const Color.fromARGB(255, 0, 0, 0), appBar: PreferredSize( preferredSize: Size.fromHeight(100), child: ToolBar() diff --git a/team_b/yappy/lib/restaurant.dart b/team_b/yappy/lib/restaurant.dart index 62e3f215..20df3c55 100644 --- a/team_b/yappy/lib/restaurant.dart +++ b/team_b/yappy/lib/restaurant.dart @@ -15,7 +15,6 @@ class RestaurantPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: const Color.fromARGB(255, 0, 0, 0), appBar: PreferredSize( preferredSize: Size.fromHeight(100), child: ToolBar(), diff --git a/team_b/yappy/lib/search_bar_widget.dart b/team_b/yappy/lib/search_bar_widget.dart index 20c8b3d1..4df852dd 100644 --- a/team_b/yappy/lib/search_bar_widget.dart +++ b/team_b/yappy/lib/search_bar_widget.dart @@ -40,31 +40,28 @@ class _SearchBarWidgetState extends State { @override Widget build(BuildContext context) { - return Container( - color: const Color.fromARGB(255, 0, 0, 0), - child: Padding( - padding: const EdgeInsets.only(left: 4.0, right: 4.0), - child: SearchAnchor( - searchController: _searchController, - suggestionsBuilder: (BuildContext context, SearchController controller) async { - return _fetchSuggestions(controller.text, widget.industry); - }, - builder: (BuildContext context, SearchController controller) { - return SearchBar( - controller: _searchController, - padding: const WidgetStatePropertyAll( - EdgeInsets.symmetric(horizontal: 2.0), - ), - onTap: () { - controller.openView(); - }, - onChanged: (_) { - controller.openView(); - }, - leading: const Icon(Icons.search), - ); - }, - ), + return Padding( + padding: const EdgeInsets.only(left: 4.0, right: 4.0), + child: SearchAnchor( + searchController: _searchController, + suggestionsBuilder: (BuildContext context, SearchController controller) async { + return _fetchSuggestions(controller.text, widget.industry); + }, + builder: (BuildContext context, SearchController controller) { + return SearchBar( + controller: _searchController, + padding: const WidgetStatePropertyAll( + EdgeInsets.symmetric(horizontal: 2.0), + ), + onTap: () { + controller.openView(); + }, + onChanged: (_) { + controller.openView(); + }, + leading: const Icon(Icons.search), + ); + }, ), ); } diff --git a/team_b/yappy/lib/settings_page.dart b/team_b/yappy/lib/settings_page.dart index 54835e6b..81934068 100644 --- a/team_b/yappy/lib/settings_page.dart +++ b/team_b/yappy/lib/settings_page.dart @@ -1,8 +1,10 @@ import 'package:dart_openai/dart_openai.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import './services/model_manager.dart'; import 'package:yappy/main.dart'; +import 'package:yappy/theme_provider.dart'; class SettingsPage extends StatefulWidget { const SettingsPage({super.key}); @@ -50,6 +52,8 @@ class _SettingsPageState extends State { @override Widget build(BuildContext context) { + final themeProvider = Provider.of(context); + return Scaffold( appBar: AppBar( title: Text('Settings'), @@ -122,7 +126,15 @@ class _SettingsPageState extends State { ); }, ), - + SwitchListTile( + title: const Text('Dark Mode'), + subtitle: const Text('Toggle Dark Mode on or off'), + value: themeProvider.isDarkMode, + onChanged: (value) { + themeProvider.toggleTheme(value); + }, + ), + // Divider to separate original and new settings const Divider(), @@ -250,4 +262,5 @@ class _SettingsPageState extends State { ); } } + } \ No newline at end of file diff --git a/team_b/yappy/lib/theme_provider.dart b/team_b/yappy/lib/theme_provider.dart new file mode 100644 index 00000000..d6f1e0d0 --- /dev/null +++ b/team_b/yappy/lib/theme_provider.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +class ThemeProvider with ChangeNotifier { + bool _isDarkMode = false; + + bool get isDarkMode => _isDarkMode; + + ThemeProvider() { + _loadThemePreference(); + } + + Future _loadThemePreference() async { + final prefs = await SharedPreferences.getInstance(); + _isDarkMode = prefs.getBool('toggle_setting') ?? false; + notifyListeners(); + } + + Future toggleTheme(bool value) async { + _isDarkMode = value; + final prefs = await SharedPreferences.getInstance(); + await prefs.setBool('toggle_setting', value); + notifyListeners(); + } + + ThemeData get themeData { + return _isDarkMode ? darkTheme : lightTheme; + } + + static final ThemeData lightTheme = ThemeData( + brightness: Brightness.light, + primarySwatch: Colors.lightGreen, + visualDensity: VisualDensity.adaptivePlatformDensity, + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.green, + foregroundColor: Colors.black, + ), + ), + scaffoldBackgroundColor: Colors.white, + iconTheme: const IconThemeData( + color: Colors.black, + ), + ); + + static final ThemeData darkTheme = ThemeData( + brightness: Brightness.dark, + primarySwatch: Colors.grey, + visualDensity: VisualDensity.adaptivePlatformDensity, + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + backgroundColor: Color.fromARGB(255, 79, 79, 83), + foregroundColor: Colors.white, + ), + ), + scaffoldBackgroundColor: Colors.black, + iconTheme: const IconThemeData( + color: Colors.white, + ), + ); +} diff --git a/team_b/yappy/lib/tool_bar.dart b/team_b/yappy/lib/tool_bar.dart index 63ceb8b1..26f25568 100644 --- a/team_b/yappy/lib/tool_bar.dart +++ b/team_b/yappy/lib/tool_bar.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:yappy/home_page.dart'; import 'package:yappy/restaurant.dart'; import 'package:yappy/contact_page.dart'; @@ -7,6 +8,7 @@ import 'package:yappy/medical_patient.dart'; import 'package:yappy/medical_doctor.dart'; import 'package:yappy/mechanic.dart'; import 'package:yappy/settings_page.dart'; +import 'package:yappy/theme_provider.dart'; // Defines a reusable Hamburger Menu Widget (AppBar + Drawer) class ToolBar extends StatelessWidget { @@ -18,92 +20,91 @@ class ToolBar extends StatelessWidget { Widget build(BuildContext context) { double screenWidth = MediaQuery.of(context).size.width; double screenHeight = MediaQuery.of(context).size.height; + final themeProvider = Provider.of(context); return AppBar( - // Creates the hamburger icon for the menu - backgroundColor: Colors.black, - leading: showHamburger - ? Builder( - builder: (context) { - return IconButton( - icon: const Icon(Icons.menu, color: Colors.white), - onPressed: () { - Scaffold.of(context).openDrawer(); - }, - ); - }, - ): SizedBox(width: screenHeight * 0.08), - toolbarHeight: screenHeight * 0.11, - // Contains the Yappy! icon - title: Center( - child: CircleAvatar( - backgroundColor: const Color.fromARGB(255, 0, 0, 0), - radius: screenWidth * 0.2, - child: Image.asset( - 'assets/icon/app_icon.png', - width: screenWidth * 0.22, - height: screenWidth * 0.22, - ), + // Background color based on the theme + backgroundColor: themeProvider.isDarkMode ? Colors.black : Colors.white, + leading: showHamburger + ? Builder( + builder: (context) { + return IconButton( + icon: Icon(Icons.menu, color: themeProvider.isDarkMode ? Colors.white : Colors.black), + onPressed: () { + Scaffold.of(context).openDrawer(); + }, + ); + }, + ) : SizedBox(width: screenHeight * 0.08), + toolbarHeight: screenHeight * 0.11, + title: Center( + child: CircleAvatar( + backgroundColor: themeProvider.isDarkMode ? Colors.black : Colors.white, + radius: screenWidth * 0.2, + child: Image.asset( + 'assets/icon/app_icon.png', + width: screenWidth * 0.22, + height: screenWidth * 0.22, ), ), - actions: [ - // Contains the information button - IconButton( - icon: const Icon(Icons.info, color: Colors.white), - onPressed: () { - showDialog( - context: context, - builder: (BuildContext context) { - // Creates a pop up when the button is pressed - return AlertDialog( - title: const Text('Information'), - content: const Text('Yappy Terms & Conditions\n\n''By using Yappy,' - 'you agree to Use the app responsibly and comply ' - 'with all applicable laws. Respect user privacy ' - 'and refrain from harmful or abusive behavior.\n\n' - 'Understand that Yappy is not liable for ' - 'any misuse or legal consequences arising from its use. ' - 'We may update these terms as needed.\n\n' - 'Continued use of Yappy means acceptance of any changes..'), - actions: [ - TextButton( - onPressed: () { - Navigator.of(context).pop(); - }, - child: const Text('OK'), - ), - ], - ); - }, - ); - }, - ), - ], - ); + ), + actions: [ + // Information button with dynamic color + IconButton( + icon: Icon(Icons.info, color: themeProvider.isDarkMode ? Colors.white : Colors.green), + onPressed: () { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Information', style: TextStyle(color: themeProvider.isDarkMode ? Colors.white : Colors.black)), + content: Text( + 'Yappy Terms & Conditions\n\nBy using Yappy, you agree to use the app responsibly and comply with all applicable laws. Respect user privacy and refrain from harmful or abusive behavior.\n\nUnderstand that Yappy is not liable for any misuse or legal consequences arising from its use. We may update these terms as needed.\n\nContinued use of Yappy means acceptance of any changes.', + style: TextStyle(color: themeProvider.isDarkMode ? Colors.white : Colors.black), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text('OK', style: TextStyle(color: themeProvider.isDarkMode ? Colors.white : Colors.black)), + ), + ], + ); + }, + ); + }, + ), + ], + ); } } - // creates the hamburger menu + +// Creates the hamburger menu class HamburgerDrawer extends StatelessWidget { const HamburgerDrawer({super.key}); @override Widget build(BuildContext context) { + final themeProvider = Provider.of(context); + double screenWidth = MediaQuery.of(context).size.width; return SafeArea( child: Drawer( width: screenWidth * .45, - backgroundColor: const Color.fromARGB(255, 54, 54, 54), + // Background color based on theme + backgroundColor: themeProvider.isDarkMode ? Color.fromARGB(255, 79, 79, 83) : Colors.green, child: ListView( padding: EdgeInsets.zero, children: [ - _buildDrawerItem('Home', context, HomePage()), - _buildDrawerItem('Restaurant', context, RestaurantPage()), - _buildDrawerItem('Vehicle Maintenance', context, MechanicalAidPage()), - _buildDrawerItem('Medical Doctor', context, MedicalDoctorPage()), - _buildDrawerItem('Medical Patient', context, MedicalPatientPage()), - _buildDrawerItem('Help', context, HelpPage()), - _buildDrawerItem('Contact', context, ContactPage()), - _buildDrawerItem('Settings', context, SettingsPage()), + _buildDrawerItem('Home', context, HomePage(), themeProvider), + _buildDrawerItem('Restaurant', context, RestaurantPage(), themeProvider), + _buildDrawerItem('Vehicle Maintenance', context, MechanicalAidPage(), themeProvider), + _buildDrawerItem('Medical Doctor', context, MedicalDoctorPage(), themeProvider), + _buildDrawerItem('Medical Patient', context, MedicalPatientPage(), themeProvider), + _buildDrawerItem('Help', context, HelpPage(), themeProvider), + _buildDrawerItem('Contact', context, ContactPage(), themeProvider), + _buildDrawerItem('Settings', context, SettingsPage(), themeProvider), ], ), ), @@ -111,19 +112,21 @@ class HamburgerDrawer extends StatelessWidget { } // Creates the individual drawer items for the hamburger menu - Widget _buildDrawerItem(String title, BuildContext context, Widget page) { + Widget _buildDrawerItem(String title, BuildContext context, Widget page, ThemeProvider themeProvider) { return ListTile( contentPadding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0), - textColor: Colors.white, - tileColor: const Color.fromARGB(255, 54, 54, 54), - title: Text(title), + textColor: themeProvider.isDarkMode ? Colors.white : Colors.black, // Text color based on theme + tileColor: themeProvider.isDarkMode ? Color.fromARGB(255, 54, 54, 54) : Colors.green.shade200, + title: Text( + title, + style: TextStyle(color: themeProvider.isDarkMode ? Colors.white : Colors.black), // Text color based on theme + ), onTap: () { Navigator.push( context, - // Navigates to the page once the button is clicked MaterialPageRoute(builder: (context) => page), ); }, ); } -} \ No newline at end of file +} diff --git a/team_b/yappy/lib/transcription_box.dart b/team_b/yappy/lib/transcription_box.dart index 8076f375..e2a59642 100644 --- a/team_b/yappy/lib/transcription_box.dart +++ b/team_b/yappy/lib/transcription_box.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:yappy/theme_provider.dart'; class TranscriptionBox extends StatefulWidget { final TextEditingController controller; @@ -40,6 +42,7 @@ class TranscriptionBoxState extends State { @override Widget build(BuildContext context) { + final themeProvider = Provider.of(context); double screenHeight = MediaQuery.of(context).size.height; return SizedBox( @@ -47,7 +50,7 @@ class TranscriptionBoxState extends State { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(8.0), - color: const Color.fromARGB(255, 67, 67, 67), + color: themeProvider.isDarkMode ? const Color.fromARGB(255, 67, 67, 67): Colors.green, ), child: Scrollbar( controller: _scrollController, @@ -59,8 +62,8 @@ class TranscriptionBoxState extends State { maxLines: null, readOnly: true, decoration: InputDecoration( - hintText: "Transcription will appear here...", - hintStyle: TextStyle(color: Colors.white), + hintText: "", + hintStyle: TextStyle(color:Colors.white), border: InputBorder.none, contentPadding: EdgeInsets.all(10), ), diff --git a/team_b/yappy/pubspec.yaml b/team_b/yappy/pubspec.yaml index 4d1359e0..de0f428a 100644 --- a/team_b/yappy/pubspec.yaml +++ b/team_b/yappy/pubspec.yaml @@ -50,6 +50,7 @@ dependencies: file_picker: ^9.0.2 flutter_audio_waveforms: ^1.2.1+8 dart_openai: ^5.1.0 + provider: ^6.1.4 dev_dependencies: flutter_test: