Refactor mobile to use OpenApi generated SDK (#336)

This commit is contained in:
Alex 2022-07-13 07:23:48 -05:00 committed by GitHub
parent d69470e207
commit ae7e582ec8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
276 changed files with 14513 additions and 3003 deletions

View file

@ -20,10 +20,13 @@ class AlbumPreviewPage extends HookConsumerWidget {
await album.getAssetListRange(start: 0, end: album.assetCount);
}
useEffect(() {
_getAssetsInAlbum();
return null;
}, []);
useEffect(
() {
_getAssetsInAlbum();
return null;
},
[],
);
return Scaffold(
appBar: AppBar(
@ -39,9 +42,10 @@ class AlbumPreviewPage extends HookConsumerWidget {
child: Text(
"ID ${album.id}",
style: TextStyle(
fontSize: 10,
color: Colors.grey[600],
fontWeight: FontWeight.bold),
fontSize: 10,
color: Colors.grey[600],
fontWeight: FontWeight.bold,
),
),
),
],
@ -59,9 +63,11 @@ class AlbumPreviewPage extends HookConsumerWidget {
),
itemCount: assets.value.length,
itemBuilder: (context, index) {
Future<Uint8List?> thumbData = assets.value[index]
.thumbnailDataWithSize(const ThumbnailSize(200, 200),
quality: 50);
Future<Uint8List?> thumbData =
assets.value[index].thumbnailDataWithSize(
const ThumbnailSize(200, 200),
quality: 50,
);
return FutureBuilder<Uint8List?>(
future: thumbData,

View file

@ -17,10 +17,13 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
final selectedBackupAlbums = ref.watch(backupProvider).selectedBackupAlbums;
final excludedBackupAlbums = ref.watch(backupProvider).excludedBackupAlbums;
useEffect(() {
ref.read(backupProvider.notifier).getBackupInfo();
return null;
}, []);
useEffect(
() {
ref.read(backupProvider.notifier).getBackupInfo();
return null;
},
[],
);
_buildAlbumSelectionList() {
if (availableAlbums.isEmpty) {
@ -42,8 +45,9 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
? const EdgeInsets.only(left: 16.00)
: const EdgeInsets.all(0),
child: AlbumInfoCard(
imageData: thumbnailData,
albumInfo: availableAlbums[index].albumEntity),
imageData: thumbnailData,
albumInfo: availableAlbums[index].albumEntity,
),
);
}),
),
@ -73,13 +77,15 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
child: Chip(
visualDensity: VisualDensity.compact,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5)),
borderRadius: BorderRadius.circular(5),
),
label: Text(
album.name,
style: const TextStyle(
fontSize: 10,
color: Colors.white,
fontWeight: FontWeight.bold),
fontSize: 10,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
backgroundColor: Theme.of(context).primaryColor,
deleteIconColor: Colors.white,
@ -109,13 +115,15 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
child: Chip(
visualDensity: VisualDensity.compact,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5)),
borderRadius: BorderRadius.circular(5),
),
label: Text(
album.name,
style: const TextStyle(
fontSize: 10,
color: Colors.white,
fontWeight: FontWeight.bold),
fontSize: 10,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
backgroundColor: Colors.red[300],
deleteIconColor: Colors.white,
@ -185,9 +193,10 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
title: Text(
"backup_album_selection_page_total_assets",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: Colors.grey[700]),
fontWeight: FontWeight.bold,
fontSize: 14,
color: Colors.grey[700],
),
).tr(),
trailing: Text(
ref
@ -234,7 +243,8 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
borderRadius: BorderRadius.circular(12),
),
elevation: 5,
title: Text(
'backup_album_selection_page_selection_info',
@ -250,7 +260,9 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
Text(
'backup_album_selection_page_assets_scatter',
style: TextStyle(
fontSize: 14, color: Colors.grey[700]),
fontSize: 14,
color: Colors.grey[700],
),
).tr(),
],
),

View file

