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
? []
: [
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(

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/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),

View File

@ -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,