Flutter upgrade

This commit is contained in:
Hillel Coren 2023-12-17 13:18:02 +02:00
parent d5388e5567
commit b1a7444a61
6 changed files with 440 additions and 464 deletions

View File

@ -123,11 +123,7 @@ class EditScaffold extends StatelessWidget {
final showOverflow = isDesktop(context) && state.isFullScreen; final showOverflow = isDesktop(context) && state.isFullScreen;
return WillPopScope( return CallbackShortcuts(
onWillPop: () async {
return true;
},
child: CallbackShortcuts(
bindings: <ShortcutActivator, VoidCallback>{ bindings: <ShortcutActivator, VoidCallback>{
const SingleActivator(LogicalKeyboardKey.keyS, control: true): () => const SingleActivator(LogicalKeyboardKey.keyS, control: true): () =>
onSavePressed!(context), onSavePressed!(context),
@ -190,8 +186,7 @@ class EditScaffold extends StatelessWidget {
entity != null && entity != null &&
entity!.isOld) ...[ entity!.isOld) ...[
EntityStatusChip( EntityStatusChip(
entity: entity: state.getEntity(entity!.entityType, entity!.id)),
state.getEntity(entity!.entityType, entity!.id)),
SizedBox(width: 8), SizedBox(width: 8),
], ],
if (showOverflow) if (showOverflow)
@ -226,8 +221,7 @@ class EditScaffold extends StatelessWidget {
: null, : null,
child: ConstrainedBox( child: ConstrainedBox(
constraints: BoxConstraints( constraints: BoxConstraints(
minWidth: minWidth: isDesktop(context) ? 60 : 0),
isDesktop(context) ? 60 : 0),
child: isDesktop(context) child: isDesktop(context)
? IconText( ? IconText(
icon: getEntityActionIcon(action), icon: getEntityActionIcon(action),
@ -272,8 +266,8 @@ class EditScaffold extends StatelessWidget {
builder: (context, remaining) { builder: (context, remaining) {
return PopupMenuButton<EntityAction>( return PopupMenuButton<EntityAction>(
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric( padding:
horizontal: 8), const EdgeInsets.symmetric(horizontal: 8),
child: isDesktop(context) child: isDesktop(context)
? Row( ? Row(
children: [ children: [
@ -294,8 +288,7 @@ class EditScaffold extends StatelessWidget {
itemBuilder: (BuildContext context) { itemBuilder: (BuildContext context) {
return entityActions return entityActions
.toList() .toList()
.sublist( .sublist(entityActions.length - remaining)
entityActions.length - remaining)
.map((action) { .map((action) {
return PopupMenuItem<EntityAction>( return PopupMenuItem<EntityAction>(
value: action, value: action,
@ -330,8 +323,7 @@ class EditScaffold extends StatelessWidget {
child: SizedBox( child: SizedBox(
width: 26, width: 26,
height: 26, height: 26,
child: child: CircularProgressIndicator(color: Colors.white),
CircularProgressIndicator(color: Colors.white),
)), )),
) )
else if (isDesktop(context)) else if (isDesktop(context))
@ -363,10 +355,8 @@ class EditScaffold extends StatelessWidget {
OutlinedButton( OutlinedButton(
style: isEnabled style: isEnabled
? ButtonStyle( ? ButtonStyle(
backgroundColor: backgroundColor: MaterialStateProperty.all(
MaterialStateProperty.all(state state.prefState.colorThemeModel!
.prefState
.colorThemeModel!
.colorSuccess)) .colorSuccess))
: null, : null,
onPressed: !isEnabled || onPressed: !isEnabled ||
@ -466,12 +456,10 @@ class EditScaffold extends StatelessWidget {
: appBarBottom as PreferredSizeWidget?, : appBarBottom as PreferredSizeWidget?,
), ),
bottomNavigationBar: bottomNavigationBar, bottomNavigationBar: bottomNavigationBar,
floatingActionButtonLocation: floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
FloatingActionButtonLocation.endDocked,
floatingActionButton: floatingActionButton, floatingActionButton: floatingActionButton,
), ),
), ),
),
); );
} }
} }

View File

@ -124,10 +124,10 @@ class ListScaffold extends StatelessWidget {
], ],
); );
return WillPopScope( return PopScope(
onWillPop: () async { canPop: false,
onPopInvoked: (_) {
store.dispatch(ViewDashboard()); store.dispatch(ViewDashboard());
return false;
}, },
child: FocusTraversalGroup( child: FocusTraversalGroup(
child: Scaffold( child: Scaffold(

View File

@ -258,8 +258,9 @@ class MainScreen extends StatelessWidget {
print('## Error: main screen route $mainRoute not defined'); print('## Error: main screen route $mainRoute not defined');
} }
return WillPopScope( return PopScope(
onWillPop: () async { canPop: false,
onPopInvoked: (_) async {
final state = store.state; final state = store.state;
final historyList = state.historyList; final historyList = state.historyList;
final isEditing = state.uiState.isEditing; final isEditing = state.uiState.isEditing;
@ -268,7 +269,6 @@ class MainScreen extends StatelessWidget {
if (state.uiState.isPreviewing) { if (state.uiState.isPreviewing) {
store.dispatch(PopPreviewStack()); store.dispatch(PopPreviewStack());
return false;
} }
for (int i = index; i < historyList.length; i++) { for (int i = index; i < historyList.length; i++) {
@ -300,9 +300,7 @@ class MainScreen extends StatelessWidget {
if (history == null) { if (history == null) {
store.dispatch(ViewDashboard()); store.dispatch(ViewDashboard());
return false; } else {
}
switch (history.entityType) { switch (history.entityType) {
case EntityType.dashboard: case EntityType.dashboard:
store.dispatch(ViewDashboard()); store.dispatch(ViewDashboard());
@ -330,8 +328,7 @@ class MainScreen extends StatelessWidget {
); );
} }
} }
}
return false;
}, },
child: DesktopSessionTimeout( child: DesktopSessionTimeout(
child: SafeArea( child: SafeArea(

View File

@ -89,11 +89,7 @@ class ViewScaffold extends StatelessWidget {
} }
} }
return WillPopScope( return FocusTraversalGroup(
onWillPop: () async {
return true;
},
child: FocusTraversalGroup(
child: Scaffold( child: Scaffold(
backgroundColor: Theme.of(context).cardColor, backgroundColor: Theme.of(context).cardColor,
appBar: AppBar( appBar: AppBar(
@ -152,10 +148,8 @@ class ViewScaffold extends StatelessWidget {
], ],
), ),
body: SafeArea( body: SafeArea(
child: entity.isNew child:
? BlankScreen(localization!.noRecordSelected) entity.isNew ? BlankScreen(localization!.noRecordSelected) : body,
: body,
),
), ),
), ),
); );

View File

@ -373,9 +373,7 @@ class _DashboardScreenState extends State<DashboardScreen>
), ),
); );
return WillPopScope( return isDesktop(context)
onWillPop: () async => true,
child: isDesktop(context)
? Row( ? Row(
children: [ children: [
Flexible( Flexible(
@ -394,8 +392,7 @@ class _DashboardScreenState extends State<DashboardScreen>
), ),
], ],
) )
: mainScaffold, : mainScaffold;
);
} }
} }

View File

@ -326,10 +326,10 @@ class ReportsScreen extends StatelessWidget {
), ),
]; ];
return WillPopScope( return PopScope(
onWillPop: () async { canPop: false,
onPopInvoked: (_) {
store.dispatch(ViewDashboard()); store.dispatch(ViewDashboard());
return false;
}, },
child: Scaffold( child: Scaffold(
drawer: isMobile(context) || state.prefState.isMenuFloated drawer: isMobile(context) || state.prefState.isMenuFloated