refactor: update navigation method in CreateOrderView and ViewOrdersNavigator for improved routing
This commit is contained in:
@@ -4,7 +4,7 @@ import 'package:flutter_modular/flutter_modular.dart';
|
||||
extension ViewOrdersNavigator on IModularNavigator {
|
||||
/// Navigates to the Create Order feature.
|
||||
void navigateToCreateOrder() {
|
||||
pushNamed('/client/create-order/');
|
||||
navigate('/client/create-order/');
|
||||
}
|
||||
|
||||
/// Navigates to the Order Details (placeholder for now).
|
||||
|
||||
@@ -27,7 +27,6 @@ class ViewOrdersPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<ViewOrdersCubit>(
|
||||
key: initialDate != null ? ValueKey<String>('view_orders_${initialDate!.toIso8601String()}') : null,
|
||||
create: (BuildContext context) => Modular.get<ViewOrdersCubit>(),
|
||||
child: ViewOrdersView(initialDate: initialDate),
|
||||
);
|
||||
@@ -52,9 +51,10 @@ class _ViewOrdersViewState extends State<ViewOrdersView> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.initialDate != null) {
|
||||
// Force initialization of cubit immediately
|
||||
_cubit = BlocProvider.of<ViewOrdersCubit>(context, listen: false);
|
||||
|
||||
if (widget.initialDate != null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
if (_didInitialJump) return;
|
||||
@@ -64,22 +64,8 @@ class _ViewOrdersViewState extends State<ViewOrdersView> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(ViewOrdersView oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.initialDate != null &&
|
||||
widget.initialDate != oldWidget.initialDate) {
|
||||
_cubit ??= BlocProvider.of<ViewOrdersCubit>(context, listen: false);
|
||||
_cubit?.jumpToDate(widget.initialDate!);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_cubit == null) {
|
||||
_cubit = BlocProvider.of<ViewOrdersCubit>(context);
|
||||
}
|
||||
return BlocBuilder<ViewOrdersCubit, ViewOrdersState>(
|
||||
builder: (BuildContext context, ViewOrdersState state) {
|
||||
final List<DateTime> calendarDays = state.calendarDays;
|
||||
@@ -102,7 +88,6 @@ class _ViewOrdersViewState extends State<ViewOrdersView> {
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: UiColors.white,
|
||||
body: Stack(
|
||||
children: <Widget>[
|
||||
// Background Gradient
|
||||
|
||||
Reference in New Issue
Block a user