Skip to content

Commit

Permalink
chore(mobile): remove screen auto-dimming (#14699)
Browse files Browse the repository at this point in the history
  • Loading branch information
alextran1502 authored Dec 14, 2024
1 parent cc111a1 commit dd9feee
Showing 1 changed file with 65 additions and 118 deletions.
183 changes: 65 additions & 118 deletions mobile/lib/pages/backup/backup_controller.page.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import 'dart:async';
import 'dart:io';
import 'dart:math';

import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/extensions/build_context_extensions.dart';
Expand All @@ -31,8 +29,6 @@ class BackupControllerPage extends HookConsumerWidget {
BackUpState backupState = ref.watch(backupProvider);
final hasAnyAlbum = backupState.selectedBackupAlbums.isNotEmpty;
final didGetBackupInfo = useState(false);
final isScreenDarkened = useState(false);
final darkenScreenTimer = useRef<Timer?>(null);

bool hasExclusiveAccess =
backupState.backupProgress != BackUpProgressEnum.inBackground;
Expand All @@ -43,25 +39,6 @@ class BackupControllerPage extends HookConsumerWidget {
? false
: true;

void startScreenDarkenTimer() {
darkenScreenTimer.value = Timer(const Duration(seconds: 30), () {
isScreenDarkened.value = true;
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
});
}

void stopScreenDarkenTimer() {
darkenScreenTimer.value?.cancel();
isScreenDarkened.value = false;
SystemChrome.setEnabledSystemUIMode(
SystemUiMode.manual,
overlays: [
SystemUiOverlay.top,
SystemUiOverlay.bottom,
],
);
}

useEffect(
() {
// Update the background settings information just to make sure we
Expand All @@ -77,8 +54,6 @@ class BackupControllerPage extends HookConsumerWidget {

return () {
WakelockPlus.disable();
darkenScreenTimer.value?.cancel();
isScreenDarkened.value = false;
};
},
[],
Expand All @@ -99,10 +74,8 @@ class BackupControllerPage extends HookConsumerWidget {
useEffect(
() {
if (backupState.backupProgress == BackUpProgressEnum.inProgress) {
startScreenDarkenTimer();
WakelockPlus.enable();
} else {
stopScreenDarkenTimer();
WakelockPlus.disable();
}

Expand Down Expand Up @@ -297,103 +270,77 @@ class BackupControllerPage extends HookConsumerWidget {
);
}

return GestureDetector(
onTap: () {
if (isScreenDarkened.value) {
stopScreenDarkenTimer();
}
if (backupState.backupProgress == BackUpProgressEnum.inProgress) {
startScreenDarkenTimer();
}
},
child: AnimatedOpacity(
opacity: isScreenDarkened.value ? 0.1 : 1.0,
duration: const Duration(seconds: 1),
child: Scaffold(
appBar: AppBar(
elevation: 0,
title: const Text(
"backup_controller_page_backup",
).tr(),
leading: IconButton(
onPressed: () {
ref.watch(websocketProvider.notifier).listenUploadEvent();
context.maybePop(true);
},
return Scaffold(
appBar: AppBar(
elevation: 0,
title: const Text(
"backup_controller_page_backup",
).tr(),
leading: IconButton(
onPressed: () {
ref.watch(websocketProvider.notifier).listenUploadEvent();
context.maybePop(true);
},
splashRadius: 24,
icon: const Icon(
Icons.arrow_back_ios_rounded,
),
),
actions: [
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: IconButton(
onPressed: () => context.pushRoute(const BackupOptionsRoute()),
splashRadius: 24,
icon: const Icon(
Icons.arrow_back_ios_rounded,
Icons.settings_outlined,
),
),
actions: [
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: IconButton(
onPressed: () =>
context.pushRoute(const BackupOptionsRoute()),
splashRadius: 24,
icon: const Icon(
Icons.settings_outlined,
),
),
),
],
),
body: Stack(
children: [
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16, bottom: 32),
child: ListView(
// crossAxisAlignment: CrossAxisAlignment.start,
children: hasAnyAlbum
? [
buildFolderSelectionTile(),
BackupInfoCard(
title: "backup_controller_page_total".tr(),
subtitle: "backup_controller_page_total_sub".tr(),
info: ref
.watch(backupProvider)
.availableAlbums
.isEmpty
? "..."
: "${backupState.allUniqueAssets.length}",
),
BackupInfoCard(
title: "backup_controller_page_backup".tr(),
subtitle: "backup_controller_page_backup_sub".tr(),
info: ref
.watch(backupProvider)
.availableAlbums
.isEmpty
? "..."
: "${backupState.selectedAlbumsBackupAssetsIds.length}",
),
BackupInfoCard(
title: "backup_controller_page_remainder".tr(),
subtitle:
"backup_controller_page_remainder_sub".tr(),
info: ref
.watch(backupProvider)
.availableAlbums
.isEmpty
? "..."
: "${max(0, backupState.allUniqueAssets.length - backupState.selectedAlbumsBackupAssetsIds.length)}",
),
const Divider(),
const CurrentUploadingAssetInfoBox(),
if (!hasExclusiveAccess) buildBackgroundBackupInfo(),
buildBackupButton(),
]
: [
buildFolderSelectionTile(),
if (!didGetBackupInfo.value) buildLoadingIndicator(),
],
),
),
],
],
),
body: Stack(
children: [
Padding(
padding: const EdgeInsets.only(left: 16.0, right: 16, bottom: 32),
child: ListView(
// crossAxisAlignment: CrossAxisAlignment.start,
children: hasAnyAlbum
? [
buildFolderSelectionTile(),
BackupInfoCard(
title: "backup_controller_page_total".tr(),
subtitle: "backup_controller_page_total_sub".tr(),
info: ref.watch(backupProvider).availableAlbums.isEmpty
? "..."
: "${backupState.allUniqueAssets.length}",
),
BackupInfoCard(
title: "backup_controller_page_backup".tr(),
subtitle: "backup_controller_page_backup_sub".tr(),
info: ref.watch(backupProvider).availableAlbums.isEmpty
? "..."
: "${backupState.selectedAlbumsBackupAssetsIds.length}",
),
BackupInfoCard(
title: "backup_controller_page_remainder".tr(),
subtitle: "backup_controller_page_remainder_sub".tr(),
info: ref.watch(backupProvider).availableAlbums.isEmpty
? "..."
: "${max(0, backupState.allUniqueAssets.length - backupState.selectedAlbumsBackupAssetsIds.length)}",
),
const Divider(),
const CurrentUploadingAssetInfoBox(),
if (!hasExclusiveAccess) buildBackgroundBackupInfo(),
buildBackupButton(),
]
: [
buildFolderSelectionTile(),
if (!didGetBackupInfo.value) buildLoadingIndicator(),
],
),
),
),
],
),
);
}
Expand Down

1 comment on commit dd9feee

@abbbubble
Copy link

@abbbubble abbbubble commented on dd9feee Dec 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello alextran1502,

I hope you see this message. While using the app, I noticed two inconveniences:

1.When multiple devices are logged into the same account, some mobile devices may only need to upload a few photos, but there’s no separate upload button.
2.If the mobile device has already backed up photos using another app, I only want to back up new photos now. However, starting the backup process currently causes duplicate backups of the same photos.

So, I suggest:
1.Adding a separate upload button in the app for easier use.
2.Including an option to back up only new photos, avoiding duplicate backups.

Would you consider adopting these suggestions?

Please sign in to comment.