Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix keyboard issues

laurenspriemce396e6eb2c6
diff --git a/mobile/apps/photos/lib/ui/activity/rituals_section.dart b/mobile/apps/photos/lib/ui/activity/rituals_section.dart
index 24ec90fe54..6b55956340 100644
--- a/mobile/apps/photos/lib/ui/activity/rituals_section.dart
+++ b/mobile/apps/photos/lib/ui/activity/rituals_section.dart
@@ -302,234 +302,200 @@ Future<void> _showRitualEditor(BuildContext context, {Ritual? ritual}) async {
barrierDismissible: true,
transitionDuration: const Duration(milliseconds: 240),
pageBuilder: (dialogContext, animation, secondaryAnimation) {
+ final mediaQuery = MediaQuery.of(dialogContext);
final colorScheme = getEnteColorScheme(dialogContext);
final textTheme = getEnteTextTheme(dialogContext);
- final bottomPadding = MediaQuery.of(dialogContext).padding.bottom;
- final maxHeight = MediaQuery.of(dialogContext).size.height * 0.95;
- return SafeArea(
- top: false,
- child: Align(
- alignment: Alignment.bottomCenter,
- child: ConstrainedBox(
- constraints: BoxConstraints(maxHeight: maxHeight),
- child: Padding(
- padding: EdgeInsets.fromLTRB(12, 8, 12, bottomPadding + 16),
- child: Material(
- color: Colors.transparent,
- child: StatefulBuilder(
- builder: (context, setState) {
- final bool canSave = controller.text.trim().isNotEmpty &&
- selectedAlbumId != null;
- final bool allDaysOff = days.every((selected) => !selected);
- return Container(
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated,
- borderRadius: BorderRadius.circular(24),
- boxShadow: [
- BoxShadow(
- color: Colors.black.withValues(alpha: 0.06),
- blurRadius: 22,
- offset: const Offset(0, 12),
- ),
- ],
- ),
- child: SingleChildScrollView(
- padding: const EdgeInsets.fromLTRB(20, 16, 20, 20),
- child: Form(
- key: formKey,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Text(
- ritual == null
- ? "New ritual"
- : "Edit ritual",
- style: textTheme.largeBold,
- ),
- const Spacer(),
- IconButton(
- icon: const Icon(Icons.close),
- onPressed: () =>
- Navigator.of(context).pop(),
- ),
- ],
- ),
- const SizedBox(height: 12),
- Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Stack(
- clipBehavior: Clip.none,
- children: [
- Container(
- width: 70,
- height: 70,
- decoration: BoxDecoration(
- color: colorScheme.fillFaintPressed,
- shape: BoxShape.circle,
- ),
- child: Center(
- child: Text(
- selectedEmoji,
- style:
- const TextStyle(fontSize: 32),
+ final bottomPadding = mediaQuery.viewPadding.bottom;
+ final maxHeight = mediaQuery.size.height * 0.95;
+ return MediaQuery.removeViewInsets(
+ context: dialogContext,
+ removeBottom: true,
+ child: SafeArea(
+ top: false,
+ bottom: false,
+ child: Align(
+ alignment: Alignment.bottomCenter,
+ child: ConstrainedBox(
+ constraints: BoxConstraints(maxHeight: maxHeight),
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(12, 8, 12, bottomPadding + 16),
+ child: Material(
+ color: Colors.transparent,
+ child: StatefulBuilder(
+ builder: (context, setState) {
+ final bool canSave = controller.text.trim().isNotEmpty &&
+ selectedAlbumId != null;
+ final bool allDaysOff =
+ days.every((selected) => !selected);
+ return Container(
+ decoration: BoxDecoration(
+ color: colorScheme.backgroundElevated,
+ borderRadius: BorderRadius.circular(24),
+ boxShadow: [
+ BoxShadow(
+ color: Colors.black.withValues(alpha: 0.06),
+ blurRadius: 22,
+ offset: const Offset(0, 12),
+ ),
+ ],
+ ),
+ child: SingleChildScrollView(
+ padding: const EdgeInsets.fromLTRB(20, 16, 20, 20),
+ child: Form(
+ key: formKey,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ children: [
+ Text(
+ ritual == null
+ ? "New ritual"
+ : "Edit ritual",
+ style: textTheme.largeBold,
+ ),
+ const Spacer(),
+ IconButton(
+ icon: const Icon(Icons.close),
+ onPressed: () =>
+ Navigator.of(context).pop(),
+ ),
+ ],
+ ),
+ const SizedBox(height: 12),
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Container(
+ width: 70,
+ height: 70,
+ decoration: BoxDecoration(
+ color: colorScheme.fillFaintPressed,
+ shape: BoxShape.circle,
+ ),
+ child: Center(
+ child: Text(
+ selectedEmoji,
+ style:
+ const TextStyle(fontSize: 32),
+ ),
),
),
- ),
- Positioned(
- right: -4,
- bottom: -4,
- child: Material(
- color: colorScheme.backgroundElevated,
- shape: const CircleBorder(),
- elevation: 2,
- child: InkWell(
- customBorder: const CircleBorder(),
- onTap: () async {
- final emoji = await _pickEmoji(
- context,
- selectedEmoji,
- );
- if (emoji != null) {
- setState(() {
- selectedEmoji = emoji;
- });
- }
- },
- child: const Padding(
- padding: EdgeInsets.all(6),
- child: Icon(
- Icons.edit_outlined,
- size: 18,
+ Positioned(
+ right: -4,
+ bottom: -4,
+ child: Material(
+ color:
+ colorScheme.backgroundElevated,
+ shape: const CircleBorder(),
+ elevation: 2,
+ child: InkWell(
+ customBorder:
+ const CircleBorder(),
+ onTap: () async {
+ final emoji = await _pickEmoji(
+ context,
+ selectedEmoji,
+ );
+ if (emoji != null) {
+ setState(() {
+ selectedEmoji = emoji;
+ });
+ }
+ },
+ child: const Padding(
+ padding: EdgeInsets.all(6),
+ child: Icon(
+ Icons.edit_outlined,
+ size: 18,
+ ),
),
),
),
),
- ),
- ],
- ),
- const SizedBox(width: 12),
- Expanded(
- child: TextFormField(
- controller: controller,
- autofocus: true,
- onChanged: (_) => setState(() {}),
- decoration: InputDecoration(
- hintText: "Enter your ritual",
- filled: true,
- fillColor: colorScheme.fillFaint,
- contentPadding:
- const EdgeInsets.symmetric(
- horizontal: 14,
- vertical: 14,
- ),
- border: OutlineInputBorder(
- borderRadius:
- BorderRadius.circular(18),
- borderSide: BorderSide.none,
- ),
- enabledBorder: OutlineInputBorder(
- borderRadius:
- BorderRadius.circular(18),
- borderSide: BorderSide.none,
- ),
- focusedBorder: OutlineInputBorder(
- borderRadius:
- BorderRadius.circular(18),
- borderSide: BorderSide.none,
+ ],
+ ),
+ const SizedBox(width: 12),
+ Expanded(
+ child: TextFormField(
+ controller: controller,
+ autofocus: true,
+ textCapitalization:
+ TextCapitalization.sentences,
+ onChanged: (_) => setState(() {}),
+ decoration: InputDecoration(
+ hintText: "Enter your ritual",
+ filled: true,
+ fillColor: colorScheme.fillFaint,
+ contentPadding:
+ const EdgeInsets.symmetric(
+ horizontal: 14,
+ vertical: 14,
+ ),
+ border: OutlineInputBorder(
+ borderRadius:
+ BorderRadius.circular(18),
+ borderSide: BorderSide.none,
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderRadius:
+ BorderRadius.circular(18),
+ borderSide: BorderSide.none,
+ ),
+ focusedBorder: OutlineInputBorder(
+ borderRadius:
+ BorderRadius.circular(18),
+ borderSide: BorderSide.none,
+ ),
),
+ validator: (value) {
+ if (value == null ||
+ value.trim().isEmpty) {
+ return "Please enter a description";
+ }
+ return null;
+ },
),
- validator: (value) {
- if (value == null ||
- value.trim().isEmpty) {
- return "Please enter a description";
- }
- return null;
- },
),
- ),
- ],
- ),
- const SizedBox(height: 20),
- _sectionLabel(context, "Day"),
- const SizedBox(height: 8),
- Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 10,
- vertical: 10,
- ),
- decoration: BoxDecoration(
- color: colorScheme.fillFaint,
- borderRadius: BorderRadius.circular(18),
- ),
- child: Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
- children: List.generate(
- days.length,
- (index) => _DayCircle(
- label: _weekLabel(index),
- selected: days[index],
- colorScheme: colorScheme,
- onTap: () {
- setState(() {
- days[index] = !days[index];
- });
- },
- ),
- ),
+ ],
),
- ),
- const SizedBox(height: 16),
- if (allDaysOff)
+ const SizedBox(height: 20),
+ _sectionLabel(context, "Day"),
+ const SizedBox(height: 8),
Container(
padding: const EdgeInsets.symmetric(
- horizontal: 14,
- vertical: 14,
+ horizontal: 10,
+ vertical: 10,
),
decoration: BoxDecoration(
color: colorScheme.fillFaint,
borderRadius: BorderRadius.circular(18),
),
child: Row(
- crossAxisAlignment:
- CrossAxisAlignment.start,
- children: [
- Icon(
- Icons.notifications_off_outlined,
- color: colorScheme.textMuted,
+ mainAxisAlignment:
+ MainAxisAlignment.spaceBetween,
+ children: List.generate(
+ days.length,
+ (index) => _DayCircle(
+ label: _weekLabel(index),
+ selected: days[index],
+ colorScheme: colorScheme,
+ onTap: () {
+ setState(() {
+ days[index] = !days[index];
+ });
+ },
),
- const SizedBox(width: 10),
- Expanded(
- child: Text(
- "Notifications are off. Tap a day to turn them on.",
- style: textTheme.small.copyWith(
- color: colorScheme.textMuted,
- ),
- ),
- ),
- ],
+ ),
),
- )
- else ...[
- _sectionLabel(context, "Time"),
- const SizedBox(height: 8),
- GestureDetector(
- onTap: () async {
- final result = await showTimePicker(
- context: context,
- initialTime: selectedTime,
- );
- if (result != null) {
- setState(() {
- selectedTime = result;
- });
- }
- },
- child: Container(
+ ),
+ const SizedBox(height: 16),
+ if (allDaysOff)
+ Container(
padding: const EdgeInsets.symmetric(
horizontal: 14,
vertical: 14,
@@ -539,96 +505,142 @@ Future<void> _showRitualEditor(BuildContext context, {Ritual? ritual}) async {
borderRadius: BorderRadius.circular(18),
),
child: Row(
+ crossAxisAlignment:
+ CrossAxisAlignment.start,
children: [
+ Icon(
+ Icons.notifications_off_outlined,
+ color: colorScheme.textMuted,
+ ),
+ const SizedBox(width: 10),
Expanded(
child: Text(
- selectedTime.format(context),
- style: textTheme.h3Bold,
+ "Notifications are off. Tap a day to turn them on.",
+ style: textTheme.small.copyWith(
+ color: colorScheme.textMuted,
+ ),
),
),
- Container(
- padding: const EdgeInsets.all(10),
- decoration: BoxDecoration(
- color:
- colorScheme.backgroundElevated2,
- borderRadius:
- BorderRadius.circular(12),
+ ],
+ ),
+ )
+ else ...[
+ _sectionLabel(context, "Time"),
+ const SizedBox(height: 8),
+ GestureDetector(
+ onTap: () async {
+ final result = await showTimePicker(
+ context: context,
+ initialTime: selectedTime,
+ );
+ if (result != null) {
+ setState(() {
+ selectedTime = result;
+ });
+ }
+ },
+ child: Container(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 14,
+ vertical: 14,
+ ),
+ decoration: BoxDecoration(
+ color: colorScheme.fillFaint,
+ borderRadius: BorderRadius.circular(18),
+ ),
+ child: Row(
+ children: [
+ Expanded(
+ child: Text(
+ selectedTime.format(context),
+ style: textTheme.h3Bold,
+ ),
),
- child: Icon(
- Icons.schedule,
- color: colorScheme.textMuted,
+ Container(
+ padding: const EdgeInsets.all(10),
+ decoration: BoxDecoration(
+ color: colorScheme
+ .backgroundElevated2,
+ borderRadius:
+ BorderRadius.circular(12),
+ ),
+ child: Icon(
+ Icons.schedule,
+ color: colorScheme.textMuted,
+ ),
),
- ),
- ],
+ ],
+ ),
),
),
+ ],
+ const SizedBox(height: 16),
+ _sectionLabel(context, "Album"),
+ const SizedBox(height: 8),
+ GestureDetector(
+ onTap: () async {
+ final result = await _pickAlbum(context);
+ if (result != null) {
+ setState(() {
+ selectedAlbum = result;
+ selectedAlbumId = result.id;
+ selectedAlbumName = result.displayName;
+ });
+ }
+ },
+ child: _AlbumPreviewTile(
+ album: selectedAlbum,
+ fallbackName: selectedAlbumName,
+ ),
),
- ],
- const SizedBox(height: 16),
- _sectionLabel(context, "Album"),
- const SizedBox(height: 8),
- GestureDetector(
- onTap: () async {
- final result = await _pickAlbum(context);
- if (result != null) {
- setState(() {
- selectedAlbum = result;
- selectedAlbumId = result.id;
- selectedAlbumName = result.displayName;
- });
- }
- },
- child: _AlbumPreviewTile(
- album: selectedAlbum,
- fallbackName: selectedAlbumName,
- ),
- ),
- const SizedBox(height: 20),
- SizedBox(
- width: double.infinity,
- child: ElevatedButton(
- style: ElevatedButton.styleFrom(
- backgroundColor: canSave
- ? colorScheme.primary500
- : colorScheme.fillMuted,
- padding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 14,
+ const SizedBox(height: 20),
+ SizedBox(
+ width: double.infinity,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ backgroundColor: canSave
+ ? colorScheme.primary500
+ : colorScheme.fillMuted,
+ padding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 14,
+ ),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(18),
+ ),
),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(18),
+ onPressed: () async {
+ if (!canSave) return;
+ final updated = (ritual ??
+ activityService
+ .createEmptyRitual())
+ .copyWith(
+ title: controller.text.trim(),
+ daysOfWeek: days,
+ timeOfDay: selectedTime,
+ albumId: selectedAlbumId,
+ albumName: selectedAlbumName,
+ icon: selectedEmoji,
+ );
+ await activityService.saveRitual(updated);
+ Navigator.of(context).pop();
+ },
+ child: Text(
+ ritual == null
+ ? "Save ritual"
+ : "Update ritual",
+ style: textTheme.bodyBold
+ .copyWith(color: Colors.white),
),
),
- onPressed: () async {
- if (!canSave) return;
- final updated = (ritual ??
- activityService.createEmptyRitual())
- .copyWith(
- title: controller.text.trim(),
- daysOfWeek: days,
- timeOfDay: selectedTime,
- albumId: selectedAlbumId,
- albumName: selectedAlbumName,
- icon: selectedEmoji,
- );
- await activityService.saveRitual(updated);
- Navigator.of(context).pop();
- },
- child: Text(
- ritual == null
- ? "Save ritual"
- : "Update ritual",
- style: textTheme.bodyBold
- .copyWith(color: Colors.white),
- ),
),
- ),
- ],
+ ],
+ ),
),
),
- ),
- );
- },
+ );
+ },
+ ),
),
),
),
@@ -659,188 +671,231 @@ String _weekLabel(int index) {
}
Future<Collection?> _pickAlbum(BuildContext context) async {
- final service = CollectionsService.instance;
final albums = List<Collection>.from(
await CollectionsService.instance.getCollectionsForRituals(),
);
Collection? selected;
+
await showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- final controller = TextEditingController();
- return StatefulBuilder(
- builder: (context, setState) {
- final trimmedQuery = controller.text.trim();
- final bool canCreateAlbum = trimmedQuery.isNotEmpty;
- final queryLower = trimmedQuery.toLowerCase();
- final filteredAlbums = queryLower.isEmpty
- ? albums
- : albums
- .where(
- (album) =>
- album.displayName.toLowerCase().contains(queryLower),
- )
- .toList();
- Future<void> createAlbum() async {
- final trimmed = controller.text.trim();
- if (trimmed.isEmpty) return;
- final created = await service.createAlbum(trimmed);
- if (!context.mounted) return;
- selected = created;
- Navigator.of(context).pop();
- }
+ return _AlbumPickerSheet(
+ albums: albums,
+ onSelected: (collection) => selected = collection,
+ );
+ },
+ );
- return SafeArea(
- child: Padding(
- padding: EdgeInsets.only(
- left: 12,
- right: 12,
- bottom: MediaQuery.of(context).viewInsets.bottom + 16,
- top: 8,
- ),
- child: Container(
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated,
- borderRadius: BorderRadius.circular(20),
- boxShadow: [
- BoxShadow(
- color: Colors.black.withValues(alpha: 0.06),
- blurRadius: 18,
- offset: const Offset(0, 10),
- ),
- ],
+ return selected;
+}
+
+class _AlbumPickerSheet extends StatefulWidget {
+ const _AlbumPickerSheet({
+ required this.albums,
+ required this.onSelected,
+ });
+
+ final List<Collection> albums;
+ final ValueChanged<Collection?> onSelected;
+
+ @override
+ State<_AlbumPickerSheet> createState() => _AlbumPickerSheetState();
+}
+
+class _AlbumPickerSheetState extends State<_AlbumPickerSheet> {
+ late final TextEditingController _controller;
+ Collection? _selected;
+
+ @override
+ void initState() {
+ super.initState();
+ _controller = TextEditingController();
+ }
+
+ @override
+ void dispose() {
+ _controller.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final service = CollectionsService.instance;
+ final mediaQuery = MediaQuery.of(context);
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final trimmedQuery = _controller.text.trim();
+ final bool canCreateAlbum = trimmedQuery.isNotEmpty;
+ final queryLower = trimmedQuery.toLowerCase();
+ final filteredAlbums = queryLower.isEmpty
+ ? widget.albums
+ : widget.albums
+ .where(
+ (album) => album.displayName.toLowerCase().contains(queryLower),
+ )
+ .toList();
+
+ Future<void> createAlbum() async {
+ final trimmed = _controller.text.trim();
+ if (trimmed.isEmpty) return;
+ final created = await service.createAlbum(trimmed);
+ if (!context.mounted) return;
+ _selected = created;
+ widget.onSelected(created);
+ Navigator.of(context).pop();
+ }
+
+ return MediaQuery.removeViewInsets(
+ context: context,
+ removeBottom: true,
+ child: SafeArea(
+ bottom: false,
+ child: Padding(
+ padding: EdgeInsets.only(
+ left: 12,
+ right: 12,
+ bottom: mediaQuery.viewPadding.bottom + 16,
+ top: 8,
+ ),
+ child: Container(
+ decoration: BoxDecoration(
+ color: colorScheme.backgroundElevated,
+ borderRadius: BorderRadius.circular(20),
+ boxShadow: [
+ BoxShadow(
+ color: Colors.black.withValues(alpha: 0.06),
+ blurRadius: 18,
+ offset: const Offset(0, 10),
),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Padding(
- padding: const EdgeInsets.fromLTRB(16, 14, 8, 0),
- child: Row(
- children: [
- Text(
- "Select album",
- style: textTheme.bodyBold,
- ),
- const Spacer(),
- IconButton(
- icon: const Icon(Icons.close),
- onPressed: () => Navigator.of(context).pop(),
- ),
- ],
+ ],
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 14, 8, 0),
+ child: Row(
+ children: [
+ Text(
+ "Select album",
+ style: textTheme.bodyBold,
),
- ),
- Padding(
- padding: const EdgeInsets.fromLTRB(16, 4, 16, 12),
- child: TextField(
- controller: controller,
- textInputAction: TextInputAction.search,
- decoration: InputDecoration(
- hintText: "Search or create new",
- prefixIcon: const Icon(Icons.search_rounded),
- filled: true,
- fillColor: colorScheme.fillFaint,
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(14),
- borderSide: BorderSide(
- color: colorScheme.strokeFaint,
- ),
- ),
- enabledBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(14),
- borderSide: BorderSide(
- color: colorScheme.strokeFaint,
- ),
- ),
+ const Spacer(),
+ IconButton(
+ icon: const Icon(Icons.close),
+ onPressed: () => Navigator.of(context).pop(),
+ ),
+ ],
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 4, 16, 12),
+ child: TextField(
+ controller: _controller,
+ textInputAction: TextInputAction.done,
+ decoration: InputDecoration(
+ hintText: "Search or create new",
+ prefixIcon: const Icon(Icons.search_rounded),
+ filled: true,
+ fillColor: colorScheme.fillFaint,
+ border: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(14),
+ borderSide: BorderSide(
+ color: colorScheme.strokeFaint,
),
- onChanged: (_) => setState(() {}),
- onSubmitted: (_) async => createAlbum(),
),
- ),
- Flexible(
- child: SizedBox(
- height: 360,
- child: filteredAlbums.isEmpty
- ? Center(
- child: Text(
- albums.isEmpty
- ? "No albums yet"
- : "No matching albums",
- style: textTheme.small
- .copyWith(color: colorScheme.textMuted),
- ),
- )
- : ListView.separated(
- padding:
- const EdgeInsets.fromLTRB(16, 0, 16, 16),
- itemBuilder: (context, index) {
- final album = filteredAlbums[index];
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {
- selected = album;
- Navigator.of(context).pop();
- },
- child: AlbumColumnItemWidget(
- album,
- selectedCollections: selected == album
- ? <Collection>[album]
- : const <Collection>[],
- ),
- );
- },
- separatorBuilder: (_, __) =>
- const SizedBox(height: 10),
- itemCount: filteredAlbums.length,
- ),
+ enabledBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(14),
+ borderSide: BorderSide(
+ color: colorScheme.strokeFaint,
+ ),
),
),
- Padding(
- padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
- child: SizedBox(
- width: double.infinity,
- child: ElevatedButton(
- style: ElevatedButton.styleFrom(
- backgroundColor: canCreateAlbum
- ? colorScheme.primary500
- : colorScheme.fillMuted,
- foregroundColor: colorScheme.backgroundBase,
- padding: const EdgeInsets.symmetric(
- horizontal: 14,
- vertical: 14,
- ),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- elevation: 0,
- ),
- onPressed: canCreateAlbum ? createAlbum : null,
- child: Text(
- canCreateAlbum
- ? 'Create "${trimmedQuery.trim()}"'
- : "Create new",
- style: textTheme.bodyBold.copyWith(
- color: canCreateAlbum
- ? Colors.white
- : colorScheme.textMuted,
+ onChanged: (_) => setState(() {}),
+ onSubmitted: (_) => FocusScope.of(context).unfocus(),
+ ),
+ ),
+ Flexible(
+ child: SizedBox(
+ height: 360,
+ child: filteredAlbums.isEmpty
+ ? Center(
+ child: Text(
+ widget.albums.isEmpty
+ ? "No albums yet"
+ : "No matching albums",
+ style: textTheme.small.copyWith(
+ color: colorScheme.textMuted,
+ ),
),
+ )
+ : ListView.separated(
+ padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
+ itemBuilder: (context, index) {
+ final album = filteredAlbums[index];
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () {
+ _selected = album;
+ widget.onSelected(album);
+ Navigator.of(context).pop();
+ },
+ child: AlbumColumnItemWidget(
+ album,
+ selectedCollections: _selected == album
+ ? <Collection>[album]
+ : const <Collection>[],
+ ),
+ );
+ },
+ separatorBuilder: (_, __) =>
+ const SizedBox(height: 10),
+ itemCount: filteredAlbums.length,
),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
+ child: SizedBox(
+ width: double.infinity,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ backgroundColor: canCreateAlbum
+ ? colorScheme.primary500
+ : colorScheme.fillMuted,
+ foregroundColor: colorScheme.backgroundBase,
+ padding: const EdgeInsets.symmetric(
+ horizontal: 14,
+ vertical: 14,
+ ),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(12),
+ ),
+ elevation: 0,
+ ),
+ onPressed: canCreateAlbum ? createAlbum : null,
+ child: Text(
+ canCreateAlbum
+ ? 'Create "${trimmedQuery.trim()}"'
+ : "Create new",
+ style: textTheme.bodyBold.copyWith(
+ color: canCreateAlbum
+ ? Colors.white
+ : colorScheme.textMuted,
),
),
),
- ],
+ ),
),
- ),
+ ],
),
- );
- },
- );
- },
- );
- return selected;
+ ),
+ ),
+ ),
+ );
+ }
}
class _AlbumPreviewTile extends StatelessWidget {