feat: update home ui
Some checks are pending
Build & Deploy iOS to TestFlight / build-and-deploy (push) Waiting to run
Some checks are pending
Build & Deploy iOS to TestFlight / build-and-deploy (push) Waiting to run
This commit is contained in:
parent
8d801e52d9
commit
b07af60778
@ -26,10 +26,25 @@ class SelectedOutletBloc
|
|||||||
return event.map(
|
return event.map(
|
||||||
loaded: (e) async {
|
loaded: (e) async {
|
||||||
final savedId = _localDataProvider.getSelectedOutletId();
|
final savedId = _localDataProvider.getSelectedOutletId();
|
||||||
|
final savedName = _localDataProvider.getSelectedOutletName();
|
||||||
|
|
||||||
|
if (savedId != null && savedName != null) {
|
||||||
|
emit(
|
||||||
|
state.copyWith(
|
||||||
|
selectedOutletId: savedId,
|
||||||
|
selectedOutlet: Outlet.empty().copyWith(
|
||||||
|
id: savedId,
|
||||||
|
name: savedName,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
emit(state.copyWith(selectedOutletId: savedId));
|
emit(state.copyWith(selectedOutletId: savedId));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
selected: (e) async {
|
selected: (e) async {
|
||||||
await _localDataProvider.saveSelectedOutletId(e.outlet.id);
|
await _localDataProvider.saveSelectedOutletId(e.outlet.id);
|
||||||
|
await _localDataProvider.saveSelectedOutletName(e.outlet.name);
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
selectedOutlet: e.outlet,
|
selectedOutlet: e.outlet,
|
||||||
|
|||||||
@ -3,4 +3,5 @@ class LocalStorageKey {
|
|||||||
static const String token = 'token';
|
static const String token = 'token';
|
||||||
static const String user = 'user';
|
static const String user = 'user';
|
||||||
static const String selectedOutletId = 'selected_outlet_id';
|
static const String selectedOutletId = 'selected_outlet_id';
|
||||||
|
static const String selectedOutletName = 'selected_outlet_name';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,11 +16,23 @@ class OutletLocalDataProvider {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> saveSelectedOutletName(String outletName) async {
|
||||||
|
await _sharedPreferences.setString(
|
||||||
|
LocalStorageKey.selectedOutletName,
|
||||||
|
outletName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
String? getSelectedOutletId() {
|
String? getSelectedOutletId() {
|
||||||
return _sharedPreferences.getString(LocalStorageKey.selectedOutletId);
|
return _sharedPreferences.getString(LocalStorageKey.selectedOutletId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String? getSelectedOutletName() {
|
||||||
|
return _sharedPreferences.getString(LocalStorageKey.selectedOutletName);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> deleteSelectedOutletId() async {
|
Future<void> deleteSelectedOutletId() async {
|
||||||
await _sharedPreferences.remove(LocalStorageKey.selectedOutletId);
|
await _sharedPreferences.remove(LocalStorageKey.selectedOutletId);
|
||||||
|
await _sharedPreferences.remove(LocalStorageKey.selectedOutletName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class HomeStats extends StatelessWidget {
|
|||||||
icon: Icons.hexagon_outlined,
|
icon: Icons.hexagon_outlined,
|
||||||
iconColor: const Color(0xFF4CAF50),
|
iconColor: const Color(0xFF4CAF50),
|
||||||
blobColor: const Color(0xFF4CAF50),
|
blobColor: const Color(0xFF4CAF50),
|
||||||
value: '0', // TODO: connect items sold data
|
value: overview.totalItemSold.toString(),
|
||||||
label: context.lang.items_sold,
|
label: context.lang.items_sold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -58,7 +58,7 @@ class HomeStats extends StatelessWidget {
|
|||||||
icon: Icons.warning_amber_rounded,
|
icon: Icons.warning_amber_rounded,
|
||||||
iconColor: const Color(0xFFFF9800),
|
iconColor: const Color(0xFFFF9800),
|
||||||
blobColor: const Color(0xFFFF9800),
|
blobColor: const Color(0xFFFF9800),
|
||||||
value: '0', // TODO: connect low stock data
|
value: overview.totalLowStock.toString(),
|
||||||
label: context.lang.low_stock_warning,
|
label: context.lang.low_stock_warning,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -68,7 +68,7 @@ class HomeStats extends StatelessWidget {
|
|||||||
icon: Icons.hexagon_outlined,
|
icon: Icons.hexagon_outlined,
|
||||||
iconColor: const Color(0xFFE53935),
|
iconColor: const Color(0xFFE53935),
|
||||||
blobColor: const Color(0xFFE53935),
|
blobColor: const Color(0xFFE53935),
|
||||||
value: '0', // TODO: connect active products data
|
value: overview.totalProductActive.toString(),
|
||||||
label: context.lang.active_products,
|
label: context.lang.active_products,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user