Compare commits

...

2 Commits

Author SHA1 Message Date
Efril
96526c1972 update 2026-05-14 15:05:04 +07:00
Efril
c4618bbc1b update pesanan 2026-05-14 14:55:49 +07:00
10 changed files with 738 additions and 210 deletions

View File

@ -14,7 +14,7 @@ class DashboardAnalyticLoaderState with _$DashboardAnalyticLoaderState {
DashboardAnalyticLoaderState( DashboardAnalyticLoaderState(
dashboardAnalytic: DashboardAnalytic.empty(), dashboardAnalytic: DashboardAnalytic.empty(),
failureOptionDashboardAnalytic: none(), failureOptionDashboardAnalytic: none(),
dateFrom: DateTime.now().subtract(const Duration(days: 30)), dateFrom: DateTime.now(),
dateTo: DateTime.now(), dateTo: DateTime.now(),
); );
} }

View File

@ -30,6 +30,9 @@ class OrderLoaderBloc extends Bloc<OrderLoaderEvent, OrderLoaderState> {
searchChanged: (e) async { searchChanged: (e) async {
emit(state.copyWith(search: e.search)); emit(state.copyWith(search: e.search));
}, },
outletChanged: (e) async {
emit(state.copyWith(outletId: e.outletId));
},
fetched: (e) async { fetched: (e) async {
var newState = state; var newState = state;
@ -69,6 +72,7 @@ class OrderLoaderBloc extends Bloc<OrderLoaderEvent, OrderLoaderState> {
status: state.status == 'all' ? null : state.status, status: state.status == 'all' ? null : state.status,
page: state.page, page: state.page,
search: state.search, search: state.search,
outletId: state.outletId,
dateFrom: state.dateFrom, dateFrom: state.dateFrom,
dateTo: state.dateTo, dateTo: state.dateTo,
); );

View File

@ -23,6 +23,7 @@ mixin _$OrderLoaderEvent {
rangeDateChanged, rangeDateChanged,
required TResult Function(String status) statusChanged, required TResult Function(String status) statusChanged,
required TResult Function(String search) searchChanged, required TResult Function(String search) searchChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function(bool isRefresh) fetched, required TResult Function(bool isRefresh) fetched,
}) => throw _privateConstructorUsedError; }) => throw _privateConstructorUsedError;
@optionalTypeArgs @optionalTypeArgs
@ -30,6 +31,7 @@ mixin _$OrderLoaderEvent {
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String status)? statusChanged, TResult? Function(String status)? statusChanged,
TResult? Function(String search)? searchChanged, TResult? Function(String search)? searchChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function(bool isRefresh)? fetched, TResult? Function(bool isRefresh)? fetched,
}) => throw _privateConstructorUsedError; }) => throw _privateConstructorUsedError;
@optionalTypeArgs @optionalTypeArgs
@ -37,6 +39,7 @@ mixin _$OrderLoaderEvent {
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String status)? statusChanged, TResult Function(String status)? statusChanged,
TResult Function(String search)? searchChanged, TResult Function(String search)? searchChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function(bool isRefresh)? fetched, TResult Function(bool isRefresh)? fetched,
required TResult orElse(), required TResult orElse(),
}) => throw _privateConstructorUsedError; }) => throw _privateConstructorUsedError;
@ -45,6 +48,7 @@ mixin _$OrderLoaderEvent {
required TResult Function(_RangeDateChanged value) rangeDateChanged, required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_StatusChanged value) statusChanged, required TResult Function(_StatusChanged value) statusChanged,
required TResult Function(_SearchChanged value) searchChanged, required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched, required TResult Function(_Fetched value) fetched,
}) => throw _privateConstructorUsedError; }) => throw _privateConstructorUsedError;
@optionalTypeArgs @optionalTypeArgs
@ -52,6 +56,7 @@ mixin _$OrderLoaderEvent {
TResult? Function(_RangeDateChanged value)? rangeDateChanged, TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_StatusChanged value)? statusChanged, TResult? Function(_StatusChanged value)? statusChanged,
TResult? Function(_SearchChanged value)? searchChanged, TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched, TResult? Function(_Fetched value)? fetched,
}) => throw _privateConstructorUsedError; }) => throw _privateConstructorUsedError;
@optionalTypeArgs @optionalTypeArgs
@ -59,6 +64,7 @@ mixin _$OrderLoaderEvent {
TResult Function(_RangeDateChanged value)? rangeDateChanged, TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_StatusChanged value)? statusChanged, TResult Function(_StatusChanged value)? statusChanged,
TResult Function(_SearchChanged value)? searchChanged, TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched, TResult Function(_Fetched value)? fetched,
required TResult orElse(), required TResult orElse(),
}) => throw _privateConstructorUsedError; }) => throw _privateConstructorUsedError;
@ -171,6 +177,7 @@ class _$RangeDateChangedImpl implements _RangeDateChanged {
rangeDateChanged, rangeDateChanged,
required TResult Function(String status) statusChanged, required TResult Function(String status) statusChanged,
required TResult Function(String search) searchChanged, required TResult Function(String search) searchChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function(bool isRefresh) fetched, required TResult Function(bool isRefresh) fetched,
}) { }) {
return rangeDateChanged(dateFrom, dateTo); return rangeDateChanged(dateFrom, dateTo);
@ -182,6 +189,7 @@ class _$RangeDateChangedImpl implements _RangeDateChanged {
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String status)? statusChanged, TResult? Function(String status)? statusChanged,
TResult? Function(String search)? searchChanged, TResult? Function(String search)? searchChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function(bool isRefresh)? fetched, TResult? Function(bool isRefresh)? fetched,
}) { }) {
return rangeDateChanged?.call(dateFrom, dateTo); return rangeDateChanged?.call(dateFrom, dateTo);
@ -193,6 +201,7 @@ class _$RangeDateChangedImpl implements _RangeDateChanged {
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String status)? statusChanged, TResult Function(String status)? statusChanged,
TResult Function(String search)? searchChanged, TResult Function(String search)? searchChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function(bool isRefresh)? fetched, TResult Function(bool isRefresh)? fetched,
required TResult orElse(), required TResult orElse(),
}) { }) {
@ -208,6 +217,7 @@ class _$RangeDateChangedImpl implements _RangeDateChanged {
required TResult Function(_RangeDateChanged value) rangeDateChanged, required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_StatusChanged value) statusChanged, required TResult Function(_StatusChanged value) statusChanged,
required TResult Function(_SearchChanged value) searchChanged, required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched, required TResult Function(_Fetched value) fetched,
}) { }) {
return rangeDateChanged(this); return rangeDateChanged(this);
@ -219,6 +229,7 @@ class _$RangeDateChangedImpl implements _RangeDateChanged {
TResult? Function(_RangeDateChanged value)? rangeDateChanged, TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_StatusChanged value)? statusChanged, TResult? Function(_StatusChanged value)? statusChanged,
TResult? Function(_SearchChanged value)? searchChanged, TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched, TResult? Function(_Fetched value)? fetched,
}) { }) {
return rangeDateChanged?.call(this); return rangeDateChanged?.call(this);
@ -230,6 +241,7 @@ class _$RangeDateChangedImpl implements _RangeDateChanged {
TResult Function(_RangeDateChanged value)? rangeDateChanged, TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_StatusChanged value)? statusChanged, TResult Function(_StatusChanged value)? statusChanged,
TResult Function(_SearchChanged value)? searchChanged, TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched, TResult Function(_Fetched value)? fetched,
required TResult orElse(), required TResult orElse(),
}) { }) {
@ -330,6 +342,7 @@ class _$StatusChangedImpl implements _StatusChanged {
rangeDateChanged, rangeDateChanged,
required TResult Function(String status) statusChanged, required TResult Function(String status) statusChanged,
required TResult Function(String search) searchChanged, required TResult Function(String search) searchChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function(bool isRefresh) fetched, required TResult Function(bool isRefresh) fetched,
}) { }) {
return statusChanged(status); return statusChanged(status);
@ -341,6 +354,7 @@ class _$StatusChangedImpl implements _StatusChanged {
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String status)? statusChanged, TResult? Function(String status)? statusChanged,
TResult? Function(String search)? searchChanged, TResult? Function(String search)? searchChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function(bool isRefresh)? fetched, TResult? Function(bool isRefresh)? fetched,
}) { }) {
return statusChanged?.call(status); return statusChanged?.call(status);
@ -352,6 +366,7 @@ class _$StatusChangedImpl implements _StatusChanged {
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String status)? statusChanged, TResult Function(String status)? statusChanged,
TResult Function(String search)? searchChanged, TResult Function(String search)? searchChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function(bool isRefresh)? fetched, TResult Function(bool isRefresh)? fetched,
required TResult orElse(), required TResult orElse(),
}) { }) {
@ -367,6 +382,7 @@ class _$StatusChangedImpl implements _StatusChanged {
required TResult Function(_RangeDateChanged value) rangeDateChanged, required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_StatusChanged value) statusChanged, required TResult Function(_StatusChanged value) statusChanged,
required TResult Function(_SearchChanged value) searchChanged, required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched, required TResult Function(_Fetched value) fetched,
}) { }) {
return statusChanged(this); return statusChanged(this);
@ -378,6 +394,7 @@ class _$StatusChangedImpl implements _StatusChanged {
TResult? Function(_RangeDateChanged value)? rangeDateChanged, TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_StatusChanged value)? statusChanged, TResult? Function(_StatusChanged value)? statusChanged,
TResult? Function(_SearchChanged value)? searchChanged, TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched, TResult? Function(_Fetched value)? fetched,
}) { }) {
return statusChanged?.call(this); return statusChanged?.call(this);
@ -389,6 +406,7 @@ class _$StatusChangedImpl implements _StatusChanged {
TResult Function(_RangeDateChanged value)? rangeDateChanged, TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_StatusChanged value)? statusChanged, TResult Function(_StatusChanged value)? statusChanged,
TResult Function(_SearchChanged value)? searchChanged, TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched, TResult Function(_Fetched value)? fetched,
required TResult orElse(), required TResult orElse(),
}) { }) {
@ -485,6 +503,7 @@ class _$SearchChangedImpl implements _SearchChanged {
rangeDateChanged, rangeDateChanged,
required TResult Function(String status) statusChanged, required TResult Function(String status) statusChanged,
required TResult Function(String search) searchChanged, required TResult Function(String search) searchChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function(bool isRefresh) fetched, required TResult Function(bool isRefresh) fetched,
}) { }) {
return searchChanged(search); return searchChanged(search);
@ -496,6 +515,7 @@ class _$SearchChangedImpl implements _SearchChanged {
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String status)? statusChanged, TResult? Function(String status)? statusChanged,
TResult? Function(String search)? searchChanged, TResult? Function(String search)? searchChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function(bool isRefresh)? fetched, TResult? Function(bool isRefresh)? fetched,
}) { }) {
return searchChanged?.call(search); return searchChanged?.call(search);
@ -507,6 +527,7 @@ class _$SearchChangedImpl implements _SearchChanged {
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String status)? statusChanged, TResult Function(String status)? statusChanged,
TResult Function(String search)? searchChanged, TResult Function(String search)? searchChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function(bool isRefresh)? fetched, TResult Function(bool isRefresh)? fetched,
required TResult orElse(), required TResult orElse(),
}) { }) {
@ -522,6 +543,7 @@ class _$SearchChangedImpl implements _SearchChanged {
required TResult Function(_RangeDateChanged value) rangeDateChanged, required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_StatusChanged value) statusChanged, required TResult Function(_StatusChanged value) statusChanged,
required TResult Function(_SearchChanged value) searchChanged, required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched, required TResult Function(_Fetched value) fetched,
}) { }) {
return searchChanged(this); return searchChanged(this);
@ -533,6 +555,7 @@ class _$SearchChangedImpl implements _SearchChanged {
TResult? Function(_RangeDateChanged value)? rangeDateChanged, TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_StatusChanged value)? statusChanged, TResult? Function(_StatusChanged value)? statusChanged,
TResult? Function(_SearchChanged value)? searchChanged, TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched, TResult? Function(_Fetched value)? fetched,
}) { }) {
return searchChanged?.call(this); return searchChanged?.call(this);
@ -544,6 +567,7 @@ class _$SearchChangedImpl implements _SearchChanged {
TResult Function(_RangeDateChanged value)? rangeDateChanged, TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_StatusChanged value)? statusChanged, TResult Function(_StatusChanged value)? statusChanged,
TResult Function(_SearchChanged value)? searchChanged, TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched, TResult Function(_Fetched value)? fetched,
required TResult orElse(), required TResult orElse(),
}) { }) {
@ -566,6 +590,168 @@ abstract class _SearchChanged implements OrderLoaderEvent {
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
/// @nodoc
abstract class _$$OutletChangedImplCopyWith<$Res> {
factory _$$OutletChangedImplCopyWith(
_$OutletChangedImpl value,
$Res Function(_$OutletChangedImpl) then,
) = __$$OutletChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String? outletId});
}
/// @nodoc
class __$$OutletChangedImplCopyWithImpl<$Res>
extends _$OrderLoaderEventCopyWithImpl<$Res, _$OutletChangedImpl>
implements _$$OutletChangedImplCopyWith<$Res> {
__$$OutletChangedImplCopyWithImpl(
_$OutletChangedImpl _value,
$Res Function(_$OutletChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of OrderLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? outletId = freezed}) {
return _then(
_$OutletChangedImpl(
freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
),
);
}
}
/// @nodoc
class _$OutletChangedImpl implements _OutletChanged {
const _$OutletChangedImpl(this.outletId);
@override
final String? outletId;
@override
String toString() {
return 'OrderLoaderEvent.outletChanged(outletId: $outletId)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$OutletChangedImpl &&
(identical(other.outletId, outletId) ||
other.outletId == outletId));
}
@override
int get hashCode => Object.hash(runtimeType, outletId);
/// Create a copy of OrderLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$OutletChangedImplCopyWith<_$OutletChangedImpl> get copyWith =>
__$$OutletChangedImplCopyWithImpl<_$OutletChangedImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(DateTime dateFrom, DateTime dateTo)
rangeDateChanged,
required TResult Function(String status) statusChanged,
required TResult Function(String search) searchChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function(bool isRefresh) fetched,
}) {
return outletChanged(outletId);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String status)? statusChanged,
TResult? Function(String search)? searchChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function(bool isRefresh)? fetched,
}) {
return outletChanged?.call(outletId);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String status)? statusChanged,
TResult Function(String search)? searchChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function(bool isRefresh)? fetched,
required TResult orElse(),
}) {
if (outletChanged != null) {
return outletChanged(outletId);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_StatusChanged value) statusChanged,
required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched,
}) {
return outletChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_StatusChanged value)? statusChanged,
TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched,
}) {
return outletChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_StatusChanged value)? statusChanged,
TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
if (outletChanged != null) {
return outletChanged(this);
}
return orElse();
}
}
abstract class _OutletChanged implements OrderLoaderEvent {
const factory _OutletChanged(final String? outletId) = _$OutletChangedImpl;
String? get outletId;
/// Create a copy of OrderLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$OutletChangedImplCopyWith<_$OutletChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc /// @nodoc
abstract class _$$FetchedImplCopyWith<$Res> { abstract class _$$FetchedImplCopyWith<$Res> {
factory _$$FetchedImplCopyWith( factory _$$FetchedImplCopyWith(
@ -642,6 +828,7 @@ class _$FetchedImpl implements _Fetched {
rangeDateChanged, rangeDateChanged,
required TResult Function(String status) statusChanged, required TResult Function(String status) statusChanged,
required TResult Function(String search) searchChanged, required TResult Function(String search) searchChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function(bool isRefresh) fetched, required TResult Function(bool isRefresh) fetched,
}) { }) {
return fetched(isRefresh); return fetched(isRefresh);
@ -653,6 +840,7 @@ class _$FetchedImpl implements _Fetched {
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String status)? statusChanged, TResult? Function(String status)? statusChanged,
TResult? Function(String search)? searchChanged, TResult? Function(String search)? searchChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function(bool isRefresh)? fetched, TResult? Function(bool isRefresh)? fetched,
}) { }) {
return fetched?.call(isRefresh); return fetched?.call(isRefresh);
@ -664,6 +852,7 @@ class _$FetchedImpl implements _Fetched {
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged, TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String status)? statusChanged, TResult Function(String status)? statusChanged,
TResult Function(String search)? searchChanged, TResult Function(String search)? searchChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function(bool isRefresh)? fetched, TResult Function(bool isRefresh)? fetched,
required TResult orElse(), required TResult orElse(),
}) { }) {
@ -679,6 +868,7 @@ class _$FetchedImpl implements _Fetched {
required TResult Function(_RangeDateChanged value) rangeDateChanged, required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_StatusChanged value) statusChanged, required TResult Function(_StatusChanged value) statusChanged,
required TResult Function(_SearchChanged value) searchChanged, required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched, required TResult Function(_Fetched value) fetched,
}) { }) {
return fetched(this); return fetched(this);
@ -690,6 +880,7 @@ class _$FetchedImpl implements _Fetched {
TResult? Function(_RangeDateChanged value)? rangeDateChanged, TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_StatusChanged value)? statusChanged, TResult? Function(_StatusChanged value)? statusChanged,
TResult? Function(_SearchChanged value)? searchChanged, TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched, TResult? Function(_Fetched value)? fetched,
}) { }) {
return fetched?.call(this); return fetched?.call(this);
@ -701,6 +892,7 @@ class _$FetchedImpl implements _Fetched {
TResult Function(_RangeDateChanged value)? rangeDateChanged, TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_StatusChanged value)? statusChanged, TResult Function(_StatusChanged value)? statusChanged,
TResult Function(_SearchChanged value)? searchChanged, TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched, TResult Function(_Fetched value)? fetched,
required TResult orElse(), required TResult orElse(),
}) { }) {
@ -730,6 +922,7 @@ mixin _$OrderLoaderState {
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
String get status => throw _privateConstructorUsedError; String get status => throw _privateConstructorUsedError;
String? get search => throw _privateConstructorUsedError; String? get search => throw _privateConstructorUsedError;
String? get outletId => throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError; bool get isFetching => throw _privateConstructorUsedError;
bool get hasReachedMax => throw _privateConstructorUsedError; bool get hasReachedMax => throw _privateConstructorUsedError;
int get page => throw _privateConstructorUsedError; int get page => throw _privateConstructorUsedError;
@ -755,6 +948,7 @@ abstract class $OrderLoaderStateCopyWith<$Res> {
Option<OrderFailure> failureOptionOrder, Option<OrderFailure> failureOptionOrder,
String status, String status,
String? search, String? search,
String? outletId,
bool isFetching, bool isFetching,
bool hasReachedMax, bool hasReachedMax,
int page, int page,
@ -782,6 +976,7 @@ class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState>
Object? failureOptionOrder = null, Object? failureOptionOrder = null,
Object? status = null, Object? status = null,
Object? search = freezed, Object? search = freezed,
Object? outletId = freezed,
Object? isFetching = null, Object? isFetching = null,
Object? hasReachedMax = null, Object? hasReachedMax = null,
Object? page = null, Object? page = null,
@ -806,6 +1001,10 @@ class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState>
? _value.search ? _value.search
: search // ignore: cast_nullable_to_non_nullable : search // ignore: cast_nullable_to_non_nullable
as String?, as String?,
outletId: freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
isFetching: null == isFetching isFetching: null == isFetching
? _value.isFetching ? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable : isFetching // ignore: cast_nullable_to_non_nullable
@ -846,6 +1045,7 @@ abstract class _$$OrderLoaderStateImplCopyWith<$Res>
Option<OrderFailure> failureOptionOrder, Option<OrderFailure> failureOptionOrder,
String status, String status,
String? search, String? search,
String? outletId,
bool isFetching, bool isFetching,
bool hasReachedMax, bool hasReachedMax,
int page, int page,
@ -872,6 +1072,7 @@ class __$$OrderLoaderStateImplCopyWithImpl<$Res>
Object? failureOptionOrder = null, Object? failureOptionOrder = null,
Object? status = null, Object? status = null,
Object? search = freezed, Object? search = freezed,
Object? outletId = freezed,
Object? isFetching = null, Object? isFetching = null,
Object? hasReachedMax = null, Object? hasReachedMax = null,
Object? page = null, Object? page = null,
@ -896,6 +1097,10 @@ class __$$OrderLoaderStateImplCopyWithImpl<$Res>
? _value.search ? _value.search
: search // ignore: cast_nullable_to_non_nullable : search // ignore: cast_nullable_to_non_nullable
as String?, as String?,
outletId: freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
isFetching: null == isFetching isFetching: null == isFetching
? _value.isFetching ? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable : isFetching // ignore: cast_nullable_to_non_nullable
@ -929,6 +1134,7 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
required this.failureOptionOrder, required this.failureOptionOrder,
required this.status, required this.status,
this.search, this.search,
this.outletId,
this.isFetching = false, this.isFetching = false,
this.hasReachedMax = false, this.hasReachedMax = false,
this.page = 1, this.page = 1,
@ -951,6 +1157,8 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
@override @override
final String? search; final String? search;
@override @override
final String? outletId;
@override
@JsonKey() @JsonKey()
final bool isFetching; final bool isFetching;
@override @override
@ -966,7 +1174,7 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
@override @override
String toString() { String toString() {
return 'OrderLoaderState(orders: $orders, failureOptionOrder: $failureOptionOrder, status: $status, search: $search, isFetching: $isFetching, hasReachedMax: $hasReachedMax, page: $page, dateFrom: $dateFrom, dateTo: $dateTo)'; return 'OrderLoaderState(orders: $orders, failureOptionOrder: $failureOptionOrder, status: $status, search: $search, outletId: $outletId, isFetching: $isFetching, hasReachedMax: $hasReachedMax, page: $page, dateFrom: $dateFrom, dateTo: $dateTo)';
} }
@override @override
@ -979,6 +1187,8 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
other.failureOptionOrder == failureOptionOrder) && other.failureOptionOrder == failureOptionOrder) &&
(identical(other.status, status) || other.status == status) && (identical(other.status, status) || other.status == status) &&
(identical(other.search, search) || other.search == search) && (identical(other.search, search) || other.search == search) &&
(identical(other.outletId, outletId) ||
other.outletId == outletId) &&
(identical(other.isFetching, isFetching) || (identical(other.isFetching, isFetching) ||
other.isFetching == isFetching) && other.isFetching == isFetching) &&
(identical(other.hasReachedMax, hasReachedMax) || (identical(other.hasReachedMax, hasReachedMax) ||
@ -996,6 +1206,7 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
failureOptionOrder, failureOptionOrder,
status, status,
search, search,
outletId,
isFetching, isFetching,
hasReachedMax, hasReachedMax,
page, page,
@ -1021,6 +1232,7 @@ abstract class _OrderLoaderState implements OrderLoaderState {
required final Option<OrderFailure> failureOptionOrder, required final Option<OrderFailure> failureOptionOrder,
required final String status, required final String status,
final String? search, final String? search,
final String? outletId,
final bool isFetching, final bool isFetching,
final bool hasReachedMax, final bool hasReachedMax,
final int page, final int page,
@ -1037,6 +1249,8 @@ abstract class _OrderLoaderState implements OrderLoaderState {
@override @override
String? get search; String? get search;
@override @override
String? get outletId;
@override
bool get isFetching; bool get isFetching;
@override @override
bool get hasReachedMax; bool get hasReachedMax;

View File

@ -8,6 +8,8 @@ class OrderLoaderEvent with _$OrderLoaderEvent {
) = _RangeDateChanged; ) = _RangeDateChanged;
const factory OrderLoaderEvent.statusChanged(String status) = _StatusChanged; const factory OrderLoaderEvent.statusChanged(String status) = _StatusChanged;
const factory OrderLoaderEvent.searchChanged(String search) = _SearchChanged; const factory OrderLoaderEvent.searchChanged(String search) = _SearchChanged;
const factory OrderLoaderEvent.outletChanged(String? outletId) =
_OutletChanged;
const factory OrderLoaderEvent.fetched({@Default(false) bool isRefresh}) = const factory OrderLoaderEvent.fetched({@Default(false) bool isRefresh}) =
_Fetched; _Fetched;
} }

View File

@ -7,6 +7,7 @@ class OrderLoaderState with _$OrderLoaderState {
required Option<OrderFailure> failureOptionOrder, required Option<OrderFailure> failureOptionOrder,
required String status, required String status,
String? search, String? search,
String? outletId,
@Default(false) bool isFetching, @Default(false) bool isFetching,
@Default(false) bool hasReachedMax, @Default(false) bool hasReachedMax,
@Default(1) int page, @Default(1) int page,
@ -17,7 +18,7 @@ class OrderLoaderState with _$OrderLoaderState {
factory OrderLoaderState.initial() => OrderLoaderState( factory OrderLoaderState.initial() => OrderLoaderState(
orders: [], orders: [],
failureOptionOrder: none(), failureOptionOrder: none(),
dateFrom: DateTime.now().subtract(const Duration(days: 30)), dateFrom: DateTime.now(),
dateTo: DateTime.now(), dateTo: DateTime.now(),
status: 'all', status: 'all',
); );

View File

@ -134,9 +134,9 @@ extension GetItInjectableX on _i174.GetIt {
final gh = _i526.GetItHelper(this, environment, environmentFilter); final gh = _i526.GetItHelper(this, environment, environmentFilter);
final firebaseDi = _$FirebaseDi(); final firebaseDi = _$FirebaseDi();
final sharedPreferencesDi = _$SharedPreferencesDi(); final sharedPreferencesDi = _$SharedPreferencesDi();
final dioDi = _$DioDi();
final autoRouteDi = _$AutoRouteDi(); final autoRouteDi = _$AutoRouteDi();
final connectivityDi = _$ConnectivityDi(); final connectivityDi = _$ConnectivityDi();
final dioDi = _$DioDi();
final packageInfoDi = _$PackageInfoDi(); final packageInfoDi = _$PackageInfoDi();
await gh.factoryAsync<_i982.FirebaseApp>( await gh.factoryAsync<_i982.FirebaseApp>(
() => firebaseDi.firebaseApp, () => firebaseDi.firebaseApp,
@ -146,9 +146,9 @@ extension GetItInjectableX on _i174.GetIt {
() => sharedPreferencesDi.prefs, () => sharedPreferencesDi.prefs,
preResolve: true, preResolve: true,
); );
gh.lazySingleton<_i361.Dio>(() => dioDi.dio);
gh.lazySingleton<_i258.AppRouter>(() => autoRouteDi.appRouter); gh.lazySingleton<_i258.AppRouter>(() => autoRouteDi.appRouter);
gh.lazySingleton<_i895.Connectivity>(() => connectivityDi.connectivity); gh.lazySingleton<_i895.Connectivity>(() => connectivityDi.connectivity);
gh.lazySingleton<_i361.Dio>(() => dioDi.dio);
await gh.lazySingletonAsync<_i655.PackageInfo>( await gh.lazySingletonAsync<_i655.PackageInfo>(
() => packageInfoDi.packageInfo, () => packageInfoDi.packageInfo,
preResolve: true, preResolve: true,
@ -172,29 +172,29 @@ extension GetItInjectableX on _i174.GetIt {
() => _i115.ApiClient(gh<_i361.Dio>(), gh<_i6.Env>()), () => _i115.ApiClient(gh<_i361.Dio>(), gh<_i6.Env>()),
); );
gh.factory<_i6.Env>(() => _i6.ProdEnv(), registerFor: {_prod}); gh.factory<_i6.Env>(() => _i6.ProdEnv(), registerFor: {_prod});
gh.factory<_i130.OrderRemoteDataProvider>( gh.factory<_i866.AnalyticRemoteDataProvider>(
() => _i130.OrderRemoteDataProvider(gh<_i115.ApiClient>()), () => _i866.AnalyticRemoteDataProvider(gh<_i115.ApiClient>()),
);
gh.factory<_i333.CategoryRemoteDataProvider>(
() => _i333.CategoryRemoteDataProvider(gh<_i115.ApiClient>()),
); );
gh.factory<_i17.AuthRemoteDataProvider>( gh.factory<_i17.AuthRemoteDataProvider>(
() => _i17.AuthRemoteDataProvider(gh<_i115.ApiClient>()), () => _i17.AuthRemoteDataProvider(gh<_i115.ApiClient>()),
); );
gh.factory<_i785.UserRemoteDataProvider>( gh.factory<_i333.CategoryRemoteDataProvider>(
() => _i785.UserRemoteDataProvider(gh<_i115.ApiClient>()), () => _i333.CategoryRemoteDataProvider(gh<_i115.ApiClient>()),
); );
gh.factory<_i823.ProductRemoteDataProvider>( gh.factory<_i1006.CustomerRemoteDataProvider>(
() => _i823.ProductRemoteDataProvider(gh<_i115.ApiClient>()), () => _i1006.CustomerRemoteDataProvider(gh<_i115.ApiClient>()),
);
gh.factory<_i130.OrderRemoteDataProvider>(
() => _i130.OrderRemoteDataProvider(gh<_i115.ApiClient>()),
); );
gh.factory<_i27.OutletRemoteDataProvider>( gh.factory<_i27.OutletRemoteDataProvider>(
() => _i27.OutletRemoteDataProvider(gh<_i115.ApiClient>()), () => _i27.OutletRemoteDataProvider(gh<_i115.ApiClient>()),
); );
gh.factory<_i866.AnalyticRemoteDataProvider>( gh.factory<_i823.ProductRemoteDataProvider>(
() => _i866.AnalyticRemoteDataProvider(gh<_i115.ApiClient>()), () => _i823.ProductRemoteDataProvider(gh<_i115.ApiClient>()),
); );
gh.factory<_i1006.CustomerRemoteDataProvider>( gh.factory<_i785.UserRemoteDataProvider>(
() => _i1006.CustomerRemoteDataProvider(gh<_i115.ApiClient>()), () => _i785.UserRemoteDataProvider(gh<_i115.ApiClient>()),
); );
gh.factory<_i48.ICustomerRepository>( gh.factory<_i48.ICustomerRepository>(
() => _i550.CustomerRepository(gh<_i1006.CustomerRemoteDataProvider>()), () => _i550.CustomerRepository(gh<_i1006.CustomerRemoteDataProvider>()),
@ -248,20 +248,23 @@ extension GetItInjectableX on _i174.GetIt {
gh<_i850.OutletLocalDataProvider>(), gh<_i850.OutletLocalDataProvider>(),
), ),
); );
gh.factory<_i473.HomeBloc>(
() => _i473.HomeBloc(gh<_i477.IAnalyticRepository>()),
);
gh.factory<_i889.SalesLoaderBloc>( gh.factory<_i889.SalesLoaderBloc>(
() => _i889.SalesLoaderBloc(gh<_i477.IAnalyticRepository>()), () => _i889.SalesLoaderBloc(gh<_i477.IAnalyticRepository>()),
); );
gh.factory<_i473.HomeBloc>(
() => _i473.HomeBloc(gh<_i477.IAnalyticRepository>()),
);
gh.factory<_i877.OutletListLoaderBloc>( gh.factory<_i877.OutletListLoaderBloc>(
() => _i877.OutletListLoaderBloc(gh<_i197.IOutletRepository>()), () => _i877.OutletListLoaderBloc(gh<_i197.IOutletRepository>()),
); );
gh.factory<_i337.CurrentOutletLoaderBloc>( gh.factory<_i337.CurrentOutletLoaderBloc>(
() => _i337.CurrentOutletLoaderBloc(gh<_i197.IOutletRepository>()), () => _i337.CurrentOutletLoaderBloc(gh<_i197.IOutletRepository>()),
); );
gh.factory<_i221.ProductAnalyticLoaderBloc>( gh.factory<_i1038.CategoryAnalyticLoaderBloc>(
() => _i221.ProductAnalyticLoaderBloc(gh<_i477.IAnalyticRepository>()), () => _i1038.CategoryAnalyticLoaderBloc(gh<_i477.IAnalyticRepository>()),
);
gh.factory<_i516.DashboardAnalyticLoaderBloc>(
() => _i516.DashboardAnalyticLoaderBloc(gh<_i477.IAnalyticRepository>()),
); );
gh.factory<_i785.InventoryAnalyticLoaderBloc>( gh.factory<_i785.InventoryAnalyticLoaderBloc>(
() => _i785.InventoryAnalyticLoaderBloc(gh<_i477.IAnalyticRepository>()), () => _i785.InventoryAnalyticLoaderBloc(gh<_i477.IAnalyticRepository>()),
@ -271,15 +274,12 @@ extension GetItInjectableX on _i174.GetIt {
gh<_i477.IAnalyticRepository>(), gh<_i477.IAnalyticRepository>(),
), ),
); );
gh.factory<_i1038.CategoryAnalyticLoaderBloc>( gh.factory<_i221.ProductAnalyticLoaderBloc>(
() => _i1038.CategoryAnalyticLoaderBloc(gh<_i477.IAnalyticRepository>()), () => _i221.ProductAnalyticLoaderBloc(gh<_i477.IAnalyticRepository>()),
); );
gh.factory<_i11.ProfitLossLoaderBloc>( gh.factory<_i11.ProfitLossLoaderBloc>(
() => _i11.ProfitLossLoaderBloc(gh<_i477.IAnalyticRepository>()), () => _i11.ProfitLossLoaderBloc(gh<_i477.IAnalyticRepository>()),
); );
gh.factory<_i516.DashboardAnalyticLoaderBloc>(
() => _i516.DashboardAnalyticLoaderBloc(gh<_i477.IAnalyticRepository>()),
);
gh.factory<_i945.AuthBloc>( gh.factory<_i945.AuthBloc>(
() => _i945.AuthBloc(gh<_i49.IAuthRepository>()), () => _i945.AuthBloc(gh<_i49.IAuthRepository>()),
); );
@ -289,12 +289,12 @@ extension GetItInjectableX on _i174.GetIt {
gh.factory<_i1058.OrderLoaderBloc>( gh.factory<_i1058.OrderLoaderBloc>(
() => _i1058.OrderLoaderBloc(gh<_i219.IOrderRepository>()), () => _i1058.OrderLoaderBloc(gh<_i219.IOrderRepository>()),
); );
gh.factory<_i147.UserEditFormBloc>(
() => _i147.UserEditFormBloc(gh<_i635.IUserRepository>()),
);
gh.factory<_i1030.ChangePasswordFormBloc>( gh.factory<_i1030.ChangePasswordFormBloc>(
() => _i1030.ChangePasswordFormBloc(gh<_i635.IUserRepository>()), () => _i1030.ChangePasswordFormBloc(gh<_i635.IUserRepository>()),
); );
gh.factory<_i147.UserEditFormBloc>(
() => _i147.UserEditFormBloc(gh<_i635.IUserRepository>()),
);
gh.factory<_i775.LoginFormBloc>( gh.factory<_i775.LoginFormBloc>(
() => _i775.LoginFormBloc( () => _i775.LoginFormBloc(
gh<_i49.IAuthRepository>(), gh<_i49.IAuthRepository>(),
@ -302,14 +302,14 @@ extension GetItInjectableX on _i174.GetIt {
gh<_i179.FcmService>(), gh<_i179.FcmService>(),
), ),
); );
gh.factory<_i605.TransactionReportBloc>( gh.factory<_i346.InventoryReportBloc>(
() => _i605.TransactionReportBloc( () => _i346.InventoryReportBloc(
gh<_i477.IAnalyticRepository>(), gh<_i477.IAnalyticRepository>(),
gh<_i197.IOutletRepository>(), gh<_i197.IOutletRepository>(),
), ),
); );
gh.factory<_i346.InventoryReportBloc>( gh.factory<_i605.TransactionReportBloc>(
() => _i346.InventoryReportBloc( () => _i605.TransactionReportBloc(
gh<_i477.IAnalyticRepository>(), gh<_i477.IAnalyticRepository>(),
gh<_i197.IOutletRepository>(), gh<_i197.IOutletRepository>(),
), ),
@ -322,10 +322,10 @@ class _$FirebaseDi extends _i73.FirebaseDi {}
class _$SharedPreferencesDi extends _i402.SharedPreferencesDi {} class _$SharedPreferencesDi extends _i402.SharedPreferencesDi {}
class _$DioDi extends _i103.DioDi {}
class _$AutoRouteDi extends _i311.AutoRouteDi {} class _$AutoRouteDi extends _i311.AutoRouteDi {}
class _$ConnectivityDi extends _i586.ConnectivityDi {} class _$ConnectivityDi extends _i586.ConnectivityDi {}
class _$DioDi extends _i103.DioDi {}
class _$PackageInfoDi extends _i227.PackageInfoDi {} class _$PackageInfoDi extends _i227.PackageInfoDi {}

View File

@ -91,6 +91,8 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
child: Scaffold( child: Scaffold(
backgroundColor: AppColor.background, backgroundColor: AppColor.background,
body: RefreshIndicator( body: RefreshIndicator(
backgroundColor: AppColor.white,
color: AppColor.primary,
onRefresh: () { onRefresh: () {
_refetchDashboard(context); _refetchDashboard(context);
return Future.value(); return Future.value();

View File

@ -6,6 +6,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:shimmer/shimmer.dart'; import 'package:shimmer/shimmer.dart';
import '../../../../application/order/order_loader/order_loader_bloc.dart'; import '../../../../application/order/order_loader/order_loader_bloc.dart';
import '../../../../application/outlet/outlet_list_loader/outlet_list_loader_bloc.dart';
import '../../../../common/extension/extension.dart'; import '../../../../common/extension/extension.dart';
import '../../../../common/theme/theme.dart'; import '../../../../common/theme/theme.dart';
import '../../../../injection.dart'; import '../../../../injection.dart';
@ -23,10 +24,19 @@ class OrderPage extends StatefulWidget implements AutoRouteWrapper {
State<OrderPage> createState() => _OrderPageState(); State<OrderPage> createState() => _OrderPageState();
@override @override
Widget wrappedRoute(BuildContext context) => BlocProvider( Widget wrappedRoute(BuildContext context) => MultiBlocProvider(
create: (_) => providers: [
getIt<OrderLoaderBloc>() BlocProvider(
..add(OrderLoaderEvent.fetched(isRefresh: true)), create: (_) =>
getIt<OrderLoaderBloc>()
..add(OrderLoaderEvent.fetched(isRefresh: true)),
),
BlocProvider(
create: (_) =>
getIt<OutletListLoaderBloc>()
..add(const OutletListLoaderEvent.fetched()),
),
],
child: this, child: this,
); );
} }
@ -179,6 +189,14 @@ class _OrderPageState extends State<OrderPage> with TickerProviderStateMixin {
backgroundColor: AppColor.background, backgroundColor: AppColor.background,
body: MultiBlocListener( body: MultiBlocListener(
listeners: [ listeners: [
BlocListener<OrderLoaderBloc, OrderLoaderState>(
listenWhen: (p, c) => p.outletId != c.outletId,
listener: (context, state) {
context.read<OrderLoaderBloc>().add(
OrderLoaderEvent.fetched(isRefresh: true),
);
},
),
BlocListener<OrderLoaderBloc, OrderLoaderState>( BlocListener<OrderLoaderBloc, OrderLoaderState>(
listenWhen: (p, c) => p.status != c.status, listenWhen: (p, c) => p.status != c.status,
listener: (context, state) { listener: (context, state) {
@ -198,137 +216,151 @@ class _OrderPageState extends State<OrderPage> with TickerProviderStateMixin {
}, },
), ),
], ],
child: BlocBuilder<OrderLoaderBloc, OrderLoaderState>( child: BlocBuilder<OutletListLoaderBloc, OutletListLoaderState>(
builder: (context, state) { builder: (context, outletListState) {
return NotificationListener<ScrollNotification>( return BlocBuilder<OrderLoaderBloc, OrderLoaderState>(
onNotification: (notification) { builder: (context, state) {
if (notification is ScrollEndNotification && return NotificationListener<ScrollNotification>(
_scrollController.position.extentAfter == 0) { onNotification: (notification) {
context.read<OrderLoaderBloc>().add( if (notification is ScrollEndNotification &&
OrderLoaderEvent.fetched(), _scrollController.position.extentAfter == 0) {
); context.read<OrderLoaderBloc>().add(
return true; OrderLoaderEvent.fetched(),
} );
return true;
}
return true; return true;
}, },
child: CustomScrollView( child: CustomScrollView(
controller: _scrollController, controller: _scrollController,
slivers: [ slivers: [
// Custom App Bar with Hero Effect // Custom App Bar with Hero Effect
SliverAppBar( SliverAppBar(
expandedHeight: 120, expandedHeight: 120,
floating: true, floating: true,
pinned: true, pinned: true,
backgroundColor: AppColor.primary, backgroundColor: AppColor.primary,
centerTitle: false, centerTitle: false,
flexibleSpace: CustomAppBar( flexibleSpace: CustomAppBar(
title: context.lang.orders, title: context.lang.orders,
isBack: false, isBack: false,
),
),
// Pinned Filter Section
SliverPersistentHeader(
pinned: true,
delegate: FilterHeaderDelegate(
backgroundColor: AppColor.background,
padding: EdgeInsets.fromLTRB(
AppValue.padding,
10,
AppValue.padding,
10,
),
startDate: state.dateFrom,
endDate: state.dateTo,
filterOptions: filterOptions,
selectedFilter: state.status,
onDateChanged: (startDate, endDate) {
if (startDate != null && endDate != null) {
log('Date changed');
context.read<OrderLoaderBloc>().add(
OrderLoaderEvent.rangeDateChanged(
startDate,
endDate,
),
);
}
},
onFilterChanged: (filter) {
final status = filter.toLowerCase();
context.read<OrderLoaderBloc>().add(
OrderLoaderEvent.statusChanged(status),
);
},
),
),
// Content
SliverPadding(
padding: EdgeInsets.all(AppValue.padding),
sliver: SliverList(
delegate: SliverChildListDelegate([
FadeTransition(
opacity: _fadeAnimation,
child: SlideTransition(
position: _slideAnimation,
child: Column(
children: [
// Show filtered transaction count
if (state.status != 'all' && !state.isFetching)
Padding(
padding: const EdgeInsets.only(bottom: 16),
child: Row(
children: [
Text(
'${state.orders.length} ${state.status.toLowerCase()} ${context.lang.orders}',
style: TextStyle(
color: AppColor.textSecondary,
fontSize: 14,
),
),
],
),
),
// Order List with Shimmer Loading
if (state.isFetching)
_buildShimmerList()
else if (state.orders.isEmpty)
EmptyWidget(
title: context.lang.order,
message: context.lang.no_order_with_status(
state.status.toLowerCase(),
),
)
else
ListView.builder(
itemCount: state.orders.length,
shrinkWrap: true,
physics:
const NeverScrollableScrollPhysics(),
padding: EdgeInsets.zero,
itemBuilder: (context, index) {
return OrderTile(
onTap: () => context.router.push(
OrderDetailRoute(
order: state.orders[index],
),
),
order: state.orders[index],
);
},
),
],
),
),
), ),
]), ),
),
// Pinned Filter Section
SliverPersistentHeader(
pinned: true,
delegate: FilterHeaderDelegate(
backgroundColor: AppColor.background,
padding: EdgeInsets.fromLTRB(
AppValue.padding,
10,
AppValue.padding,
10,
),
startDate: state.dateFrom,
endDate: state.dateTo,
filterOptions: filterOptions,
selectedFilter: state.status,
selectedOutletId: state.outletId,
outletListState: outletListState,
onDateChanged: (startDate, endDate) {
if (startDate != null && endDate != null) {
log('Date changed');
context.read<OrderLoaderBloc>().add(
OrderLoaderEvent.rangeDateChanged(
startDate,
endDate,
),
);
}
},
onFilterChanged: (filter) {
final status = filter.toLowerCase();
context.read<OrderLoaderBloc>().add(
OrderLoaderEvent.statusChanged(status),
);
},
onOutletChanged: (outletId) {
context.read<OrderLoaderBloc>().add(
OrderLoaderEvent.outletChanged(outletId),
);
},
),
),
// Content
SliverPadding(
padding: EdgeInsets.all(AppValue.padding),
sliver: SliverList(
delegate: SliverChildListDelegate([
FadeTransition(
opacity: _fadeAnimation,
child: SlideTransition(
position: _slideAnimation,
child: Column(
children: [
// Show filtered transaction count
if (state.status != 'all' &&
!state.isFetching)
Padding(
padding: const EdgeInsets.only(
bottom: 16,
),
child: Row(
children: [
Text(
'${state.orders.length} ${state.status.toLowerCase()} ${context.lang.orders}',
style: TextStyle(
color: AppColor.textSecondary,
fontSize: 14,
),
),
],
),
),
// Order List with Shimmer Loading
if (state.isFetching)
_buildShimmerList()
else if (state.orders.isEmpty)
EmptyWidget(
title: context.lang.order,
message:
context.lang.no_order_with_status(
state.status.toLowerCase(),
),
)
else
ListView.builder(
itemCount: state.orders.length,
shrinkWrap: true,
physics:
const NeverScrollableScrollPhysics(),
padding: EdgeInsets.zero,
itemBuilder: (context, index) {
return OrderTile(
onTap: () => context.router.push(
OrderDetailRoute(
order: state.orders[index],
),
),
order: state.orders[index],
);
},
),
],
),
),
),
]),
),
),
],
), ),
], );
), },
); );
}, },
), ),

View File

@ -1,6 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../../application/outlet/outlet_list_loader/outlet_list_loader_bloc.dart';
import '../../../../../common/extension/extension.dart'; import '../../../../../common/extension/extension.dart';
import '../../../../../common/theme/theme.dart';
import '../../../../../domain/outlet/outlet.dart';
import '../../../../components/field/date_range_picker_field.dart'; import '../../../../components/field/date_range_picker_field.dart';
import 'status_tile.dart'; import 'status_tile.dart';
@ -11,8 +14,11 @@ class FilterHeaderDelegate extends SliverPersistentHeaderDelegate {
final DateTime? endDate; final DateTime? endDate;
final List<String> filterOptions; final List<String> filterOptions;
final String selectedFilter; final String selectedFilter;
final String? selectedOutletId;
final OutletListLoaderState outletListState;
final Function(DateTime?, DateTime?) onDateChanged; final Function(DateTime?, DateTime?) onDateChanged;
final Function(String) onFilterChanged; final Function(String) onFilterChanged;
final Function(String?) onOutletChanged;
FilterHeaderDelegate({ FilterHeaderDelegate({
required this.backgroundColor, required this.backgroundColor,
@ -21,15 +27,18 @@ class FilterHeaderDelegate extends SliverPersistentHeaderDelegate {
required this.endDate, required this.endDate,
required this.filterOptions, required this.filterOptions,
required this.selectedFilter, required this.selectedFilter,
required this.selectedOutletId,
required this.outletListState,
required this.onDateChanged, required this.onDateChanged,
required this.onFilterChanged, required this.onFilterChanged,
required this.onOutletChanged,
}); });
@override @override
double get minExtent => 130; double get minExtent => 190;
@override @override
double get maxExtent => 130; double get maxExtent => 190;
@override @override
Widget build( Widget build(
@ -37,51 +46,55 @@ class FilterHeaderDelegate extends SliverPersistentHeaderDelegate {
double shrinkOffset, double shrinkOffset,
bool overlapsContent, bool overlapsContent,
) { ) {
final selectedOutlet = outletListState.outlets
.where((o) => o.id == selectedOutletId)
.firstOrNull;
return Container( return Container(
color: backgroundColor, color: backgroundColor,
padding: padding, padding: padding,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Padding( // Date range picker
padding: const EdgeInsets.only(bottom: 8.0), DateRangePickerField(
child: DateRangePickerField( maxDate: DateTime.now(),
maxDate: DateTime.now(), startDate: startDate,
startDate: startDate, endDate: endDate,
endDate: endDate, onChanged: (start, end) => onDateChanged(start, end),
onChanged: (start, end) {
onDateChanged(start, end);
},
),
), ),
Expanded( const SizedBox(height: 8),
child: SingleChildScrollView( // Outlet selector + status chips
scrollDirection: Axis.horizontal, _OutletSelectorField(
child: Row( selectedOutlet: selectedOutlet,
children: filterOptions.asMap().entries.map((entry) { isLoading: outletListState.isFetching,
final index = entry.key; onTap: () => _showOutletSheet(context),
final option = entry.value; ),
const SizedBox(height: 8),
return Padding( // Status chips
padding: EdgeInsets.only( SingleChildScrollView(
right: index < filterOptions.length - 1 ? 8 : 0, scrollDirection: Axis.horizontal,
), child: Row(
child: OrderStatusTile( children: filterOptions.asMap().entries.map((entry) {
label: option == "All" final index = entry.key;
? context.lang.all final option = entry.value;
: option == "Completed" return Padding(
? context.lang.completed padding: EdgeInsets.only(
: context.lang.pending, right: index < filterOptions.length - 1 ? 8 : 0,
isSelected: option == selectedFilter, ),
onSelected: (isSelected) { child: OrderStatusTile(
if (isSelected) { label: option == 'All'
onFilterChanged(option); ? context.lang.all
} : option == 'Completed'
}, ? context.lang.completed
), : context.lang.pending,
); isSelected: option.toLowerCase() == selectedFilter,
}).toList(), onSelected: (isSelected) {
), if (isSelected) onFilterChanged(option);
},
),
);
}).toList(),
), ),
), ),
], ],
@ -89,12 +102,258 @@ class FilterHeaderDelegate extends SliverPersistentHeaderDelegate {
); );
} }
void _showOutletSheet(BuildContext context) {
showModalBottomSheet(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
builder: (_) => _OutletBottomSheet(
outlets: outletListState.outlets,
selectedOutletId: selectedOutletId,
onSelected: (outletId) {
Navigator.pop(context);
onOutletChanged(outletId);
},
),
);
}
@override @override
bool shouldRebuild(covariant FilterHeaderDelegate oldDelegate) { bool shouldRebuild(covariant FilterHeaderDelegate oldDelegate) {
return oldDelegate.startDate != startDate || return oldDelegate.startDate != startDate ||
oldDelegate.endDate != endDate || oldDelegate.endDate != endDate ||
oldDelegate.selectedFilter != selectedFilter || oldDelegate.selectedFilter != selectedFilter ||
oldDelegate.selectedOutletId != selectedOutletId ||
oldDelegate.outletListState.outlets.length !=
outletListState.outlets.length ||
oldDelegate.outletListState.isFetching != outletListState.isFetching ||
oldDelegate.filterOptions.length != filterOptions.length || oldDelegate.filterOptions.length != filterOptions.length ||
oldDelegate.backgroundColor != backgroundColor; oldDelegate.backgroundColor != backgroundColor;
} }
} }
// Field outlet — ikut style DateRangePickerField
class _OutletSelectorField extends StatefulWidget {
final Outlet? selectedOutlet;
final bool isLoading;
final VoidCallback onTap;
const _OutletSelectorField({
required this.selectedOutlet,
required this.isLoading,
required this.onTap,
});
@override
State<_OutletSelectorField> createState() => _OutletSelectorFieldState();
}
class _OutletSelectorFieldState extends State<_OutletSelectorField> {
bool _isPressed = false;
@override
Widget build(BuildContext context) {
final hasValue = widget.selectedOutlet != null;
final label = widget.selectedOutlet?.name ?? 'Semua Outlet';
return GestureDetector(
onTap: widget.isLoading ? null : widget.onTap,
onTapDown: (_) => setState(() => _isPressed = true),
onTapUp: (_) => setState(() => _isPressed = false),
onTapCancel: () => setState(() => _isPressed = false),
child: AnimatedContainer(
duration: const Duration(milliseconds: 150),
height: 52,
padding: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: _isPressed ? AppColor.backgroundLight : AppColor.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: _isPressed ? AppColor.primary : AppColor.border,
width: _isPressed ? 2 : 1,
),
boxShadow: _isPressed
? [
BoxShadow(
color: AppColor.primary.withOpacity(0.1),
blurRadius: 8,
offset: const Offset(0, 2),
),
]
: null,
),
child: Row(
children: [
Expanded(
child: Text(
label,
style: TextStyle(
fontSize: 15,
fontWeight: hasValue ? FontWeight.w500 : FontWeight.w400,
color: hasValue
? AppColor.textPrimary
: AppColor.textSecondary,
),
overflow: TextOverflow.ellipsis,
),
),
Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: AppColor.primary.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
),
child: widget.isLoading
? const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: AppColor.primary,
),
)
: const Icon(
Icons.store_rounded,
size: 20,
color: AppColor.primary,
),
),
],
),
),
);
}
}
// Bottom sheet pilih outlet
class _OutletBottomSheet extends StatelessWidget {
final List<Outlet> outlets;
final String? selectedOutletId;
final Function(String?) onSelected;
const _OutletBottomSheet({
required this.outlets,
required this.selectedOutletId,
required this.onSelected,
});
@override
Widget build(BuildContext context) {
return SafeArea(
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 16, 20, 20),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
width: 40,
height: 4,
decoration: BoxDecoration(
color: Colors.grey.shade300,
borderRadius: BorderRadius.circular(2),
),
),
),
const SizedBox(height: 16),
Text(
'Pilih Outlet',
style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700),
),
const SizedBox(height: 12),
_OutletItem(
label: 'Semua Outlet',
icon: Icons.store_rounded,
isSelected: selectedOutletId == null,
onTap: () => onSelected(null),
),
const Divider(height: 1),
...outlets.map(
(outlet) => Column(
children: [
_OutletItem(
label: outlet.name,
icon: Icons.storefront_rounded,
isSelected: selectedOutletId == outlet.id,
isActive: outlet.isActive,
onTap: () => onSelected(outlet.id),
),
if (outlet != outlets.last) const Divider(height: 1),
],
),
),
],
),
),
);
}
}
class _OutletItem extends StatelessWidget {
final String label;
final IconData icon;
final bool isSelected;
final bool? isActive;
final VoidCallback onTap;
const _OutletItem({
required this.label,
required this.icon,
required this.isSelected,
required this.onTap,
this.isActive,
});
@override
Widget build(BuildContext context) {
return ListTile(
onTap: onTap,
contentPadding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
leading: Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: isSelected
? AppColor.primary.withOpacity(0.1)
: AppColor.background,
borderRadius: BorderRadius.circular(10),
),
child: Icon(
icon,
size: 18,
color: isSelected ? AppColor.primary : AppColor.textSecondary,
),
),
title: Text(
label,
style: AppStyle.md.copyWith(
fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500,
color: isSelected ? AppColor.primary : AppColor.textPrimary,
),
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (isActive != null)
Container(
width: 8,
height: 8,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: isActive! ? AppColor.success : AppColor.error,
),
),
if (isActive != null) const SizedBox(width: 8),
if (isSelected)
const Icon(
Icons.check_rounded,
color: AppColor.primary,
size: 20,
),
],
),
);
}
}

View File

@ -107,7 +107,20 @@ class _ReportPageState extends State<ReportPage> with TickerProviderStateMixin {
DashboardAnalyticLoaderState DashboardAnalyticLoaderState
>( >(
builder: (context, state) { builder: (context, state) {
return CustomScrollView( return RefreshIndicator(
color: AppColor.primary,
onRefresh: () async {
context.read<DashboardAnalyticLoaderBloc>().add(
DashboardAnalyticLoaderEvent.fetched(),
);
// tunggu sampai fetching selesai
await context
.read<DashboardAnalyticLoaderBloc>()
.stream
.firstWhere((s) => !s.isFetching);
},
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [ slivers: [
SliverAppBar( SliverAppBar(
expandedHeight: 120, expandedHeight: 120,
@ -197,6 +210,7 @@ class _ReportPageState extends State<ReportPage> with TickerProviderStateMixin {
), ),
), ),
], ],
),
); );
}, },
), ),