Adjust create button

This commit is contained in:
Hillel Coren 2022-08-28 21:28:23 +03:00
parent aa9a1e2f27
commit c6264789c4
3 changed files with 32 additions and 14 deletions

View File

@ -291,7 +291,7 @@ class EditScaffold extends StatelessWidget {
actions: showOverflow actions: showOverflow
? [] ? []
: [ : [
if (state.isSaving && isMobileOS()) if (state.isSaving && isMobile(context))
Padding( Padding(
padding: const EdgeInsets.only(right: 20), padding: const EdgeInsets.only(right: 20),
child: Center( child: Center(
@ -301,7 +301,7 @@ class EditScaffold extends StatelessWidget {
child: CircularProgressIndicator(color: Colors.white), child: CircularProgressIndicator(color: Colors.white),
)), )),
) )
else if (isDesktopOS()) else if (isDesktop(context))
Row( Row(
children: [ children: [
OutlinedButton( OutlinedButton(

View File

@ -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/redux/ui/pref_state.dart';
import 'package:invoiceninja_flutter/ui/app/app_bottom_bar.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/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/localization.dart';
import 'package:invoiceninja_flutter/utils/platforms.dart'; import 'package:invoiceninja_flutter/utils/platforms.dart';
import 'menu_drawer_vm.dart'; import 'menu_drawer_vm.dart';
@ -79,28 +80,46 @@ class ListScaffold extends StatelessWidget {
), ),
); );
} else if (entityType != null && entityType != EntityType.settings) { } else if (entityType != null && entityType != EntityType.settings) {
leading = IconButton( leading = Padding(
icon: Icon(Icons.add), padding: const EdgeInsets.only(left: 20, right: 12),
tooltip: prefState.enableTooltips ? localization.createNew : null, child: OutlinedButton(
onPressed: () { style: ButtonStyle(
createEntityByType(entityType: entityType, context: context); 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( leading = Row(
children: [ children: [
Expanded(child: leading), Expanded(child: leading),
if (isDesktop(context) && onCheckboxPressed != null) if (isDesktop(context) && onCheckboxPressed != null)
Expanded( IconButton(
child: IconButton(
icon: Icon(Icons.check_box), icon: Icon(Icons.check_box),
tooltip: prefState.enableTooltips ? localization.multiselect : null, tooltip: prefState.enableTooltips ? localization.multiselect : null,
onPressed: state.prefState.showKanban && onPressed: state.prefState.showKanban &&
state.uiState.mainRoute == '${EntityType.task}' state.uiState.mainRoute == '${EntityType.task}'
? null ? null
: () => onCheckboxPressed(), : () => onCheckboxPressed(),
)), ),
...appBarLeadingActions, ...appBarLeadingActions,
], ],
); );
@ -123,9 +142,7 @@ class ListScaffold extends StatelessWidget {
centerTitle: false, centerTitle: false,
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
leading: leading, leading: leading,
leadingWidth: kMinInteractiveDimension * leadingWidth: leadingWidth,
(appBarLeadingActions.length +
(onCheckboxPressed == null || isMobile(context) ? 1 : 2)),
title: Row( title: Row(
children: [ children: [
Expanded(child: appBarTitle), Expanded(child: appBarTitle),

View File

@ -319,6 +319,7 @@ class ReportsScreen extends StatelessWidget {
appBar: AppBar( appBar: AppBar(
centerTitle: false, centerTitle: false,
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
leadingWidth: isMobile(context) ? 40 : 0,
leading: leading, leading: leading,
title: Row( title: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,