refactor: enhance navigation robustness by introducing popSafe and safePushNamedAndRemoveUntil methods and updating their usage.
This commit is contained in:
@@ -4,7 +4,7 @@ import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:core_localization/core_localization.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
// ignore: depend_on_referenced_packages
|
||||
import 'package:krow_core/core.dart';
|
||||
|
||||
import '../blocs/bank_account_cubit.dart';
|
||||
import '../blocs/bank_account_state.dart';
|
||||
@@ -32,12 +32,9 @@ class BankAccountPage extends StatelessWidget {
|
||||
elevation: 0,
|
||||
leading: IconButton(
|
||||
icon: const Icon(UiIcons.arrowLeft, color: UiColors.textSecondary),
|
||||
onPressed: () => Modular.to.pop(),
|
||||
),
|
||||
title: Text(
|
||||
strings.title,
|
||||
style: UiTypography.headline3m.textPrimary,
|
||||
onPressed: () => Modular.to.popSafe(),
|
||||
),
|
||||
title: Text(strings.title, style: UiTypography.headline3m.textPrimary),
|
||||
bottom: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(1.0),
|
||||
child: Container(color: UiColors.border, height: 1.0),
|
||||
@@ -61,7 +58,8 @@ class BankAccountPage extends StatelessWidget {
|
||||
// Error is already shown on the page itself (lines 73-85), no need for snackbar
|
||||
},
|
||||
builder: (BuildContext context, BankAccountState state) {
|
||||
if (state.status == BankAccountStatus.loading && state.accounts.isEmpty) {
|
||||
if (state.status == BankAccountStatus.loading &&
|
||||
state.accounts.isEmpty) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
@@ -74,7 +72,9 @@ class BankAccountPage extends StatelessWidget {
|
||||
? translateErrorKey(state.errorMessage!)
|
||||
: 'Error',
|
||||
textAlign: TextAlign.center,
|
||||
style: UiTypography.body1m.copyWith(color: UiColors.textSecondary),
|
||||
style: UiTypography.body1m.copyWith(
|
||||
color: UiColors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -92,11 +92,14 @@ class BankAccountPage extends StatelessWidget {
|
||||
const SizedBox(height: UiConstants.space6),
|
||||
Text(
|
||||
strings.linked_accounts,
|
||||
style: UiTypography.headline4m.copyWith(color: UiColors.textPrimary),
|
||||
style: UiTypography.headline4m.copyWith(
|
||||
color: UiColors.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: UiConstants.space3),
|
||||
...state.accounts.map((StaffBankAccount a) => _buildAccountCard(a, strings)), // Added type
|
||||
|
||||
...state.accounts.map(
|
||||
(StaffBankAccount a) => _buildAccountCard(a, strings),
|
||||
), // Added type
|
||||
// Add extra padding at bottom
|
||||
const SizedBox(height: UiConstants.space20),
|
||||
],
|
||||
@@ -121,17 +124,23 @@ class BankAccountPage extends StatelessWidget {
|
||||
backgroundColor: UiColors.transparent,
|
||||
child: AddAccountForm(
|
||||
strings: strings,
|
||||
onSubmit: (String bankName, String routing, String account, String type) {
|
||||
cubit.addAccount(
|
||||
bankName: bankName,
|
||||
routingNumber: routing,
|
||||
accountNumber: account,
|
||||
type: type,
|
||||
);
|
||||
Modular.to.pop();
|
||||
},
|
||||
onSubmit:
|
||||
(
|
||||
String bankName,
|
||||
String routing,
|
||||
String account,
|
||||
String type,
|
||||
) {
|
||||
cubit.addAccount(
|
||||
bankName: bankName,
|
||||
routingNumber: routing,
|
||||
accountNumber: account,
|
||||
type: type,
|
||||
);
|
||||
Modular.to.popSafe();
|
||||
},
|
||||
onCancel: () {
|
||||
Modular.to.pop();
|
||||
Modular.to.popSafe();
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -249,12 +258,13 @@ class BankAccountPage extends StatelessWidget {
|
||||
),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
const Icon(UiIcons.check, size: UiConstants.iconXs, color: primaryColor),
|
||||
const SizedBox(width: UiConstants.space1),
|
||||
Text(
|
||||
strings.primary,
|
||||
style: UiTypography.body3m.primary,
|
||||
const Icon(
|
||||
UiIcons.check,
|
||||
size: UiConstants.iconXs,
|
||||
color: primaryColor,
|
||||
),
|
||||
const SizedBox(width: UiConstants.space1),
|
||||
Text(strings.primary, style: UiTypography.body3m.primary),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:core_localization/core_localization.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import '../blocs/time_card_bloc.dart';
|
||||
import '../widgets/month_selector.dart';
|
||||
import '../widgets/shift_history_list.dart';
|
||||
@@ -37,8 +38,11 @@ class _TimeCardPageState extends State<TimeCardPage> {
|
||||
backgroundColor: UiColors.bgPopup,
|
||||
elevation: 0,
|
||||
leading: IconButton(
|
||||
icon: const Icon(UiIcons.chevronLeft, color: UiColors.iconSecondary),
|
||||
onPressed: () => Modular.to.pop(),
|
||||
icon: const Icon(
|
||||
UiIcons.chevronLeft,
|
||||
color: UiColors.iconSecondary,
|
||||
),
|
||||
onPressed: () => Modular.to.popSafe(),
|
||||
),
|
||||
title: Text(
|
||||
t.staff_time_card.title,
|
||||
@@ -69,7 +73,9 @@ class _TimeCardPageState extends State<TimeCardPage> {
|
||||
child: Text(
|
||||
translateErrorKey(state.message),
|
||||
textAlign: TextAlign.center,
|
||||
style: UiTypography.body1m.copyWith(color: UiColors.textSecondary),
|
||||
style: UiTypography.body1m.copyWith(
|
||||
color: UiColors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -83,12 +89,22 @@ class _TimeCardPageState extends State<TimeCardPage> {
|
||||
children: <Widget>[
|
||||
MonthSelector(
|
||||
selectedDate: state.selectedMonth,
|
||||
onPreviousMonth: () => _bloc.add(ChangeMonth(
|
||||
DateTime(state.selectedMonth.year, state.selectedMonth.month - 1),
|
||||
)),
|
||||
onNextMonth: () => _bloc.add(ChangeMonth(
|
||||
DateTime(state.selectedMonth.year, state.selectedMonth.month + 1),
|
||||
)),
|
||||
onPreviousMonth: () => _bloc.add(
|
||||
ChangeMonth(
|
||||
DateTime(
|
||||
state.selectedMonth.year,
|
||||
state.selectedMonth.month - 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
onNextMonth: () => _bloc.add(
|
||||
ChangeMonth(
|
||||
DateTime(
|
||||
state.selectedMonth.year,
|
||||
state.selectedMonth.month + 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: UiConstants.space6),
|
||||
TimeCardSummary(
|
||||
@@ -108,4 +124,3 @@ class _TimeCardPageState extends State<TimeCardPage> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user