backup. before shop update
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_wisetronic/models/user.dart';
|
||||
import '../models/located_address.dart';
|
||||
import '../models/cart_info.dart';
|
||||
import '../models/user.dart';
|
||||
|
||||
class UpdateContext {
|
||||
final BuildContext context;
|
||||
@@ -15,4 +17,39 @@ class UpdateLocale {
|
||||
class UpdateCurrentUser {
|
||||
final User user;
|
||||
UpdateCurrentUser(this.user);
|
||||
}
|
||||
|
||||
class UpdateRedirectRoute {
|
||||
final String route;
|
||||
UpdateRedirectRoute(this.route);
|
||||
}
|
||||
|
||||
class UpdateCartInfo {
|
||||
final List<CartInfo> cartInfos;
|
||||
UpdateCartInfo(this.cartInfos);
|
||||
}
|
||||
|
||||
class UpdateLocatedAddress {
|
||||
final LocatedAddress locatedAddress;
|
||||
UpdateLocatedAddress(this.locatedAddress);
|
||||
}
|
||||
|
||||
class UpdateFcmToken {
|
||||
final String token;
|
||||
UpdateFcmToken(this.token);
|
||||
}
|
||||
|
||||
class UpdateLastVisit {
|
||||
final List<int> lastVisit;
|
||||
UpdateLastVisit(this.lastVisit);
|
||||
}
|
||||
|
||||
class UpdateDeviceId {
|
||||
final String deviceId;
|
||||
UpdateDeviceId(this.deviceId);
|
||||
}
|
||||
|
||||
class UpdateTableNumber {
|
||||
final String tableNumber;
|
||||
UpdateTableNumber(this.tableNumber);
|
||||
}
|
||||
@@ -1,13 +1,27 @@
|
||||
|
||||
import 'package:flutter_wisetronic/store/reducer/context_reducer.dart';
|
||||
import 'package:flutter_wisetronic/store/reducer/locale_reducer.dart';
|
||||
import 'package:flutter_wisetronic/store/reducer/user_reducer.dart';
|
||||
import 'package:flutter_wisetronic/store/state/app_state.dart';
|
||||
import '../../store/reducer/cart_info_reducer.dart';
|
||||
import '../../store/reducer/context_reducer.dart';
|
||||
import '../../store/reducer/device_id_reducer.dart';
|
||||
import '../../store/reducer/fcmtoken_reducer.dart';
|
||||
import '../../store/reducer/last_visit_reducer.dart';
|
||||
import '../../store/reducer/locale_reducer.dart';
|
||||
import '../../store/reducer/locate_address_reducer.dart';
|
||||
import '../../store/reducer/redirect_route_reducer.dart';
|
||||
import '../../store/reducer/table_number_reducer.dart';
|
||||
import '../../store/reducer/user_reducer.dart';
|
||||
import '../../store/state/app_state.dart';
|
||||
|
||||
AppState appReducer(AppState state, action) {
|
||||
return AppState(
|
||||
context: contextReducer(state.context, action),
|
||||
locale: localeReducer(state.locale, action),
|
||||
user: userReducer(state.user, action),
|
||||
redirectRoute: redirectRouteReducer(state.redirectRoute, action),
|
||||
locatedAddress: locatedAddressReducer(state.locatedAddress, action),
|
||||
fcmToken: fcmtokenReducer(state.fcmToken, action),
|
||||
lastVisit: lastVisitReducer(state.lastVisit, action),
|
||||
cartInfos: cartInfoReducer(state.cartInfos, action),
|
||||
deviceId: deviceIdReducer(state.deviceId, action),
|
||||
tableNumber: tableNumberReducer(state.tableNumber, action)
|
||||
);
|
||||
}
|
||||
13
lib/store/reducer/cart_info_reducer.dart
Normal file
13
lib/store/reducer/cart_info_reducer.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
import '../../models/cart_info.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
import '../actions.dart';
|
||||
|
||||
final cartInfoReducer = combineReducers<List<CartInfo>>([
|
||||
TypedReducer<List<CartInfo>, UpdateCartInfo>(_updateCartInfo)
|
||||
]);
|
||||
|
||||
List<CartInfo> _updateCartInfo(List<CartInfo> cartInfos, action) {
|
||||
return action.cartInfos;
|
||||
}
|
||||
11
lib/store/reducer/device_id_reducer.dart
Normal file
11
lib/store/reducer/device_id_reducer.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
import '../actions.dart';
|
||||
|
||||
final deviceIdReducer = combineReducers<String>([
|
||||
TypedReducer<String, UpdateDeviceId>(_updateDeviceId)
|
||||
]);
|
||||
|
||||
String _updateDeviceId(String deviceId, action) {
|
||||
return action.deviceId;
|
||||
}
|
||||
11
lib/store/reducer/fcmtoken_reducer.dart
Normal file
11
lib/store/reducer/fcmtoken_reducer.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
import '../actions.dart';
|
||||
|
||||
final fcmtokenReducer = combineReducers<String>([
|
||||
TypedReducer<String, UpdateFcmToken>(_updateFcmToken)
|
||||
]);
|
||||
|
||||
String _updateFcmToken(String token, action) {
|
||||
return action.token;
|
||||
}
|
||||
11
lib/store/reducer/last_visit_reducer.dart
Normal file
11
lib/store/reducer/last_visit_reducer.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
import '../actions.dart';
|
||||
|
||||
final lastVisitReducer = combineReducers<List<int>>([
|
||||
TypedReducer<List<int>, UpdateLastVisit>(_updateLastVisit)
|
||||
]);
|
||||
|
||||
List<int> _updateLastVisit(List<int> lastVisit, action) {
|
||||
return action.lastVisit;
|
||||
}
|
||||
12
lib/store/reducer/locate_address_reducer.dart
Normal file
12
lib/store/reducer/locate_address_reducer.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
import '../../models/located_address.dart';
|
||||
import '../actions.dart';
|
||||
|
||||
final locatedAddressReducer = combineReducers<LocatedAddress>([
|
||||
TypedReducer<LocatedAddress, UpdateLocatedAddress>(_updateLocatedAddress)
|
||||
]);
|
||||
|
||||
LocatedAddress _updateLocatedAddress(LocatedAddress locatedAddress, action) {
|
||||
return action.locatedAddress;
|
||||
}
|
||||
11
lib/store/reducer/redirect_route_reducer.dart
Normal file
11
lib/store/reducer/redirect_route_reducer.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
import 'package:redux/redux.dart';
|
||||
import '../actions.dart';
|
||||
|
||||
final redirectRouteReducer = combineReducers<String>([
|
||||
TypedReducer<String, UpdateRedirectRoute>(_updateRedirectRoute)
|
||||
]);
|
||||
|
||||
String _updateRedirectRoute(String route, action) {
|
||||
return action.route;
|
||||
}
|
||||
11
lib/store/reducer/table_number_reducer.dart
Normal file
11
lib/store/reducer/table_number_reducer.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
import '../actions.dart';
|
||||
|
||||
final tableNumberReducer = combineReducers<String>([
|
||||
TypedReducer<String, UpdateTableNumber>(_updateTableNumber)
|
||||
]);
|
||||
|
||||
String _updateTableNumber(String tableNumber, action) {
|
||||
return action.tableNumber;
|
||||
}
|
||||
@@ -1,14 +1,25 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_wisetronic/models/user.dart';
|
||||
import '../../models/located_address.dart';
|
||||
import '../../models/cart_info.dart';
|
||||
import '../../models/user.dart';
|
||||
|
||||
@immutable
|
||||
class AppState {
|
||||
final BuildContext context;
|
||||
final Locale locale;
|
||||
final User user;
|
||||
final String redirectRoute;
|
||||
final List<CartInfo> cartInfos;
|
||||
final LocatedAddress locatedAddress;
|
||||
final String fcmToken;
|
||||
final List<int> lastVisit;
|
||||
final String deviceId;
|
||||
final String tableNumber;
|
||||
|
||||
AppState({this.context, this.locale, this.user});
|
||||
AppState({this.context, this.locale, this.user, this.redirectRoute,
|
||||
this.cartInfos, this.locatedAddress, this.fcmToken, this.lastVisit,
|
||||
this.deviceId, this.tableNumber});
|
||||
|
||||
factory AppState.init() => AppState();
|
||||
|
||||
@@ -19,6 +30,13 @@ class AppState {
|
||||
context: context ?? this.context,
|
||||
locale: locale ?? this.locale,
|
||||
user: user ?? this.user,
|
||||
redirectRoute: redirectRoute ?? this.redirectRoute,
|
||||
cartInfos: cartInfos ?? this.cartInfos,
|
||||
locatedAddress: locatedAddress ?? this.locatedAddress,
|
||||
fcmToken: fcmToken ?? this.fcmToken,
|
||||
lastVisit: lastVisit ?? this.lastVisit,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
tableNumber: tableNumber ?? this.tableNumber
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,7 +44,15 @@ class AppState {
|
||||
int get hashCode =>
|
||||
context.hashCode ^
|
||||
locale.hashCode ^
|
||||
user.hashCode;
|
||||
user.hashCode ^
|
||||
redirectRoute.hashCode ^
|
||||
cartInfos.hashCode ^
|
||||
locatedAddress.hashCode ^
|
||||
fcmToken.hashCode ^
|
||||
lastVisit.hashCode ^
|
||||
deviceId.hashCode ^
|
||||
tableNumber.hashCode;
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
@@ -34,9 +60,20 @@ class AppState {
|
||||
other is AppState &&
|
||||
context == other.context &&
|
||||
locale == other.locale &&
|
||||
user == other.user;
|
||||
user == other.user &&
|
||||
redirectRoute == other.redirectRoute &&
|
||||
cartInfos == other.cartInfos &&
|
||||
locatedAddress == other.locatedAddress &&
|
||||
fcmToken == other.fcmToken &&
|
||||
lastVisit == other.lastVisit &&
|
||||
deviceId == other.deviceId &&
|
||||
tableNumber == other.tableNumber;
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'AppState(context: $context, locale: $locale), user: $user';
|
||||
'AppState(context: $context, locale: $locale), user: $user, '
|
||||
'redirectRoute: $redirectRoute, cart info: $cartInfos, '
|
||||
'locate address: $locatedAddress, fcm: $fcmToken, '
|
||||
'last visit: $lastVisit, deviceId: $deviceId, '
|
||||
'tableNumber: $tableNumber';
|
||||
}
|
||||
Reference in New Issue
Block a user