diff --git a/lib/Components/message_notification.dart b/lib/Components/message_notification.dart index 5628eea..444a590 100644 --- a/lib/Components/message_notification.dart +++ b/lib/Components/message_notification.dart @@ -1,30 +1,22 @@ import 'package:flutter/material.dart'; -class MessageNotification extends StatelessWidget { - final VoidCallback onReplay; - - const MessageNotification({Key key, this.onReplay}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Card( - margin: const EdgeInsets.symmetric(horizontal: 4), - child: SafeArea( - child: ListTile( - leading: SizedBox.fromSize( - size: const Size(40, 40), - child: Text("YOLO")), - title: Text('Lily MacDonald'), - subtitle: Text('Do you want to see a movie?'), - trailing: IconButton( - icon: Icon(Icons.reply), - onPressed: () { - ///TODO i'm not sure it should be use this widget' BuildContext to create a Dialog - ///maybe i will give the answer in the future - if (onReplay != null) onReplay(); - }), - ), +showNotification (Color backgroundColor, Color textColor, String text, BuildContext context) { + final snackBar = SnackBar( + behavior: SnackBarBehavior.floating, + duration: const Duration(milliseconds: 1500), + width: 280.0, // Width of the SnackBar. + backgroundColor: backgroundColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), ), - ); - } -} \ No newline at end of file + padding: const EdgeInsets.symmetric( + horizontal: 8.0, // Inner padding for SnackBar content. + ), + content: Text( + text, + textAlign: TextAlign.center, + style: TextStyle(color: textColor), + ) + ); + ScaffoldMessenger.of(context).showSnackBar(snackBar); +} diff --git a/lib/Components/translation_tab.dart b/lib/Components/translation_tab.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Screens/Configurations/Section/section_detail_screen.dart b/lib/Screens/Configurations/Section/section_detail_screen.dart index cd77eb1..1c5041c 100644 --- a/lib/Screens/Configurations/Section/section_detail_screen.dart +++ b/lib/Screens/Configurations/Section/section_detail_screen.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:manager_app/Components/confirmation_dialog.dart'; import 'package:manager_app/Components/fetch_section_icon.dart'; +import 'package:manager_app/Components/message_notification.dart'; import 'package:manager_app/Components/multi_select_container.dart'; import 'package:manager_app/Components/multi_string_input_container.dart'; import 'package:manager_app/Components/rounded_button.dart'; @@ -10,7 +11,6 @@ import 'package:manager_app/app_context.dart'; import 'package:manager_app/client.dart'; import 'package:manager_app/constants.dart'; import 'package:managerapi/api.dart'; -import 'package:overlay_support/overlay_support.dart'; import 'package:provider/provider.dart'; import 'package:intl/intl.dart'; @@ -259,14 +259,7 @@ class _SectionDetailScreenState extends State { managerAppContext.selectedSection = section; appContext.setContext(managerAppContext); - // popup a toast. - toast('La section a été sauvegardée avec succès'); - - // show a notification at top of screen. - /*showSimpleNotification( - Text("La configuration a été sauvegardée avec succès"), - position: NotificationPosition.bottom, - background: Colors.green);*/ + showNotification(Colors.green, kWhite, 'La section a été sauvegardée avec succès', context); } getSpecificData(SectionDTO sectionDTO, AppContext appContext) { diff --git a/lib/Screens/Configurations/configuration_detail_screen.dart b/lib/Screens/Configurations/configuration_detail_screen.dart index 8906771..a450fda 100644 --- a/lib/Screens/Configurations/configuration_detail_screen.dart +++ b/lib/Screens/Configurations/configuration_detail_screen.dart @@ -5,6 +5,7 @@ import 'package:flutter/painting.dart'; import 'package:manager_app/Components/color_picker_input_container.dart'; import 'package:manager_app/Components/confirmation_dialog.dart'; import 'package:manager_app/Components/fetch_section_icon.dart'; +import 'package:manager_app/Components/message_notification.dart'; import 'package:manager_app/Components/multi_select_container.dart'; import 'package:manager_app/Components/rounded_button.dart'; import 'package:manager_app/Components/string_input_container.dart'; @@ -14,7 +15,6 @@ import 'package:manager_app/app_context.dart'; import 'package:manager_app/client.dart'; import 'package:manager_app/constants.dart'; import 'package:managerapi/api.dart'; -import 'package:overlay_support/overlay_support.dart'; import 'package:provider/provider.dart'; import 'package:intl/intl.dart'; @@ -361,14 +361,7 @@ class _ConfigurationDetailScreenState extends State { managerAppContext.selectedConfiguration = configuration; appContext.setContext(managerAppContext); - // popup a toast. - toast('La configuration a été sauvegardée avec succès'); - - // show a notification at top of screen. - /*showSimpleNotification( - Text("La configuration a été sauvegardée avec succès"), - position: NotificationPosition.bottom, - background: Colors.green);*/ + showNotification(Colors.green, kWhite, 'La configuration a été sauvegardée avec succès', context); } Future getConfiguration(ConfigurationDetailScreen widget, Client client) async { diff --git a/lib/Screens/Configurations/new_configuration_popup.dart b/lib/Screens/Configurations/new_configuration_popup.dart index c8c9bae..6ec4b4e 100644 --- a/lib/Screens/Configurations/new_configuration_popup.dart +++ b/lib/Screens/Configurations/new_configuration_popup.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:manager_app/Components/message_notification.dart'; import 'package:manager_app/Components/rounded_button.dart'; import 'package:manager_app/Components/string_input_container.dart'; import 'package:manager_app/Models/managerContext.dart'; import 'package:manager_app/app_context.dart'; import 'package:manager_app/constants.dart'; import 'package:managerapi/api.dart'; -import 'package:overlay_support/overlay_support.dart'; void showNewConfiguration(AppContext appContext, BuildContext context) { ConfigurationDTO configurationDTO = new ConfigurationDTO(); @@ -83,7 +83,6 @@ void create(ConfigurationDTO configurationDTO, AppContext appContext, context) a managerAppContext.selectedConfiguration = null; appContext.setContext(managerAppContext); - // popup a toast. - toast('La configuration a été créée avec succès'); + showNotification(Colors.green, kWhite, 'La configuration a été créée avec succès', context); } } \ No newline at end of file diff --git a/lib/Screens/Configurations/new_section_popup.dart b/lib/Screens/Configurations/new_section_popup.dart index 85dc847..f748459 100644 --- a/lib/Screens/Configurations/new_section_popup.dart +++ b/lib/Screens/Configurations/new_section_popup.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:manager_app/Components/message_notification.dart'; import 'package:manager_app/Components/multi_select_container.dart'; import 'package:manager_app/Components/rounded_button.dart'; import 'package:manager_app/Components/string_input_container.dart'; @@ -6,7 +7,6 @@ import 'package:manager_app/Models/managerContext.dart'; import 'package:manager_app/app_context.dart'; import 'package:manager_app/constants.dart'; import 'package:managerapi/api.dart'; -import 'package:overlay_support/overlay_support.dart'; void showNewSection(ConfigurationDTO configurationDTO, AppContext appContext, BuildContext context) { SectionDTO sectionDTO = new SectionDTO(); @@ -100,7 +100,6 @@ void create(SectionDTO sectionDTO, AppContext appContext, BuildContext context) managerAppContext.selectedConfiguration.sectionIds.add(newSection.id); appContext.setContext(managerAppContext); - // popup a toast. - toast('La section a été créée avec succès'); + showNotification(Colors.green, kWhite, 'La section a été créée avec succès !', context); } } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 84c9f23..c13e4af 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,13 +1,10 @@ import 'package:manager_app/Models/managerContext.dart'; import 'package:manager_app/Screens/Main/main_screen.dart'; -import 'package:managerapi/api.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'Screens/login_screen.dart'; import 'app_context.dart'; -import 'client.dart'; import 'constants.dart'; -import 'package:overlay_support/overlay_support.dart'; void main() { String initialRoute; @@ -37,27 +34,25 @@ class _MyAppState extends State { Widget build(BuildContext context) { return ChangeNotifierProvider( create: (_) => AppContext(widget.managerAppContext), - child: OverlaySupport( - child: MaterialApp( - debugShowCheckedModeBanner: false, - title: 'Manager App Demo', - initialRoute: widget.initialRoute, - /*supportedLocales: [ - const Locale('en', 'US'), - //const Locale('fr', 'FR'), - ],*/ - theme: ThemeData( - primarySwatch: Colors.blue, - scaffoldBackgroundColor: kBackgroundColor, - //fontFamily: "Vollkorn", - textTheme: TextTheme(bodyText1: TextStyle(color: kBodyTextColor)), - visualDensity: VisualDensity.adaptivePlatformDensity, - ), - routes: { - '/welcome': (context) => LoginScreen(), - '/main': (context) => MainScreen() - } - ), + child: MaterialApp( + debugShowCheckedModeBanner: false, + title: 'Manager App Demo', + initialRoute: widget.initialRoute, + /*supportedLocales: [ + const Locale('en', 'US'), + //const Locale('fr', 'FR'), + ],*/ + theme: ThemeData( + primarySwatch: Colors.blue, + scaffoldBackgroundColor: kBackgroundColor, + //fontFamily: "Vollkorn", + textTheme: TextTheme(bodyText1: TextStyle(color: kBodyTextColor)), + visualDensity: VisualDensity.adaptivePlatformDensity, + ), + routes: { + '/welcome': (context) => LoginScreen(), + '/main': (context) => MainScreen() + } ), ); } diff --git a/pubspec.lock b/pubspec.lock index cc9bcaf..45a58c8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -56,7 +56,7 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" fake_async: dependency: transitive description: @@ -116,6 +116,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.10" + material_segmented_control: + dependency: "direct main" + description: + name: material_segmented_control + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.2" meta: dependency: transitive description: @@ -137,13 +144,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - overlay_support: - dependency: "direct main" - description: - name: overlay_support - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5-hotfix1" path: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9a78927..9b0da39 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -26,10 +26,10 @@ dependencies: rxdart: 0.22.0 provider: ^5.0.0 - overlay_support: 1.0.5-hotfix1 auto_size_text: ^2.1.0 flutter_colorpicker: ^0.4.0 multiselect_formfield: ^0.1.6 + material_segmented_control: ^3.1.2 managerapi: path: manager_api