From bea5441363f736fefa3892a786964745dca3d9b2 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Sat, 29 Oct 2022 17:17:30 +0530 Subject: [PATCH 1/3] fetch memories count from network api --- .../settings/settings_title_bar_widget.dart | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/ui/settings/settings_title_bar_widget.dart b/lib/ui/settings/settings_title_bar_widget.dart index a74764fb7..3c2e0482e 100644 --- a/lib/ui/settings/settings_title_bar_widget.dart +++ b/lib/ui/settings/settings_title_bar_widget.dart @@ -1,10 +1,8 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:logging/logging.dart'; -import 'package:photos/core/configuration.dart'; -import 'package:photos/db/files_db.dart'; -import 'package:photos/models/file_type.dart'; import 'package:photos/models/user_details.dart'; +import 'package:photos/states/user_details_state.dart'; import 'package:photos/theme/ente_theme.dart'; import 'package:photos/ui/common/loading_widget.dart'; @@ -29,22 +27,28 @@ class SettingsTitleBarWidget extends StatelessWidget { icon: const Icon(Icons.keyboard_double_arrow_left_outlined), ), FutureBuilder( - future: FilesDB.instance - .fetchFilesCountbyType(Configuration.instance.getUserID()), + future: InheritedUserDetails.of(context)?.userDetails, builder: (context, snapshot) { - if (snapshot.hasData) { - final totalFiles = - FilesCount(snapshot.data as Map).total; + 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; return Text( - totalFiles == 0 - ? "No memories yet" - : "${NumberFormat().format(totalFiles)} memories", + "${NumberFormat().format(userDetails.fileCount)} memories", style: getEnteTextTheme(context).largeBold, ); } else if (snapshot.hasError) { - logger.severe('failed to fetch filesCount'); + logger.severe('failed to load user details'); + return const EnteLoadingWidget(); + } else { + return const EnteLoadingWidget(); } - return const EnteLoadingWidget(); }, ) ], From 408e71c7a62486c085c400f08952195a7d2810b8 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Sat, 29 Oct 2022 17:19:50 +0530 Subject: [PATCH 2/3] removed photos and videos count from storage card --- lib/ui/settings/details_section_widget.dart | 44 +-------------------- 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/lib/ui/settings/details_section_widget.dart b/lib/ui/settings/details_section_widget.dart index 6566cb73d..b058b8bd7 100644 --- a/lib/ui/settings/details_section_widget.dart +++ b/lib/ui/settings/details_section_widget.dart @@ -1,9 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; import 'package:logging/logging.dart'; -import 'package:photos/core/configuration.dart'; -import 'package:photos/db/files_db.dart'; -import 'package:photos/models/file_type.dart'; import 'package:photos/models/user_details.dart'; import 'package:photos/states/user_details_state.dart'; import 'package:photos/theme/colors.dart'; @@ -253,45 +249,7 @@ class _DetailsSectionWidgetState extends State { ), ], ) - : FutureBuilder( - future: FilesDB.instance.fetchFilesCountbyType( - Configuration.instance.getUserID(), - ), - builder: (context, snapshot) { - if (snapshot.hasData) { - final filesCount = FilesCount( - snapshot.data as Map, - ); - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "${NumberFormat().format(filesCount.photos)} photos", - style: getEnteTextTheme(context) - .mini - .copyWith(color: textBaseDark), - ), - Text( - "${NumberFormat().format(filesCount.videos)} videos", - style: getEnteTextTheme(context) - .mini - .copyWith(color: textBaseDark), - ), - ], - ); - } else if (snapshot.hasError) { - _logger.severe( - 'Error fetching photo and video count', - snapshot.error, - ); - return const SizedBox.shrink(); - } else { - return const EnteLoadingWidget( - color: strokeBaseDark, - ); - } - }, - ), + : const SizedBox.shrink(), RichText( text: TextSpan( style: getEnteTextTheme(context) From 2e32ae259d16ba6760da3f6320171f9907a1f039 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Sat, 29 Oct 2022 17:28:09 +0530 Subject: [PATCH 3/3] layout changes in storage card --- lib/ui/settings/details_section_widget.dart | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/ui/settings/details_section_widget.dart b/lib/ui/settings/details_section_widget.dart index b058b8bd7..3b29a8b29 100644 --- a/lib/ui/settings/details_section_widget.dart +++ b/lib/ui/settings/details_section_widget.dart @@ -141,13 +141,7 @@ class _DetailsSectionWidgetState extends State { 16, 20, 16, - isMobileScreenSmall - ? userDetails.isPartOfFamily() - ? 12 - : 8 - : userDetails.isPartOfFamily() - ? 20 - : 12, + isMobileScreenSmall ? 12 : 20, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween,