Skip to content

armgit / ente

Public Imported from GitHub
0

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

migrate to new design

AmanRajSinghMouryafff8d1fc02ba
diff --git a/mobile/apps/photos/lib/ui/actions/file/file_actions.dart b/mobile/apps/photos/lib/ui/actions/file/file_actions.dart
index a3c66efdaa..d7398d4988 100644
--- a/mobile/apps/photos/lib/ui/actions/file/file_actions.dart
+++ b/mobile/apps/photos/lib/ui/actions/file/file_actions.dart
@@ -11,7 +11,6 @@ import 'package:photos/models/file/file.dart';
import 'package:photos/module/metadata/panorama.dart';
import "package:photos/service_locator.dart";
import "package:photos/services/media_store_service.dart";
-import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/notification/toast.dart";
import 'package:photos/ui/viewer/file/file_details_widget.dart';
import "package:photos/utils/delete_file_util.dart";
@@ -163,8 +162,7 @@ class _DraggableDetailsSheetState extends State<_DraggableDetailsSheet> {
@override
Widget build(BuildContext context) {
- final isKeyboardOpen = MediaQuery.of(context).viewInsets.bottom > 60;
- final disableSnap = isKeyboardOpen || _isExpanded;
+ final disableSnap = _isExpanded;
return DraggableScrollableSheet(
controller: _sheetController,
initialChildSize: disableSnap ? 0.95 : 0.75,
@@ -174,9 +172,12 @@ class _DraggableDetailsSheetState extends State<_DraggableDetailsSheet> {
snapSizes: disableSnap ? null : const [0.75],
expand: false,
builder: (context, scrollController) => Container(
+ clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
- color: getEnteColorScheme(context).backgroundElevated,
- borderRadius: const BorderRadius.vertical(top: Radius.circular(12)),
+ color: context.componentColors.backgroundBase,
+ borderRadius: const BorderRadius.vertical(
+ top: Radius.circular(Radii.bottomSheet),
+ ),
),
child: FileDetailsWidget(
widget.file,
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_caption_widget.dart b/mobile/apps/photos/lib/ui/viewer/file/file_caption_widget.dart
index 19f18eae04..f6d78926d0 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/file_caption_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/file_caption_widget.dart
@@ -1,11 +1,10 @@
+import "package:ente_components/ente_components.dart";
import 'package:flutter/material.dart';
+import "package:hugeicons/hugeicons.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/file_caption_updated_event.dart";
import "package:photos/generated/l10n.dart";
import 'package:photos/models/file/file.dart';
-import 'package:photos/theme/ente_theme.dart';
-import 'package:photos/ui/components/keyboard/keyboard_oveylay.dart';
-import 'package:photos/ui/components/keyboard/keyboard_top_button.dart';
import "package:photos/ui/notification/toast.dart";
import 'package:photos/utils/magic_util.dart';
@@ -16,31 +15,9 @@ class FileCaptionReadyOnly extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- return Padding(
- padding: const EdgeInsets.all(4.0),
- child: ConstrainedBox(
- constraints: const BoxConstraints(
- minHeight: 32.0,
- minWidth: double.infinity,
- maxHeight: 200.0,
- maxWidth: double.infinity,
- ),
- child: DecoratedBox(
- decoration: BoxDecoration(
- color: colorScheme.fillFaint,
- borderRadius: BorderRadius.circular(4),
- ),
- child: SingleChildScrollView(
- scrollDirection: Axis.vertical,
- child: Padding(
- padding: const EdgeInsets.all(12.0),
- child: Text(caption, style: textTheme.small),
- ),
- ),
- ),
- ),
+ return Text(
+ caption,
+ style: TextStyles.body.copyWith(color: context.componentColors.textLight),
);
}
}
@@ -57,139 +34,82 @@ class FileCaptionWidget extends StatefulWidget {
class _FileCaptionWidgetState extends State<FileCaptionWidget> {
static const int maxLength = 5000;
- // counterThreshold represents the nun of char after which
- // currentLength/maxLength will show up
- static const int counterThreshold = 1000;
- int currentLength = 0;
-
final _textController = TextEditingController();
final _focusNode = FocusNode();
String? editedCaption;
late String defaultHintText = AppLocalizations.of(
context,
).fileInfoAddDescHint;
- String hintText = '';
- Widget? keyboardTopButtons;
@override
void initState() {
super.initState();
- _focusNode.addListener(_focusNodeListener);
editedCaption = widget.file.caption;
if (editedCaption != null && editedCaption!.isNotEmpty) {
- hintText = editedCaption!;
+ _textController.text = editedCaption!;
}
}
@override
void dispose() {
- if (editedCaption != null) {
- editFileCaption(
- null,
- widget.file,
- editedCaption!,
- ).then((isSuccess) => _onEditFileFinish(isSuccess));
- }
_textController.dispose();
- _focusNode.removeListener(_focusNodeListener);
+ _focusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
- if (hintText.isEmpty) {
- hintText = defaultHintText;
- }
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- return TextField(
- onSubmitted: (value) async {
- await _onDoneClick(context);
- },
- controller: _textController,
- focusNode: _focusNode,
- decoration: InputDecoration(
- counterStyle: textTheme.mini.copyWith(color: colorScheme.textMuted),
- counterText: currentLength >= counterThreshold
- ? currentLength.toString() + " / " + maxLength.toString()
- : "",
- contentPadding: const EdgeInsets.all(16),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(2),
- borderSide: const BorderSide(width: 0, style: BorderStyle.none),
+ return Row(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ Expanded(
+ child: TextInputComponent(
+ controller: _textController,
+ focusNode: _focusNode,
+ hintText: defaultHintText,
+ maxLength: maxLength,
+ minLines: 1,
+ maxLines: 10,
+ textCapitalization: TextCapitalization.sentences,
+ keyboardType: TextInputType.multiline,
+ onChanged: (value) {
+ setState(() {
+ editedCaption = value;
+ });
+ },
+ ),
),
- focusedBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(2),
- borderSide: const BorderSide(width: 0, style: BorderStyle.none),
+ const SizedBox(width: Spacing.sm),
+ IconButtonComponent(
+ variant: IconButtonComponentVariant.green,
+ tooltip: AppLocalizations.of(context).done,
+ icon: const HugeIcon(icon: HugeIcons.strokeRoundedTick02),
+ onTap: _hasPendingCaptionEdit ? onDoneTap : null,
),
- filled: true,
- fillColor: colorScheme.fillFaint,
- hintText: hintText,
- hintStyle: hintText == defaultHintText
- ? textTheme.miniMuted
- : textTheme.mini,
- ),
- style: textTheme.mini,
- cursorWidth: 1.5,
- maxLength: maxLength,
- minLines: 1,
- maxLines: 10,
- textCapitalization: TextCapitalization.sentences,
- keyboardType: TextInputType.multiline,
- onChanged: (value) {
- setState(() {
- hintText = defaultHintText;
- currentLength = value.length;
- editedCaption = value;
- });
- },
+ ],
);
}
Future<void> _onDoneClick(BuildContext context) async {
- if (editedCaption != null) {
+ if (_hasPendingCaptionEdit) {
final isSuccesful = await editFileCaption(
context,
widget.file,
editedCaption!,
).then((isSuccess) => _onEditFileFinish(isSuccess));
- if (isSuccesful) {
- if (mounted) {
- if (!context.mounted) return;
- Navigator.pop(context);
- }
+ if (isSuccesful && mounted) {
+ setState(() {});
}
}
}
- void onCancelTap() {
- _textController.text = widget.file.caption ?? '';
- _focusNode.unfocus();
- editedCaption = null;
- }
-
void onDoneTap() {
_focusNode.unfocus();
_onDoneClick(context);
}
- void _focusNodeListener() {
- final caption = widget.file.caption;
- if (_focusNode.hasFocus && caption != null) {
- _textController.text = caption;
- editedCaption = caption;
- }
- final bool hasFocus = _focusNode.hasFocus;
- keyboardTopButtons ??= KeyboardTopButton(
- onDoneTap: onDoneTap,
- onCancelTap: onCancelTap,
- );
- if (hasFocus) {
- KeyboardOverlay.showOverlay(context, keyboardTopButtons!);
- } else {
- KeyboardOverlay.removeOverlay();
- }
- }
+ bool get _hasPendingCaptionEdit =>
+ editedCaption != null && editedCaption != (widget.file.caption ?? '');
bool _onEditFileFinish(bool isSuccess) {
if (!mounted) {
diff --git a/mobile/apps/photos/lib/ui/viewer/file_details/exif_item_widgets.dart b/mobile/apps/photos/lib/ui/viewer/file_details/exif_item_widgets.dart
index a5ba6548a8..03cb2877a2 100644
--- a/mobile/apps/photos/lib/ui/viewer/file_details/exif_item_widgets.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file_details/exif_item_widgets.dart
@@ -65,6 +65,7 @@ class _AllExifItemWidgetState extends State<AllExifItemWidget> {
title: AppLocalizations.of(context).exif,
subtitleSection: _exifButton(context, widget.file, widget.exif),
onTap: _onTap,
+ useMenuStyle: true,
);
}
diff --git a/mobile/apps/photos/lib/ui/viewer/file_details/video_exif_item.dart b/mobile/apps/photos/lib/ui/viewer/file_details/video_exif_item.dart
index 58f1b7334b..e4aaf83f8c 100644
--- a/mobile/apps/photos/lib/ui/viewer/file_details/video_exif_item.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file_details/video_exif_item.dart
@@ -34,6 +34,7 @@ class _VideoProbeInfoState extends State<VideoExifRowItem> {
title: AppLocalizations.of(context).videoInfo,
subtitleSection: _exifButton(context, widget.file, widget.props),
onTap: _onTap,
+ useMenuStyle: true,
);
}