Added toast library
This commit is contained in:
parent
827b38fdff
commit
d47763869a
|
|
@ -190,6 +190,7 @@ abstract class TaskEntity extends Object
|
||||||
|
|
||||||
TaskEntity get clone => rebuild((b) => b
|
TaskEntity get clone => rebuild((b) => b
|
||||||
..id = BaseEntity.nextId
|
..id = BaseEntity.nextId
|
||||||
|
..number = ''
|
||||||
..isChanged = false
|
..isChanged = false
|
||||||
..isDeleted = false
|
..isDeleted = false
|
||||||
..invoiceId = null
|
..invoiceId = null
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
|
|
@ -173,8 +174,18 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
TargetPlatform.android: ZoomPageTransitionsBuilder(),
|
TargetPlatform.android: ZoomPageTransitionsBuilder(),
|
||||||
});
|
});
|
||||||
Intl.defaultLocale = localeSelector(state);
|
Intl.defaultLocale = localeSelector(state);
|
||||||
|
final locale = AppLocalization.createLocale(localeSelector(state));
|
||||||
|
|
||||||
return MaterialApp(
|
return StyledToast(
|
||||||
|
locale: locale,
|
||||||
|
duration: Duration(seconds: 3),
|
||||||
|
backgroundColor:
|
||||||
|
state.prefState.enableDarkMode ? Colors.white : Colors.black,
|
||||||
|
textStyle: TextStyle(
|
||||||
|
color:
|
||||||
|
state.prefState.enableDarkMode ? Colors.black87 : Colors.white,
|
||||||
|
),
|
||||||
|
child: MaterialApp(
|
||||||
supportedLocales: kLanguages
|
supportedLocales: kLanguages
|
||||||
.map((String locale) => AppLocalization.createLocale(locale))
|
.map((String locale) => AppLocalization.createLocale(locale))
|
||||||
.toList(),
|
.toList(),
|
||||||
|
|
@ -189,7 +200,7 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
home: state.prefState.requireAuthentication && !_authenticated
|
home: state.prefState.requireAuthentication && !_authenticated
|
||||||
? LockScreen(onAuthenticatePressed: _authenticate)
|
? LockScreen(onAuthenticatePressed: _authenticate)
|
||||||
: InitScreen(),
|
: InitScreen(),
|
||||||
locale: AppLocalization.createLocale(localeSelector(state)),
|
locale: locale,
|
||||||
theme: state.prefState.enableDarkMode
|
theme: state.prefState.enableDarkMode
|
||||||
? ThemeData(
|
? ThemeData(
|
||||||
pageTransitionsTheme: pageTransitionsTheme,
|
pageTransitionsTheme: pageTransitionsTheme,
|
||||||
|
|
@ -247,8 +258,12 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
color: hasAccentColor ? Colors.white : accentColor,
|
color: hasAccentColor ? Colors.white : accentColor,
|
||||||
),
|
),
|
||||||
textTheme: TextTheme(
|
textTheme: TextTheme(
|
||||||
headline6: Theme.of(context).textTheme.headline6.copyWith(
|
headline6: Theme.of(context)
|
||||||
color: hasAccentColor ? Colors.white : Colors.black,
|
.textTheme
|
||||||
|
.headline6
|
||||||
|
.copyWith(
|
||||||
|
color:
|
||||||
|
hasAccentColor ? Colors.white : Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -259,7 +274,8 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
? {
|
? {
|
||||||
LoginScreen.route: (context) => LoginScreen(),
|
LoginScreen.route: (context) => LoginScreen(),
|
||||||
MainScreen.route: (context) => MainScreen(),
|
MainScreen.route: (context) => MainScreen(),
|
||||||
DashboardScreenBuilder.route: (context) => ChangeLayoutBanner(
|
DashboardScreenBuilder.route: (context) =>
|
||||||
|
ChangeLayoutBanner(
|
||||||
suggestedLayout: AppLayout.mobile,
|
suggestedLayout: AppLayout.mobile,
|
||||||
appLayout: state.prefState.appLayout,
|
appLayout: state.prefState.appLayout,
|
||||||
child: DashboardScreenBuilder(),
|
child: DashboardScreenBuilder(),
|
||||||
|
|
@ -292,7 +308,8 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
PaymentScreen.route: (context) => PaymentScreenBuilder(),
|
PaymentScreen.route: (context) => PaymentScreenBuilder(),
|
||||||
PaymentViewScreen.route: (context) => PaymentViewScreen(),
|
PaymentViewScreen.route: (context) => PaymentViewScreen(),
|
||||||
PaymentEditScreen.route: (context) => PaymentEditScreen(),
|
PaymentEditScreen.route: (context) => PaymentEditScreen(),
|
||||||
PaymentRefundScreen.route: (context) => PaymentRefundScreen(),
|
PaymentRefundScreen.route: (context) =>
|
||||||
|
PaymentRefundScreen(),
|
||||||
QuoteScreen.route: (context) => QuoteScreenBuilder(),
|
QuoteScreen.route: (context) => QuoteScreenBuilder(),
|
||||||
QuoteViewScreen.route: (context) => QuoteViewScreen(),
|
QuoteViewScreen.route: (context) => QuoteViewScreen(),
|
||||||
QuoteEditScreen.route: (context) => QuoteEditScreen(),
|
QuoteEditScreen.route: (context) => QuoteEditScreen(),
|
||||||
|
|
@ -337,7 +354,8 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
UserScreen.route: (context) => UserScreenBuilder(),
|
UserScreen.route: (context) => UserScreenBuilder(),
|
||||||
UserViewScreen.route: (context) => UserViewScreen(),
|
UserViewScreen.route: (context) => UserViewScreen(),
|
||||||
UserEditScreen.route: (context) => UserEditScreen(),
|
UserEditScreen.route: (context) => UserEditScreen(),
|
||||||
GroupSettingsScreen.route: (context) => GroupScreenBuilder(),
|
GroupSettingsScreen.route: (context) =>
|
||||||
|
GroupScreenBuilder(),
|
||||||
GroupViewScreen.route: (context) => GroupViewScreen(),
|
GroupViewScreen.route: (context) => GroupViewScreen(),
|
||||||
GroupEditScreen.route: (context) => GroupEditScreen(),
|
GroupEditScreen.route: (context) => GroupEditScreen(),
|
||||||
SettingsScreen.route: (context) => SettingsScreenBuilder(),
|
SettingsScreen.route: (context) => SettingsScreenBuilder(),
|
||||||
|
|
@ -376,10 +394,13 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
GeneratedNumbersScreen(),
|
GeneratedNumbersScreen(),
|
||||||
WorkflowSettingsScreen.route: (context) =>
|
WorkflowSettingsScreen.route: (context) =>
|
||||||
WorkflowSettingsScreen(),
|
WorkflowSettingsScreen(),
|
||||||
InvoiceDesignScreen.route: (context) => InvoiceDesignScreen(),
|
InvoiceDesignScreen.route: (context) =>
|
||||||
|
InvoiceDesignScreen(),
|
||||||
ClientPortalScreen.route: (context) => ClientPortalScreen(),
|
ClientPortalScreen.route: (context) => ClientPortalScreen(),
|
||||||
BuyNowButtonsScreen.route: (context) => BuyNowButtonsScreen(),
|
BuyNowButtonsScreen.route: (context) =>
|
||||||
EmailSettingsScreen.route: (context) => EmailSettingsScreen(),
|
BuyNowButtonsScreen(),
|
||||||
|
EmailSettingsScreen.route: (context) =>
|
||||||
|
EmailSettingsScreen(),
|
||||||
TemplatesAndRemindersScreen.route: (context) =>
|
TemplatesAndRemindersScreen.route: (context) =>
|
||||||
TemplatesAndRemindersScreen(),
|
TemplatesAndRemindersScreen(),
|
||||||
CreditCardsAndBanksScreen.route: (context) =>
|
CreditCardsAndBanksScreen.route: (context) =>
|
||||||
|
|
@ -388,6 +409,7 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
DataVisualizationsScreen(),
|
DataVisualizationsScreen(),
|
||||||
}
|
}
|
||||||
: {},
|
: {},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,9 @@ class BottomButtons extends StatelessWidget {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: action1Enabled && !entity.isDeleted
|
onTap: action1Enabled &&
|
||||||
|
(!entity.isDeleted ||
|
||||||
|
action1 == EntityAction.viewPdf)
|
||||||
? () {
|
? () {
|
||||||
handleEntityAction(context, entity, action1);
|
handleEntityAction(context, entity, action1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,18 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
|
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/snackbar_row.dart';
|
|
||||||
|
|
||||||
/*
|
|
||||||
Completer<Null> refreshCompleter(BuildContext context) {
|
|
||||||
final Completer<Null> completer = Completer<Null>();
|
|
||||||
|
|
||||||
completer.future.then((_) {
|
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
|
||||||
content: SnackBarRow(
|
|
||||||
message: AppLocalization.of(context).refreshComplete,
|
|
||||||
)));
|
|
||||||
}).catchError((Object error) {
|
|
||||||
showDialog<ErrorDialog>(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return ErrorDialog(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return completer;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
Completer<T> snackBarCompleter<T>(BuildContext context, String message,
|
Completer<T> snackBarCompleter<T>(BuildContext context, String message,
|
||||||
{bool shouldPop = false}) {
|
{bool shouldPop = false}) {
|
||||||
final Completer<T> completer = Completer<T>();
|
final Completer<T> completer = Completer<T>();
|
||||||
ScaffoldState scaffold;
|
|
||||||
|
|
||||||
try {
|
|
||||||
scaffold = Scaffold.of(context);
|
|
||||||
} catch (e) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
completer.future.then((_) {
|
completer.future.then((_) {
|
||||||
if (shouldPop && Navigator.of(context).canPop()) {
|
if (shouldPop && Navigator.of(context).canPop()) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
if (scaffold != null) {
|
showToast(message);
|
||||||
scaffold.showSnackBar(SnackBar(
|
|
||||||
content: SnackBarRow(
|
|
||||||
message: message,
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
}).catchError((Object error) {
|
}).catchError((Object error) {
|
||||||
if (shouldPop && Navigator.of(context).canPop()) {
|
if (shouldPop && Navigator.of(context).canPop()) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
|
||||||
|
|
@ -415,6 +415,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.7"
|
version: "0.5.7"
|
||||||
|
flutter_styled_toast:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_styled_toast
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.4.0+1"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ dependencies:
|
||||||
#idb_shim: ^1.11.1+1
|
#idb_shim: ^1.11.1+1
|
||||||
flutter_launcher_icons: ^0.8.0
|
flutter_launcher_icons: ^0.8.0
|
||||||
overflow_view: ^0.2.1
|
overflow_view: ^0.2.1
|
||||||
|
flutter_styled_toast: ^1.4.0+1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_driver:
|
flutter_driver:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue