From c6264789c4647ab2163da0acd0f9f618e80b52af Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 28 Aug 2022 21:28:23 +0300 Subject: [PATCH] Adjust create button --- lib/ui/app/edit_scaffold.dart | 4 +-- lib/ui/app/list_scaffold.dart | 41 +++++++++++++++++++++--------- lib/ui/reports/reports_screen.dart | 1 + 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/lib/ui/app/edit_scaffold.dart b/lib/ui/app/edit_scaffold.dart index de9993ea6..9d06f0939 100644 --- a/lib/ui/app/edit_scaffold.dart +++ b/lib/ui/app/edit_scaffold.dart @@ -291,7 +291,7 @@ class EditScaffold extends StatelessWidget { actions: showOverflow ? [] : [ - if (state.isSaving && isMobileOS()) + if (state.isSaving && isMobile(context)) Padding( padding: const EdgeInsets.only(right: 20), child: Center( @@ -301,7 +301,7 @@ class EditScaffold extends StatelessWidget { child: CircularProgressIndicator(color: Colors.white), )), ) - else if (isDesktopOS()) + else if (isDesktop(context)) Row( children: [ OutlinedButton( diff --git a/lib/ui/app/list_scaffold.dart b/lib/ui/app/list_scaffold.dart index f82f54225..d726d36df 100644 --- a/lib/ui/app/list_scaffold.dart +++ b/lib/ui/app/list_scaffold.dart @@ -13,6 +13,7 @@ import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart'; import 'package:invoiceninja_flutter/redux/ui/pref_state.dart'; import 'package:invoiceninja_flutter/ui/app/app_bottom_bar.dart'; import 'package:invoiceninja_flutter/ui/app/history_drawer_vm.dart'; +import 'package:invoiceninja_flutter/ui/app/icon_text.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; import 'package:invoiceninja_flutter/utils/platforms.dart'; import 'menu_drawer_vm.dart'; @@ -79,28 +80,46 @@ class ListScaffold extends StatelessWidget { ), ); } else if (entityType != null && entityType != EntityType.settings) { - leading = IconButton( - icon: Icon(Icons.add), - tooltip: prefState.enableTooltips ? localization.createNew : null, - onPressed: () { - createEntityByType(entityType: entityType, context: context); - }, + leading = Padding( + padding: const EdgeInsets.only(left: 20, right: 12), + child: OutlinedButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + state.prefState.colorThemeModel.colorSuccess)), + onPressed: () { + createEntityByType(entityType: entityType, context: context); + }, + child: IconText( + text: localization.create, + icon: Icons.add_circle_outline, + style: TextStyle(color: Colors.white), + ), + ), ); } + double leadingWidth = 0; + if (entityType == EntityType.settings) { + leadingWidth = isDesktop(context) ? 0 : 40; + } else { + leadingWidth = (isDesktop(context) ? 90 : 10) + + kMinInteractiveDimension * + (appBarLeadingActions.length + + (onCheckboxPressed == null || isMobile(context) ? 1 : 2)); + } + leading = Row( children: [ Expanded(child: leading), if (isDesktop(context) && onCheckboxPressed != null) - Expanded( - child: IconButton( + IconButton( icon: Icon(Icons.check_box), tooltip: prefState.enableTooltips ? localization.multiselect : null, onPressed: state.prefState.showKanban && state.uiState.mainRoute == '${EntityType.task}' ? null : () => onCheckboxPressed(), - )), + ), ...appBarLeadingActions, ], ); @@ -123,9 +142,7 @@ class ListScaffold extends StatelessWidget { centerTitle: false, automaticallyImplyLeading: false, leading: leading, - leadingWidth: kMinInteractiveDimension * - (appBarLeadingActions.length + - (onCheckboxPressed == null || isMobile(context) ? 1 : 2)), + leadingWidth: leadingWidth, title: Row( children: [ Expanded(child: appBarTitle), diff --git a/lib/ui/reports/reports_screen.dart b/lib/ui/reports/reports_screen.dart index e297dc04d..bbb7096fc 100644 --- a/lib/ui/reports/reports_screen.dart +++ b/lib/ui/reports/reports_screen.dart @@ -319,6 +319,7 @@ class ReportsScreen extends StatelessWidget { appBar: AppBar( centerTitle: false, automaticallyImplyLeading: false, + leadingWidth: isMobile(context) ? 40 : 0, leading: leading, title: Row( mainAxisSize: MainAxisSize.min,