Harden app for 24-7 offline-first operation

This commit is contained in:
dwindown
2026-03-31 14:37:14 +07:00
parent 49f130b5ea
commit 081ed9f695
9 changed files with 289 additions and 17 deletions

View File

@@ -1628,6 +1628,17 @@ class _AdminScreenState extends ConsumerState<AdminScreen> {
height: 180 * s,
width: double.infinity,
fit: BoxFit.cover,
errorBuilder: (_, __, ___) => Container(
height: 180 * s,
width: double.infinity,
color: SacredColors.surfaceContainerLowest,
alignment: Alignment.center,
child: Icon(
Icons.broken_image,
size: 36 * s,
color: SacredColors.onSurfaceVariant,
),
),
),
),
SizedBox(height: 12 * s),
@@ -1673,8 +1684,9 @@ class _AdminScreenState extends ConsumerState<AdminScreen> {
s: s,
onActivate: () async {
final res = await FilePicker.platform.pickFiles(type: FileType.image);
if (res != null && res.files.single.path != null) {
setState(() => _brandedBgImage = res.files.single.path);
final selectedPath = res?.files.single.path;
if (selectedPath != null && File(selectedPath).existsSync()) {
setState(() => _brandedBgImage = selectedPath);
_queueTampilanAutoSave(
message: 'Foto latar otomatis tersimpan',
);
@@ -1683,8 +1695,10 @@ class _AdminScreenState extends ConsumerState<AdminScreen> {
child: ElevatedButton.icon(
onPressed: () async {
final res = await FilePicker.platform.pickFiles(type: FileType.image);
if (res != null && res.files.single.path != null) {
setState(() => _brandedBgImage = res.files.single.path);
final selectedPath = res?.files.single.path;
if (selectedPath != null &&
File(selectedPath).existsSync()) {
setState(() => _brandedBgImage = selectedPath);
_queueTampilanAutoSave(
message: 'Foto latar otomatis tersimpan',
);
@@ -1720,7 +1734,9 @@ class _AdminScreenState extends ConsumerState<AdminScreen> {
if (res != null) {
setState(() {
for (var path in res.paths) {
if (path != null && !_slideshowImages.contains(path)) {
if (path != null &&
File(path).existsSync() &&
!_slideshowImages.contains(path)) {
_slideshowImages.add(path);
}
}
@@ -1736,7 +1752,9 @@ class _AdminScreenState extends ConsumerState<AdminScreen> {
if (res != null) {
setState(() {
for (var path in res.paths) {
if (path != null && !_slideshowImages.contains(path)) {
if (path != null &&
File(path).existsSync() &&
!_slideshowImages.contains(path)) {
_slideshowImages.add(path);
}
}
@@ -1785,6 +1803,17 @@ class _AdminScreenState extends ConsumerState<AdminScreen> {
width: double.infinity,
height: 120 * s,
fit: BoxFit.cover,
errorBuilder: (_, __, ___) => Container(
width: double.infinity,
height: 120 * s,
color: SacredColors.surfaceContainerHigh,
alignment: Alignment.center,
child: Icon(
Icons.broken_image,
size: 32 * s,
color: SacredColors.onSurfaceVariant,
),
),
),
),
SizedBox(height: 10 * s),