mirror of
https://github.com/immich-app/immich.git
synced 2024-12-25 10:43:13 +02:00
chore(mobile): styling and linter (#1807)
* chore(mobile): styling and linter * style: adaptive SwitchListTile
This commit is contained in:
parent
88a2966666
commit
03d484aba2
5
mobile/ios/Runner/Runner.entitlements
Normal file
5
mobile/ios/Runner/Runner.entitlements
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict/>
|
||||||
|
</plist>
|
@ -301,12 +301,11 @@ class BackgroundService {
|
|||||||
// indefinitely and can run later
|
// indefinitely and can run later
|
||||||
// Android is fine to wait here until the lock releases
|
// Android is fine to wait here until the lock releases
|
||||||
final waitForLock = Platform.isIOS
|
final waitForLock = Platform.isIOS
|
||||||
? acquireLock()
|
? acquireLock().timeout(
|
||||||
.timeout(
|
const Duration(seconds: 5),
|
||||||
const Duration(seconds: 5),
|
onTimeout: () => false,
|
||||||
onTimeout: () => false,
|
)
|
||||||
)
|
: acquireLock();
|
||||||
: acquireLock();
|
|
||||||
|
|
||||||
final bool hasAccess = await waitForLock;
|
final bool hasAccess = await waitForLock;
|
||||||
if (!hasAccess) {
|
if (!hasAccess) {
|
||||||
@ -381,7 +380,8 @@ class BackgroundService {
|
|||||||
}
|
}
|
||||||
// Android should check for new assets added while performing backup
|
// Android should check for new assets added while performing backup
|
||||||
} while (Platform.isAndroid &&
|
} while (Platform.isAndroid &&
|
||||||
true == await _backgroundChannel.invokeMethod<bool>("hasContentChanged"));
|
true ==
|
||||||
|
await _backgroundChannel.invokeMethod<bool>("hasContentChanged"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,8 +555,8 @@ class BackgroundService {
|
|||||||
Future<DateTime?> getIOSBackupLastRun(IosBackgroundTask task) async {
|
Future<DateTime?> getIOSBackupLastRun(IosBackgroundTask task) async {
|
||||||
// Seconds since last run
|
// Seconds since last run
|
||||||
final double? lastRun = task == IosBackgroundTask.fetch
|
final double? lastRun = task == IosBackgroundTask.fetch
|
||||||
? await _foregroundChannel.invokeMethod('lastBackgroundFetchTime')
|
? await _foregroundChannel.invokeMethod('lastBackgroundFetchTime')
|
||||||
: await _foregroundChannel.invokeMethod('lastBackgroundProcessingTime');
|
: await _foregroundChannel.invokeMethod('lastBackgroundProcessingTime');
|
||||||
if (lastRun == null) {
|
if (lastRun == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -565,15 +565,11 @@ class BackgroundService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<int> getIOSBackupNumberOfProcesses() async {
|
Future<int> getIOSBackupNumberOfProcesses() async {
|
||||||
return await _foregroundChannel
|
return await _foregroundChannel.invokeMethod('numberOfBackgroundProcesses');
|
||||||
.invokeMethod('numberOfBackgroundProcesses');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum IosBackgroundTask {
|
enum IosBackgroundTask { fetch, processing }
|
||||||
fetch,
|
|
||||||
processing
|
|
||||||
}
|
|
||||||
|
|
||||||
class _Throttle {
|
class _Throttle {
|
||||||
_Throttle(this._fun, Duration interval) : _interval = interval.inMicroseconds;
|
_Throttle(this._fun, Duration interval) : _interval = interval.inMicroseconds;
|
||||||
|
@ -21,7 +21,7 @@ class BackupInfoCard extends StatelessWidget {
|
|||||||
borderRadius: BorderRadius.circular(20), // if you need this
|
borderRadius: BorderRadius.circular(20), // if you need this
|
||||||
side: BorderSide(
|
side: BorderSide(
|
||||||
color: isDarkMode
|
color: isDarkMode
|
||||||
? const Color.fromARGB(255, 101, 101, 101)
|
? const Color.fromARGB(255, 56, 56, 56)
|
||||||
: Colors.black12,
|
: Colors.black12,
|
||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
|
@ -11,12 +11,13 @@ class IosDebugInfoTile extends HookConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final futures = [
|
final futures = [
|
||||||
ref.read(backgroundServiceProvider)
|
ref
|
||||||
.getIOSBackupLastRun(IosBackgroundTask.fetch),
|
.read(backgroundServiceProvider)
|
||||||
ref.read(backgroundServiceProvider)
|
.getIOSBackupLastRun(IosBackgroundTask.fetch),
|
||||||
.getIOSBackupLastRun(IosBackgroundTask.processing),
|
ref
|
||||||
ref.read(backgroundServiceProvider)
|
.read(backgroundServiceProvider)
|
||||||
.getIOSBackupNumberOfProcesses(),
|
.getIOSBackupLastRun(IosBackgroundTask.processing),
|
||||||
|
ref.read(backgroundServiceProvider).getIOSBackupNumberOfProcesses(),
|
||||||
];
|
];
|
||||||
return FutureBuilder<List<dynamic>>(
|
return FutureBuilder<List<dynamic>>(
|
||||||
future: Future.wait(futures),
|
future: Future.wait(futures),
|
||||||
@ -41,9 +42,8 @@ class IosDebugInfoTile extends HookConsumerWidget {
|
|||||||
} else if (processing != null && fetch == null) {
|
} else if (processing != null && fetch == null) {
|
||||||
subtitle = 'Processing ran ${df.format(processing)}';
|
subtitle = 'Processing ran ${df.format(processing)}';
|
||||||
} else {
|
} else {
|
||||||
final fetchOrProcessing = fetch!.isAfter(processing!)
|
final fetchOrProcessing =
|
||||||
? fetch
|
fetch!.isAfter(processing!) ? fetch : processing;
|
||||||
: processing;
|
|
||||||
subtitle = 'Last sync ${df.format(fetchOrProcessing)}';
|
subtitle = 'Last sync ${df.format(fetchOrProcessing)}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,8 +52,20 @@ class IosDebugInfoTile extends HookConsumerWidget {
|
|||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
key: ValueKey(title),
|
key: ValueKey(title),
|
||||||
title: Text(title ?? ''),
|
title: Text(
|
||||||
subtitle: Text(subtitle ?? ''),
|
title ?? '',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 14,
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
subtitle ?? '',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
leading: Icon(
|
leading: Icon(
|
||||||
Icons.bug_report,
|
Icons.bug_report,
|
||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context).primaryColor,
|
||||||
@ -64,4 +76,3 @@ class IosDebugInfoTile extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,14 +263,14 @@ class BackupControllerPage extends HookConsumerWidget {
|
|||||||
if (!isBackgroundEnabled)
|
if (!isBackgroundEnabled)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
child:
|
child: const Text(
|
||||||
const Text("backup_controller_page_background_description")
|
"backup_controller_page_background_description",
|
||||||
.tr(),
|
).tr(),
|
||||||
),
|
),
|
||||||
if (isBackgroundEnabled && Platform.isAndroid)
|
if (isBackgroundEnabled && Platform.isAndroid)
|
||||||
SwitchListTile(
|
SwitchListTile.adaptive(
|
||||||
title:
|
title: const Text("backup_controller_page_background_wifi")
|
||||||
const Text("backup_controller_page_background_wifi").tr(),
|
.tr(),
|
||||||
secondary: Icon(
|
secondary: Icon(
|
||||||
Icons.wifi,
|
Icons.wifi,
|
||||||
color: isWifiRequired ? activeColor : null,
|
color: isWifiRequired ? activeColor : null,
|
||||||
@ -289,9 +289,10 @@ class BackupControllerPage extends HookConsumerWidget {
|
|||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
if (isBackgroundEnabled)
|
if (isBackgroundEnabled)
|
||||||
SwitchListTile(
|
SwitchListTile.adaptive(
|
||||||
title: const Text("backup_controller_page_background_charging")
|
title:
|
||||||
.tr(),
|
const Text("backup_controller_page_background_charging")
|
||||||
|
.tr(),
|
||||||
secondary: Icon(
|
secondary: Icon(
|
||||||
Icons.charging_station,
|
Icons.charging_station,
|
||||||
color: isChargingRequired ? activeColor : null,
|
color: isChargingRequired ? activeColor : null,
|
||||||
@ -319,7 +320,9 @@ class BackupControllerPage extends HookConsumerWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
).tr(args: [formatBackupDelaySliderValue(triggerDelay.value)]),
|
).tr(
|
||||||
|
args: [formatBackupDelaySliderValue(triggerDelay.value)],
|
||||||
|
),
|
||||||
subtitle: Slider(
|
subtitle: Slider(
|
||||||
value: triggerDelay.value,
|
value: triggerDelay.value,
|
||||||
onChanged: hasExclusiveAccess
|
onChanged: hasExclusiveAccess
|
||||||
@ -339,18 +342,21 @@ class BackupControllerPage extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () =>
|
onPressed: () => ref
|
||||||
ref.read(backupProvider.notifier).configureBackgroundBackup(
|
.read(backupProvider.notifier)
|
||||||
enabled: !isBackgroundEnabled,
|
.configureBackgroundBackup(
|
||||||
onError: showErrorToUser,
|
enabled: !isBackgroundEnabled,
|
||||||
onBatteryInfo: showBatteryOptimizationInfoToUser,
|
onError: showErrorToUser,
|
||||||
),
|
onBatteryInfo: showBatteryOptimizationInfoToUser,
|
||||||
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
isBackgroundEnabled
|
isBackgroundEnabled
|
||||||
? "backup_controller_page_background_turn_off"
|
? "backup_controller_page_background_turn_off"
|
||||||
: "backup_controller_page_background_turn_on",
|
: "backup_controller_page_background_turn_on",
|
||||||
style:
|
style: const TextStyle(
|
||||||
const TextStyle(fontWeight: FontWeight.bold, fontSize: 12),
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
).tr(),
|
).tr(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -434,7 +440,7 @@ class BackupControllerPage extends HookConsumerWidget {
|
|||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
side: BorderSide(
|
side: BorderSide(
|
||||||
color: isDarkMode
|
color: isDarkMode
|
||||||
? const Color.fromARGB(255, 101, 101, 101)
|
? const Color.fromARGB(255, 56, 56, 56)
|
||||||
: Colors.black12,
|
: Colors.black12,
|
||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
@ -534,7 +540,7 @@ class BackupControllerPage extends HookConsumerWidget {
|
|||||||
borderRadius: BorderRadius.circular(20), // if you need this
|
borderRadius: BorderRadius.circular(20), // if you need this
|
||||||
side: BorderSide(
|
side: BorderSide(
|
||||||
color: isDarkMode
|
color: isDarkMode
|
||||||
? const Color.fromARGB(255, 101, 101, 101)
|
? const Color.fromARGB(255, 56, 56, 56)
|
||||||
: Colors.black12,
|
: Colors.black12,
|
||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user