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