updated snackbar to flushbar + added copy to other languages

This commit is contained in:
Thomas Fransolet 2024-07-02 16:22:45 +02:00
parent 214fe574e6
commit a9f9aa81e0
5 changed files with 68 additions and 20 deletions

View File

@ -1,7 +1,18 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
showNotification (Color backgroundColor, Color textColor, String text, BuildContext context, int? duration) {
final snackBar = SnackBar(
showNotification (Color backgroundColor, Color textColor, String text, BuildContext context, int? duration) async {
await Flushbar(
message: text,
messageColor: textColor,
margin: EdgeInsets.all(8),
backgroundColor: backgroundColor,
borderRadius: BorderRadius.circular(8),
duration: duration == null ? Duration(milliseconds: 1500) : Duration(milliseconds: duration),
).show(context);
/*final snackBar = SnackBar(
behavior: SnackBarBehavior.floating,
duration: duration == null ? Duration(milliseconds: 1500) : Duration(milliseconds: duration),
width: 320.0, // Width of the SnackBar.
@ -23,5 +34,5 @@ showNotification (Color backgroundColor, Color textColor, String text, BuildCont
),
)
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
ScaffoldMessenger.of(context).showSnackBar(snackBar);*/
}

View File

@ -9,6 +9,7 @@ import 'package:collection/collection.dart';
showMultiStringInputHTML (String label, String modalLabel, bool isTitle, List<TranslationDTO> values, List<TranslationDTO> newValues, Function onGetResult, int maxLines, List<ResourceType>? resourceTypes, BuildContext context, bool isMandatory) {
showDialog(
useRootNavigator: false,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
@ -70,6 +71,7 @@ showMultiStringInputHTML (String label, String modalLabel, bool isTitle, List<Tr
showMultiStringInputAndResourceHTML (String label, String modalLabel, bool isTitle, List<TranslationAndResourceDTO> values, List<TranslationAndResourceDTO> newValues, Function onGetResult, int maxLines, List<ResourceType>? resourceTypes, BuildContext context) {
showDialog(
useRootNavigator: false,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(

View File

@ -2,12 +2,14 @@ import 'package:flutter/material.dart';
import 'package:manager_api_new/api.dart';
import 'package:manager_app/Components/audio_input_container.dart';
import 'package:manager_app/Components/resource_input_container.dart';
import 'package:manager_app/Components/rounded_button.dart';
import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart';
import 'package:provider/provider.dart';
import 'package:quill_html_editor/quill_html_editor.dart';
import 'flag_decoration.dart';
import 'message_notification.dart';
class _TranslationInputContainerState extends State<TranslationInputContainer> with TickerProviderStateMixin {
TabController? _tabController;
@ -201,30 +203,54 @@ class _TranslationInputContainerState extends State<TranslationInputContainer> w
];
return Container(
height: widget.isTitle ? MediaQuery.of(context).size.height *0.35 : MediaQuery.of(context).size.height *0.53,
height: widget.isTitle ? MediaQuery.of(context).size.height *0.4 : MediaQuery.of(context).size.height *0.53,
width: MediaQuery.of(context).size.width *0.7,
constraints: BoxConstraints(
minHeight: 200,
minWidth: 300
),
child: DefaultTabController(
length: widget.newValues.length,
child: Column(
children: [
RotatedBox(
quarterTurns: 0, // Can be used to test vertical tab in case of smaller screen
child: TabBar(
indicatorColor: kPrimaryColor,
//overlayColor: MaterialStateProperty().c,
labelColor: kPrimaryColor,
unselectedLabelColor: Colors.black,
controller: _tabController,
tabs: widget.newValues.map((v) => Tab(icon: FlagDecoration(language: v.language!))).toList(), // text: v.language!.toUpperCase(),
child: Column(
children: [
DefaultTabController(
length: widget.newValues.length,
child: Column(
children: [
RotatedBox(
quarterTurns: 0, // Can be used to test vertical tab in case of smaller screen
child: TabBar(
indicatorColor: kPrimaryColor,
//overlayColor: MaterialStateProperty().c,
labelColor: kPrimaryColor,
unselectedLabelColor: Colors.black,
controller: _tabController,
tabs: widget.newValues.map((v) => Tab(icon: FlagDecoration(language: v.language!))).toList(), // text: v.language!.toUpperCase(),
),
),
getTranslation(context, Provider.of<AppContext>(context), controllerQuill, customToolBarList, widget.isTitle, widget.resourceTypes, widget.newValues, currentLanguage!)
],
),
),
Center(
child: Container(
width: 370,
height: 70,
child: RoundedButton(
text: "Appliquer à toutes les langues",
icon: Icons.copy,
color: kSecond,
press: () async {
var plainText = await controllerQuill.getText();
widget.newValues.forEach((language) {
language.value = plainText;
}
);
showNotification(kSuccess, kWhite, 'Le texte a été appliqué à toutes les langues', context, null);
},
fontSize: 20,
),
),
getTranslation(context, Provider.of<AppContext>(context), controllerQuill, customToolBarList, widget.isTitle, widget.resourceTypes, widget.newValues, currentLanguage!)
],
),
),
],
),
);
}

View File

@ -25,6 +25,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.1.0"
another_flushbar:
dependency: "direct main"
description:
name: another_flushbar
sha256: "19bf9520230ec40b300aaf9dd2a8fefcb277b25ecd1c4838f530566965befc2a"
url: "https://pub.dev"
source: hosted
version: "1.12.30"
archive:
dependency: transitive
description:

View File

@ -70,6 +70,7 @@ dependencies:
flutter_widget_from_html: ^0.10.1
firebase_storage: ^12.0.1
firebase_core: ^3.1.0
another_flushbar: ^1.12.30
dev_dependencies:
flutter_test: