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