Skip to content

armgit / ente

Public Imported from GitHub
0

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

Simplify contact edit UI

Neeraj Gupta8f101697aad0
diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart
index 0dc184710e..138190757c 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart
@@ -284,8 +284,7 @@ class _ContactResultPageState extends State<ContactResultPage> {
Widget? _buildPageHeader(BuildContext context) {
final sections = <Widget?>[
_buildContactHeader(context),
- if (collections.isNotEmpty)
- _AlbumsSection(context: context, collections: collections),
+ if (collections.isNotEmpty) _AlbumsSection(collections: collections),
].whereType<Widget>().toList();
if (sections.isEmpty) {
return null;
@@ -448,9 +447,8 @@ class _SavedContactAppBar extends StatelessWidget {
}
class _AlbumsSection extends StatelessWidget {
- const _AlbumsSection({required this.context, required this.collections});
+ const _AlbumsSection({required this.collections});
- final BuildContext context;
final List<Collection> collections;
@override
diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart
index 48cde091b0..dff99b837b 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart
@@ -134,60 +134,74 @@ class _EditContactPageState extends State<EditContactPage> {
backgroundColor: colors.backgroundBase,
body: Column(
children: [
- _EditContactHeader(
- title: l10n.editContact,
- onBack: () {
- Navigator.of(context).maybePop();
- },
- ),
Expanded(
- child: ListView(
- keyboardDismissBehavior:
- ScrollViewKeyboardDismissBehavior.onDrag,
- padding: const EdgeInsets.fromLTRB(24, 20, 24, 20),
- children: [
- Center(
- child: SizedBox(
- width: _avatarSize,
- height: _avatarSize,
- child: GestureDetector(
- onTap: _openAvatarEditor,
- child: Stack(
- clipBehavior: Clip.none,
+ child: NotificationListener<ScrollStartNotification>(
+ onNotification: (_) {
+ if (_nameFocusNode.hasFocus) {
+ _nameFocusNode.unfocus();
+ }
+ return false;
+ },
+ child: AppBarComponent(
+ title: l10n.editContact,
+ onBack: () {
+ Navigator.of(context).maybePop();
+ },
+ physics: const BouncingScrollPhysics(),
+ slivers: [
+ SliverPadding(
+ padding: const EdgeInsets.fromLTRB(24, 20, 24, 20),
+ sliver: SliverToBoxAdapter(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- _buildAvatar(context, size: _avatarSize),
- Positioned(
- right: 0,
- bottom: 0,
- child: _AvatarActionButton(
- size: _editBadgeSize,
- isUnlink: _hasLinkedPersonDraft,
- onTap: _hasLinkedPersonDraft
- ? _draftUnlinkPerson
- : _openAvatarEditor,
+ Center(
+ child: SizedBox(
+ width: _avatarSize,
+ height: _avatarSize,
+ child: GestureDetector(
+ onTap: _openAvatarEditor,
+ child: Stack(
+ clipBehavior: Clip.none,
+ children: [
+ _buildAvatar(context, size: _avatarSize),
+ Positioned(
+ right: 0,
+ bottom: 0,
+ child: _AvatarActionButton(
+ size: _editBadgeSize,
+ isUnlink: _hasLinkedPersonDraft,
+ onTap: _hasLinkedPersonDraft
+ ? _draftUnlinkPerson
+ : _openAvatarEditor,
+ ),
+ ),
+ ],
+ ),
+ ),
),
),
+ const SizedBox(height: 20),
+ _ReadOnlyContactTextInput(
+ label: l10n.email,
+ value: widget.email,
+ ),
+ const SizedBox(height: 20),
+ TextInputComponent(
+ label: l10n.name,
+ hintText: l10n.enterName,
+ controller: _nameController,
+ focusNode: _nameFocusNode,
+ isRequired: true,
+ textCapitalization: TextCapitalization.words,
+ onSubmit: _canSave ? (_) => _saveContact() : null,
+ ),
],
),
),
),
- ),
- const SizedBox(height: 20),
- _ReadOnlyContactTextInput(
- label: l10n.email,
- value: widget.email,
- ),
- const SizedBox(height: 20),
- TextInputComponent(
- label: l10n.name,
- hintText: l10n.enterName,
- controller: _nameController,
- focusNode: _nameFocusNode,
- isRequired: true,
- textCapitalization: TextCapitalization.words,
- onSubmit: _canSave ? (_) => _saveContact() : null,
- ),
- ],
+ ],
+ ),
),
),
Padding(
@@ -654,86 +668,6 @@ class _EditContactPageState extends State<EditContactPage> {
}
}
-class _EditContactHeader extends StatelessWidget {
- const _EditContactHeader({required this.title, required this.onBack});
-
- final String title;
- final VoidCallback onBack;
-
- @override
- Widget build(BuildContext context) {
- final topPadding = MediaQuery.paddingOf(context).top;
- final colors = context.componentColors;
- final height = topPadding + 76;
-
- return SizedBox(
- width: double.infinity,
- height: height,
- child: Padding(
- padding: EdgeInsets.only(top: topPadding),
- child: ColoredBox(
- color: colors.backgroundBase,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: Spacing.lg),
- child: _expandedContent(context),
- ),
- ),
- ),
- );
- }
-
- Widget _expandedContent(BuildContext context) {
- return Padding(
- padding: const EdgeInsets.only(top: Spacing.lg),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- _BackButton(onBack: onBack),
- const SizedBox(height: 8),
- Text(title, style: _titleStyle(context)),
- ],
- ),
- );
- }
-
- TextStyle _titleStyle(BuildContext context) {
- return TextStyles.display2.copyWith(
- color: context.componentColors.textBase,
- );
- }
-}
-
-class _BackButton extends StatelessWidget {
- const _BackButton({required this.onBack});
-
- final VoidCallback onBack;
-
- @override
- Widget build(BuildContext context) {
- final tooltip = MaterialLocalizations.of(context).backButtonTooltip;
- return Semantics(
- button: true,
- label: tooltip,
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: onBack,
- child: SizedBox(
- width: 40,
- height: 20,
- child: Align(
- alignment: Alignment.centerLeft,
- child: Icon(
- Icons.arrow_back,
- size: 24,
- color: getEnteColorScheme(context).textBase,
- ),
- ),
- ),
- ),
- );
- }
-}
-
class _ReadOnlyContactTextInput extends StatelessWidget {
const _ReadOnlyContactTextInput({required this.label, required this.value});
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart
index c2f9028c19..1df341e96a 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart
@@ -227,17 +227,11 @@ class ContactRecommendation extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
- ClipOval(
- child: SizedBox(
- width: ContactRecommendation._avatarSize,
- height: ContactRecommendation._avatarSize,
- child: ContactAvatarWidget(
- contactUserId: contactUserId,
- email: contactEmail,
- personId: personId,
- size: ContactRecommendation._avatarSize,
- ),
- ),
+ ContactAvatarWidget(
+ contactUserId: contactUserId,
+ email: contactEmail,
+ personId: personId,
+ size: ContactRecommendation._avatarSize,
),
const SizedBox(height: 10),
Text(