@ -11,7 +11,6 @@ import 'package:immich_mobile/modules/backup/providers/backup.provider.dart';
import 'package:immich_mobile/routing/router.dart';
import 'package:immich_mobile/shared/providers/websocket.provider.dart';
import 'package:immich_mobile/modules/backup/ui/backup_info_card.dart';
import 'package:intl/intl.dart';
import 'package:percent_indicator/linear_percent_indicator.dart';
class BackupControllerPage extends HookConsumerWidget {
@ -27,16 +26,19 @@ class BackupControllerPage extends HookConsumerWidget {
? false
: true;
useEffect(() {
if (backupState.backupProgress != BackUpProgressEnum.inProgress) {
ref.watch(backupProvider.notifier).getBackupInfo();
}
useEffect(
() {
if (backupState.backupProgress != BackUpProgressEnum.inProgress) {
ref.watch(backupProvider.notifier).getBackupInfo();
}
ref
.watch(websocketProvider.notifier)
.stopListenToEvent('on_upload_success');
return null;
}, []);
ref
.watch(websocketProvider.notifier)
.stopListenToEvent('on_upload_success');
return null;
},
[],
);
Widget _buildStorageInformation() {
return ListTile(
@ -68,10 +70,11 @@ class BackupControllerPage extends HookConsumerWidget {
Padding(
padding: const EdgeInsets.only(top: 12.0),
child: const Text('backup_controller_page_storage_format').tr(
args: [
backupState.serverInfo.diskUse,
backupState.serverInfo.diskSize
]),
args: [
backupState.serverInfo.diskUse,
backupState.serverInfo.diskSize
],
),
),
],
),
@ -129,8 +132,10 @@ class BackupControllerPage extends HookConsumerWidget {
.setAutoBackup(true);
}
},
child: Text(backupBtnText,
style: const TextStyle(fontWeight: FontWeight.bold)),
child: Text(
backupBtnText,
style: const TextStyle(fontWeight: FontWeight.bold),
),
),
)
],
@ -157,9 +162,10 @@ class BackupControllerPage extends HookConsumerWidget {
child: Text(
text.trim().substring(0, text.length - 2),
style: TextStyle(
color: Theme.of(context).primaryColor,
fontSize: 12,
fontWeight: FontWeight.bold),
color: Theme.of(context).primaryColor,
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
);
} else {
@ -168,9 +174,10 @@ class BackupControllerPage extends HookConsumerWidget {
child: Text(
"backup_controller_page_none_selected".tr(),
style: TextStyle(
color: Theme.of(context).primaryColor,
fontSize: 12,
fontWeight: FontWeight.bold),
color: Theme.of(context).primaryColor,
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
);
}
@ -190,9 +197,10 @@ class BackupControllerPage extends HookConsumerWidget {
child: Text(
text.trim().substring(0, text.length - 2),
style: TextStyle(
color: Colors.red[300],
fontSize: 12,
fontWeight: FontWeight.bold),
color: Colors.red[300],
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
);
} else {
@ -213,9 +221,10 @@ class BackupControllerPage extends HookConsumerWidget {
borderOnForeground: false,
child: ListTile(
minVerticalPadding: 15,
title: const Text("backup_controller_page_albums",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20))
.tr(),
title: const Text(
"backup_controller_page_albums",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
).tr(),
subtitle: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Column(
@ -284,9 +293,9 @@ class BackupControllerPage extends HookConsumerWidget {
fontWeight: FontWeight.bold,
fontSize: 11,
),
).tr(args: [
ref.watch(errorBackupListProvider).length.toString()
]),
).tr(
args: [ref.watch(errorBackupListProvider).length.toString()],
),
backgroundColor: Colors.white,
onPressed: () {
AutoRouter.of(context).push(const FailedBackupStatusRoute());
@ -331,12 +340,16 @@ class BackupControllerPage extends HookConsumerWidget {
child: const Text(
'backup_controller_page_filename',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 10.0),
).tr(args: [
backupState.currentUploadAsset.fileName,
backupState.currentUploadAsset.fileType
.toLowerCase()
]),
fontWeight: FontWeight.bold,
fontSize: 10.0,
),
).tr(
args: [
backupState.currentUploadAsset.fileName,
backupState.currentUploadAsset.fileType
.toLowerCase()
],
),
),
),
],
@ -352,16 +365,20 @@ class BackupControllerPage extends HookConsumerWidget {
padding: const EdgeInsets.all(6.0),
child: const Text(
"backup_controller_page_created",
style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 10.0),
).tr(args: [
DateFormat.yMMMMd('en_US').format(
DateTime.parse(
backupState.currentUploadAsset.createdAt
.toString(),
),
)
]),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 10.0,
),
).tr(
args: [
DateFormat.yMMMMd('en_US').format(
DateTime.parse(
backupState.currentUploadAsset.createdAt
.toString(),
),
)
],
),
),
),
],
@ -406,14 +423,15 @@ class BackupControllerPage extends HookConsumerWidget {
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
).tr(),
leading: IconButton(
onPressed: () {
ref.watch(websocketProvider.notifier).listenUploadEvent();
AutoRouter.of(context).pop(true);
},
splashRadius: 24,
icon: const Icon(
Icons.arrow_back_ios_rounded,
)),
onPressed: () {
ref.watch(websocketProvider.notifier).listenUploadEvent();
AutoRouter.of(context).pop(true);
},
splashRadius: 24,
icon: const Icon(
Icons.arrow_back_ios_rounded,
),
),
),
body: Padding(
padding: const EdgeInsets.only(left: 16.0, right: 16, bottom: 32),

View file

@ -19,13 +19,14 @@ class FailedBackupStatusPage extends HookConsumerWidget {
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
leading: IconButton(
onPressed: () {
AutoRouter.of(context).pop(true);
},
splashRadius: 24,
icon: const Icon(
Icons.arrow_back_ios_rounded,
)),
onPressed: () {
AutoRouter.of(context).pop(true);
},
splashRadius: 24,
icon: const Icon(
Icons.arrow_back_ios_rounded,
),
),
),
body: ListView.builder(
shrinkWrap: true,
@ -92,9 +93,10 @@ class FailedBackupStatusPage extends HookConsumerWidget {
),
),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Colors.grey[700]),
fontSize: 12,
fontWeight: FontWeight.w600,
color: Colors.grey[700],
),
),
Icon(
Icons.error,