2022-02-03 09:06:44 -07:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2022-02-10 19:40:11 -07:00
|
|
|
import 'package:badges/badges.dart';
|
2022-02-03 09:06:44 -07:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2022-02-10 19:40:11 -07:00
|
|
|
import 'package:immich_mobile/modules/login/providers/authentication.provider.dart';
|
2022-02-03 09:06:44 -07:00
|
|
|
|
|
|
|
import 'package:immich_mobile/routing/router.dart';
|
2022-05-06 05:22:23 -07:00
|
|
|
import 'package:immich_mobile/modules/backup/models/backup_state.model.dart';
|
2022-03-21 23:22:04 -07:00
|
|
|
import 'package:immich_mobile/shared/models/server_info_state.model.dart';
|
2022-05-06 05:22:23 -07:00
|
|
|
import 'package:immich_mobile/modules/backup/providers/backup.provider.dart';
|
2022-03-21 23:22:04 -07:00
|
|
|
import 'package:immich_mobile/shared/providers/server_info.provider.dart';
|
2022-02-03 09:06:44 -07:00
|
|
|
|
|
|
|
class ImmichSliverAppBar extends ConsumerWidget {
|
|
|
|
const ImmichSliverAppBar({
|
|
|
|
Key? key,
|
2022-02-06 19:31:32 -07:00
|
|
|
this.onPopBack,
|
2022-02-03 09:06:44 -07:00
|
|
|
}) : super(key: key);
|
|
|
|
|
2022-02-06 19:31:32 -07:00
|
|
|
final Function? onPopBack;
|
2022-02-03 09:06:44 -07:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2022-06-21 22:23:35 -07:00
|
|
|
final BackUpState backupState = ref.watch(backupProvider);
|
2022-09-08 06:36:08 -07:00
|
|
|
bool isEnableAutoBackup = backupState.backgroundBackup ||
|
2022-06-21 22:23:35 -07:00
|
|
|
ref.watch(authenticationProvider).deviceInfo.isAutoBackup;
|
|
|
|
final ServerInfoState serverInfoState = ref.watch(serverInfoProvider);
|
2022-03-21 23:22:04 -07:00
|
|
|
|
2022-02-10 19:40:11 -07:00
|
|
|
return SliverAppBar(
|
|
|
|
centerTitle: true,
|
|
|
|
floating: true,
|
|
|
|
pinned: false,
|
|
|
|
snap: false,
|
2022-08-15 16:53:30 -07:00
|
|
|
backgroundColor: Theme.of(context).appBarTheme.backgroundColor,
|
2022-06-21 22:23:35 -07:00
|
|
|
shape: const RoundedRectangleBorder(
|
2022-07-13 05:23:48 -07:00
|
|
|
borderRadius: BorderRadius.all(Radius.circular(5)),
|
|
|
|
),
|
2022-02-10 19:40:11 -07:00
|
|
|
leading: Builder(
|
|
|
|
builder: (BuildContext context) {
|
2022-03-21 23:22:04 -07:00
|
|
|
return Stack(
|
|
|
|
children: [
|
|
|
|
Positioned(
|
|
|
|
top: 5,
|
|
|
|
child: IconButton(
|
|
|
|
splashRadius: 25,
|
2022-09-06 06:18:07 -07:00
|
|
|
icon: Icon(
|
2022-04-23 19:08:45 -07:00
|
|
|
Icons.face_outlined,
|
2022-03-21 23:22:04 -07:00
|
|
|
size: 30,
|
2022-09-06 06:18:07 -07:00
|
|
|
color: Theme.of(context).primaryColor,
|
2022-03-21 23:22:04 -07:00
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
Scaffold.of(context).openDrawer();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2022-06-30 18:08:49 -07:00
|
|
|
if (serverInfoState.isVersionMismatch)
|
|
|
|
Positioned(
|
|
|
|
bottom: 12,
|
|
|
|
right: 12,
|
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () => Scaffold.of(context).openDrawer(),
|
|
|
|
child: Material(
|
2022-08-15 16:53:30 -07:00
|
|
|
// color: Colors.grey[200],
|
2022-06-30 18:08:49 -07:00
|
|
|
elevation: 1,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(50.0),
|
|
|
|
),
|
|
|
|
child: const Padding(
|
|
|
|
padding: EdgeInsets.all(2.0),
|
|
|
|
child: Icon(
|
|
|
|
Icons.info,
|
|
|
|
color: Color.fromARGB(255, 243, 188, 106),
|
|
|
|
size: 15,
|
2022-03-21 23:22:04 -07:00
|
|
|
),
|
|
|
|
),
|
2022-06-30 18:08:49 -07:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-03-21 23:22:04 -07:00
|
|
|
],
|
2022-02-10 19:40:11 -07:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2022-08-15 16:53:30 -07:00
|
|
|
title: const Text(
|
2022-02-10 19:40:11 -07:00
|
|
|
'IMMICH',
|
2022-04-04 07:08:53 -07:00
|
|
|
style: TextStyle(
|
|
|
|
fontFamily: 'SnowburstOne',
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 22,
|
2022-02-03 09:06:44 -07:00
|
|
|
),
|
2022-02-10 19:40:11 -07:00
|
|
|
),
|
|
|
|
actions: [
|
|
|
|
Stack(
|
|
|
|
alignment: AlignmentDirectional.center,
|
|
|
|
children: [
|
2022-06-30 18:08:49 -07:00
|
|
|
if (backupState.backupProgress == BackUpProgressEnum.inProgress)
|
|
|
|
Positioned(
|
|
|
|
top: 10,
|
|
|
|
right: 12,
|
|
|
|
child: SizedBox(
|
|
|
|
height: 8,
|
|
|
|
width: 8,
|
|
|
|
child: CircularProgressIndicator(
|
|
|
|
strokeWidth: 1,
|
|
|
|
valueColor: AlwaysStoppedAnimation<Color>(
|
2022-07-13 05:23:48 -07:00
|
|
|
Theme.of(context).primaryColor,
|
|
|
|
),
|
2022-06-30 18:08:49 -07:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-02-10 19:40:11 -07:00
|
|
|
IconButton(
|
|
|
|
splashRadius: 25,
|
|
|
|
iconSize: 30,
|
2022-06-21 22:23:35 -07:00
|
|
|
icon: isEnableAutoBackup
|
2022-09-06 06:18:07 -07:00
|
|
|
? Icon(
|
|
|
|
Icons.backup_rounded,
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
)
|
2022-02-10 19:40:11 -07:00
|
|
|
: Badge(
|
|
|
|
padding: const EdgeInsets.all(4),
|
2022-08-15 16:53:30 -07:00
|
|
|
elevation: 3,
|
2022-02-10 19:40:11 -07:00
|
|
|
position: BadgePosition.bottomEnd(bottom: -4, end: -4),
|
|
|
|
badgeColor: Colors.white,
|
|
|
|
badgeContent: const Icon(
|
|
|
|
Icons.cloud_off_rounded,
|
|
|
|
size: 8,
|
2022-08-15 16:53:30 -07:00
|
|
|
color: Colors.indigo,
|
2022-02-03 09:06:44 -07:00
|
|
|
),
|
2022-09-06 06:18:07 -07:00
|
|
|
child: Icon(
|
|
|
|
Icons.backup_rounded,
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
),
|
2022-07-13 05:23:48 -07:00
|
|
|
),
|
2022-04-03 10:31:45 -07:00
|
|
|
onPressed: () async {
|
2022-06-21 22:23:35 -07:00
|
|
|
var onPop = await AutoRouter.of(context)
|
|
|
|
.push(const BackupControllerRoute());
|
2022-04-03 10:31:45 -07:00
|
|
|
|
|
|
|
if (onPop != null && onPop == true) {
|
|
|
|
onPopBack!();
|
|
|
|
}
|
2022-02-10 19:40:11 -07:00
|
|
|
},
|
|
|
|
),
|
2022-06-30 18:08:49 -07:00
|
|
|
if (backupState.backupProgress == BackUpProgressEnum.inProgress)
|
|
|
|
Positioned(
|
|
|
|
bottom: 5,
|
|
|
|
child: Text(
|
|
|
|
'${backupState.allUniqueAssets.length - backupState.selectedAlbumsBackupAssetsIds.length}',
|
|
|
|
style:
|
|
|
|
const TextStyle(fontSize: 9, fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
),
|
2022-02-10 19:40:11 -07:00
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-02-03 09:06:44 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|