Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][locker] Update Locker home header

AmanRajSinghMouryab08a44314d77
diff --git a/mobile/apps/locker/assets/svg/legacy_heartbeat_icon.svg b/mobile/apps/locker/assets/svg/legacy_heartbeat_icon.svg
new file mode 100644
index 0000000000..dde59f1b76
--- /dev/null
+++ b/mobile/apps/locker/assets/svg/legacy_heartbeat_icon.svg
@@ -0,0 +1,6 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0.75 2) scale(1.25)">
+<path d="M14.2822 0.763148C13.4966 0.279911 12.596 0.0174457 11.6751 0.000753683C10.7532 -0.0150137 9.84335 0.216861 9.04194 0.673182L8.3797 1.04325L7.71746 0.673182C6.87529 0.200155 5.91812 -0.0280005 4.95248 0.0137414C3.98788 0.0564068 3.05389 0.366196 2.25635 0.910621C1.46521 1.43002 0.837275 2.16366 0.446806 3.0253C0.0554108 3.88787 -0.0828028 4.84226 0.0479788 5.78007C0.522857 9.41954 3.22468 12.7511 8.07818 15.6839C8.26739 15.798 8.50391 15.798 8.6931 15.6839C10.1623 14.8121 11.5376 13.7909 12.7963 12.6352C12.9187 12.5304 12.9938 12.3792 13.0031 12.2169C13.0124 12.0555 12.9549 11.8969 12.8445 11.7782C12.7332 11.6604 12.5792 11.5917 12.4169 11.5899C12.2555 11.588 12.0997 11.653 11.9866 11.7689C10.8754 12.7882 9.66784 13.6962 8.37963 14.48C4.04352 11.7922 1.63683 8.81491 1.21846 5.628C1.12015 4.9092 1.22681 4.17554 1.52825 3.51517C1.82875 2.85386 2.31107 2.29182 2.91858 1.89391C3.53537 1.47377 4.25788 1.23447 5.00358 1.20199C5.74928 1.17046 6.48943 1.34761 7.14053 1.71303L8.09029 2.24449C8.27023 2.34652 8.49097 2.34652 8.67183 2.24449L9.62158 1.71303C10.2393 1.36336 10.9396 1.18528 11.6491 1.19826C12.3596 1.21032 13.0524 1.41252 13.6581 1.78445C14.2526 2.13321 14.7423 2.63589 15.0762 3.23877C15.411 3.84165 15.5771 4.52336 15.5576 5.21248C15.5529 5.37016 15.6114 5.5232 15.7199 5.63729C15.8275 5.7523 15.9768 5.81908 16.1345 5.82279C16.4619 5.83206 16.7355 5.57421 16.7448 5.24588C16.7726 4.34713 16.5593 3.45673 16.1261 2.66848C15.693 1.88011 15.0558 1.22252 14.2823 0.763406L14.2822 0.763148Z" fill="black" style="fill:black;fill-opacity:1;"/>
+<path d="M16.6507 7.15128H12.1059C11.9195 7.15221 11.7433 7.23939 11.631 7.38872L10.8566 8.40247L9.61742 5.19718C9.55157 4.96809 9.354 4.80113 9.11656 4.7733C8.87912 4.74641 8.64817 4.86512 8.53225 5.07381L6.78949 7.16052H4.47446C4.14705 7.16052 3.88086 7.42671 3.88086 7.75411C3.88086 8.08245 4.14705 8.34771 4.47446 8.34771H7.13639C7.34972 8.34864 7.54635 8.23456 7.65116 8.04906L8.87359 6.88613L10.0497 9.85849C10.1136 10.0718 10.2908 10.2323 10.5106 10.274C10.7295 10.313 10.953 10.2267 11.0894 10.0505L12.4027 8.33833H16.6507C16.9781 8.33833 17.2443 8.07306 17.2443 7.74473C17.2443 7.41733 16.9781 7.15128 16.6507 7.15128Z" fill="black" style="fill:black;fill-opacity:1;"/>
+</g>
+</svg>
diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dart
index 6c697ef2c5..d1e205fa0d 100644
--- a/mobile/apps/locker/lib/ui/pages/home_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart
@@ -35,71 +35,39 @@ import "package:locker/utils/bottom_sheet_illustration.dart";
import 'package:locker/utils/collection_sort_util.dart';
import 'package:logging/logging.dart';
-class CustomLockerAppBar extends StatelessWidget
- implements PreferredSizeWidget {
- final GlobalKey<ScaffoldState> scaffoldKey;
- final bool isSyncing;
- final TextEditingController searchController;
- final FocusNode searchFocusNode;
- final bool isSearchActive;
- final VoidCallback onClearSearch;
- final VoidCallback onSearchTapped;
- final ValueChanged<String>? onSearchChanged;
-
- const CustomLockerAppBar({
+class LockerHomeHeader extends StatelessWidget {
+ const LockerHomeHeader({
super.key,
required this.scaffoldKey,
+ required this.onLegacyTapped,
this.isSyncing = false,
- required this.searchController,
- required this.searchFocusNode,
- this.isSearchActive = false,
- required this.onClearSearch,
- required this.onSearchTapped,
- this.onSearchChanged,
});
- @override
- Size get preferredSize => const Size.fromHeight(140);
+ final GlobalKey<ScaffoldState> scaffoldKey;
+ final VoidCallback onLegacyTapped;
+ final bool isSyncing;
@override
Widget build(BuildContext context) {
final colors = context.componentColors;
- final hasQuery = searchController.text.trim().isNotEmpty;
- final showClearIcon = isSearchActive || hasQuery;
-
- return Container(
- decoration: BoxDecoration(
- color: colors.primary,
- borderRadius: const BorderRadius.only(
- bottomLeft: Radius.circular(20),
- bottomRight: Radius.circular(20),
- ),
- ),
- child: SafeArea(
- child: Column(
- children: [
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
- child: Stack(
- alignment: Alignment.center,
- children: [
- Align(
- alignment: Alignment.centerLeft,
- child: GestureDetector(
- onTap: () {
- scaffoldKey.currentState!.openDrawer();
- },
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12),
- child: HugeIcon(
- icon: HugeIcons.strokeRoundedMenu01,
- color: colors.specialWhite,
- strokeWidth: 2.25,
- ),
- ),
- ),
- ),
- isSyncing
+ return SafeArea(
+ bottom: false,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: SizedBox(
+ height: 48,
+ child: Row(
+ children: [
+ _LockerHeaderAction(
+ onTap: () => scaffoldKey.currentState!.openDrawer(),
+ child: HugeIcon(
+ icon: HugeIcons.strokeRoundedMenu01,
+ color: colors.textBase,
+ ),
+ ),
+ Expanded(
+ child: Center(
+ child: isSyncing
? Row(
mainAxisSize: MainAxisSize.min,
children: [
@@ -109,7 +77,7 @@ class CustomLockerAppBar extends StatelessWidget
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
- colors.specialWhite,
+ colors.textBase,
),
),
),
@@ -117,65 +85,59 @@ class CustomLockerAppBar extends StatelessWidget
Text(
context.l10n.syncing,
style: TextStyles.body.copyWith(
- color: colors.specialWhite,
+ color: colors.textBase,
),
),
],
)
- : SvgPicture.asset('assets/svg/app-logo.svg'),
- ],
- ),
- ),
- Padding(
- padding: const EdgeInsets.only(
- left: 16,
- right: 16,
- top: 16,
- bottom: 16,
- ),
- child: Listener(
- behavior: HitTestBehavior.translucent,
- onPointerDown: (_) => onSearchTapped(),
- child: Theme(
- data: ComponentTheme.lightTheme(app: ComponentApp.locker),
- child: Builder(
- builder: (context) {
- final fieldColors = context.componentColors;
- return TextInputComponent(
- controller: searchController,
- focusNode: searchFocusNode,
- hintText: context.l10n.searchHint,
- onChanged: onSearchChanged,
- autocorrect: false,
- enableSuggestions: false,
- shouldUnfocusOnClearOrSubmit: true,
- prefix: HugeIcon(
- icon: HugeIcons.strokeRoundedSearch01,
- color: fieldColors.primary,
- size: 20,
- strokeWidth: 1.75,
+ : SvgPicture.asset(
+ 'assets/svg/app-logo.svg',
+ colorFilter: ColorFilter.mode(
+ colors.textBase,
+ BlendMode.srcIn,
+ ),
),
- suffix: showClearIcon
- ? HugeIcon(
- icon: HugeIcons.strokeRoundedCancel01,
- color: fieldColors.textLight,
- size: 18,
- )
- : null,
- onSuffixTap: showClearIcon ? onClearSearch : null,
- );
- },
+ ),
+ ),
+ _LockerHeaderAction(
+ onTap: onLegacyTapped,
+ child: SvgPicture.asset(
+ 'assets/svg/legacy_heartbeat_icon.svg',
+ width: 20,
+ height: 20,
+ colorFilter: ColorFilter.mode(
+ colors.textBase,
+ BlendMode.srcIn,
),
),
),
- ),
- ],
+ ],
+ ),
),
),
);
}
}
+class _LockerHeaderAction extends StatelessWidget {
+ const _LockerHeaderAction({required this.onTap, required this.child});
+
+ final VoidCallback onTap;
+ final Widget child;
+
+ @override
+ Widget build(BuildContext context) {
+ return Semantics(
+ button: true,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onTap,
+ child: SizedBox(width: 48, height: 48, child: Center(child: child)),
+ ),
+ );
+ }
+}
+
class HomePage extends UploaderPage {
final String? initialSearchQuery;
@@ -588,6 +550,7 @@ class _HomePageState extends UploaderPageState<HomePage>
@override
Widget build(BuildContext context) {
final colors = context.componentColors;
+ final isHomeEmptyState = _error == null && _recentFiles.isEmpty;
return UserDetailsStateWidget(
child: ListenableBuilder(
listenable: _selectedFiles,
@@ -633,20 +596,6 @@ class _HomePageState extends UploaderPageState<HomePage>
Bus.instance.fire(OpenedSettingsEvent());
}
},
- appBar: CustomLockerAppBar(
- scaffoldKey: scaffoldKey,
- isSyncing: _isSyncing,
- searchController: searchController,
- searchFocusNode: searchFocusNode,
- isSearchActive: isSearchActive,
- onClearSearch: _handleClearSearch,
- onSearchTapped: () {
- if (!isSearchActive) {
- activateSearchWithQuery('');
- }
- },
- onSearchChanged: _handleSearchChange,
- ),
body: Stack(
children: [
GestureDetector(
@@ -660,7 +609,7 @@ class _HomePageState extends UploaderPageState<HomePage>
scaffoldKey.currentState?.openDrawer();
}
},
- child: _buildBody(),
+ child: _buildHomeContent(isHomeEmptyState),
),
ValueListenableBuilder<List<EnteFile>>(
valueListenable: _displayedFilesNotifier,
@@ -763,7 +712,7 @@ class _HomePageState extends UploaderPageState<HomePage>
padding: EdgeInsets.only(
left: 16.0,
right: 16.0,
- top: 16.0,
+ top: 0,
bottom: scrollBottomPadding,
),
child: Column(
@@ -782,6 +731,66 @@ class _HomePageState extends UploaderPageState<HomePage>
);
}
+ Widget _buildHomeContent(bool isHomeEmptyState) {
+ return Column(
+ children: [
+ LockerHomeHeader(
+ scaffoldKey: scaffoldKey,
+ onLegacyTapped: () => unawaited(openLegacyPage(context)),
+ isSyncing: _isSyncing,
+ ),
+ if (!isHomeEmptyState) _buildSearchBar(),
+ Expanded(child: _buildBody()),
+ ],
+ );
+ }
+
+ Widget _buildSearchBar() {
+ final colors = context.componentColors;
+ final showClearIcon =
+ isSearchActive || searchController.text.trim().isNotEmpty;
+
+ return Padding(
+ padding: const EdgeInsets.only(
+ left: Spacing.lg,
+ top: Spacing.lg,
+ right: Spacing.lg,
+ bottom: Spacing.xl,
+ ),
+ child: Listener(
+ behavior: HitTestBehavior.translucent,
+ onPointerDown: (_) {
+ if (!isSearchActive) {
+ activateSearchWithQuery('');
+ }
+ },
+ child: TextInputComponent(
+ controller: searchController,
+ focusNode: searchFocusNode,
+ hintText: context.l10n.searchHint,
+ onChanged: _handleSearchChange,
+ autocorrect: false,
+ enableSuggestions: false,
+ shouldUnfocusOnClearOrSubmit: true,
+ prefix: HugeIcon(
+ icon: HugeIcons.strokeRoundedSearch01,
+ color: colors.primary,
+ size: 20,
+ strokeWidth: 1.75,
+ ),
+ suffix: showClearIcon
+ ? HugeIcon(
+ icon: HugeIcons.strokeRoundedCancel01,
+ color: colors.textLight,
+ size: 18,
+ )
+ : null,
+ onSuffixTap: showClearIcon ? _handleClearSearch : null,
+ ),
+ ),
+ );
+ }
+
void _openSavePage() {
showSaveBottomSheet(context, onUploadDocument: addFile);
}