2022-10-10 08:59:54 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
import 'package:photos/models/user_details.dart';
|
2022-10-29 11:47:30 +00:00
|
|
|
import 'package:photos/states/user_details_state.dart';
|
2022-10-10 08:59:54 +00:00
|
|
|
import 'package:photos/theme/ente_theme.dart';
|
|
|
|
import 'package:photos/ui/common/loading_widget.dart';
|
|
|
|
|
2022-10-10 09:05:16 +00:00
|
|
|
class SettingsTitleBarWidget extends StatelessWidget {
|
2022-10-10 08:59:54 +00:00
|
|
|
const SettingsTitleBarWidget({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-10-10 09:05:16 +00:00
|
|
|
final logger = Logger((SettingsTitleBarWidget).toString());
|
2022-10-10 08:59:54 +00:00
|
|
|
return Container(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
|
|
|
child: Padding(
|
2022-10-12 08:27:54 +00:00
|
|
|
padding: const EdgeInsets.fromLTRB(8, 0, 20, 0),
|
2022-10-10 08:59:54 +00:00
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
IconButton(
|
|
|
|
visualDensity: const VisualDensity(horizontal: -2, vertical: -2),
|
2022-10-10 11:36:41 +00:00
|
|
|
onPressed: () {
|
2022-10-12 06:32:19 +00:00
|
|
|
Navigator.pop(context);
|
2022-10-10 11:36:41 +00:00
|
|
|
},
|
2022-10-10 08:59:54 +00:00
|
|
|
icon: const Icon(Icons.keyboard_double_arrow_left_outlined),
|
|
|
|
),
|
|
|
|
FutureBuilder(
|
2022-10-29 11:47:30 +00:00
|
|
|
future: InheritedUserDetails.of(context)?.userDetails,
|
2022-10-10 08:59:54 +00:00
|
|
|
builder: (context, snapshot) {
|
2022-10-29 11:47:30 +00:00
|
|
|
if (InheritedUserDetails.of(context) == null) {
|
|
|
|
logger.severe(
|
|
|
|
(InheritedUserDetails).toString() +
|
|
|
|
' not found before ' +
|
|
|
|
(SettingsTitleBarWidget).toString() +
|
|
|
|
' on tree',
|
|
|
|
);
|
|
|
|
throw Error();
|
|
|
|
} else if (snapshot.hasData) {
|
|
|
|
final userDetails = snapshot.data as UserDetails;
|
2022-10-10 08:59:54 +00:00
|
|
|
return Text(
|
2022-10-29 11:47:30 +00:00
|
|
|
"${NumberFormat().format(userDetails.fileCount)} memories",
|
2022-10-10 08:59:54 +00:00
|
|
|
style: getEnteTextTheme(context).largeBold,
|
|
|
|
);
|
2022-10-20 11:56:48 +00:00
|
|
|
} else if (snapshot.hasError) {
|
2022-10-29 11:47:30 +00:00
|
|
|
logger.severe('failed to load user details');
|
|
|
|
return const EnteLoadingWidget();
|
|
|
|
} else {
|
|
|
|
return const EnteLoadingWidget();
|
2022-10-10 08:59:54 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|