fix: padding issues (#47)

## Pull Request Description

This fixes a bunch of padding issues, and also improves padding in other
areas.

Issue Number: #29

---------

Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
PartyDonut 2024-10-19 15:25:32 +02:00 committed by GitHub
parent f5343be4e7
commit 6669a06e53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 926 additions and 877 deletions

View file

@ -1,14 +1,16 @@
import 'package:ficonsax/ficonsax.dart';
import 'package:fladder/providers/collections_provider.dart';
import 'package:fladder/screens/shared/adaptive_dialog.dart';
import 'package:fladder/screens/shared/fladder_snackbar.dart';
import 'package:fladder/util/localization_helper.dart';
import 'package:fladder/widgets/shared/modal_bottom_sheet.dart';
import 'package:flutter/material.dart';
import 'package:ficonsax/ficonsax.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:fladder/models/item_base_model.dart';
import 'package:fladder/providers/collections_provider.dart';
import 'package:fladder/screens/shared/adaptive_dialog.dart';
import 'package:fladder/screens/shared/fladder_snackbar.dart';
import 'package:fladder/screens/shared/outlined_text_field.dart';
import 'package:fladder/util/localization_helper.dart';
import 'package:fladder/widgets/shared/alert_content.dart';
import 'package:fladder/widgets/shared/modal_bottom_sheet.dart';
Future<void> addItemToCollection(BuildContext context, List<ItemBaseModel> item) {
return showDialogAdaptive(
@ -40,71 +42,62 @@ class _AddToCollectionState extends ConsumerState<AddToCollection> {
@override
Widget build(BuildContext context) {
final collectonOptions = ref.watch(provider);
return Card(
color: Theme.of(context).colorScheme.surface,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: MediaQuery.paddingOf(context).top),
Container(
color: Theme.of(context).colorScheme.surface,
child: Column(
return ActionContent(
title: Container(
color: Theme.of(context).colorScheme.surface,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (widget.items.length == 1)
Text(
'Add to collection',
style: Theme.of(context).textTheme.titleLarge,
)
else
Text(
'Add ${widget.items.length} item(s) to collection',
style: Theme.of(context).textTheme.titleLarge,
),
IconButton(
onPressed: () => ref.read(provider.notifier).setItems(widget.items),
icon: const Icon(IconsaxOutline.refresh),
)
],
if (widget.items.length == 1)
Text(
'Add to collection',
style: Theme.of(context).textTheme.titleLarge,
)
else
Text(
'Add ${widget.items.length} item(s) to collection',
style: Theme.of(context).textTheme.titleLarge,
),
),
if (widget.items.length == 1) ItemBottomSheetPreview(item: widget.items.first),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Row(
children: [
Flexible(
child: OutlinedTextField(
label: 'New collection',
controller: controller,
onChanged: (value) => setState(() {}),
),
),
const SizedBox(width: 32),
IconButton(
onPressed: controller.text.isNotEmpty
? () async {
await ref.read(provider.notifier).addToNewCollection(
name: controller.text,
);
setState(() => controller.text = '');
}
: null,
icon: const Icon(Icons.add_rounded)),
const SizedBox(width: 4),
onPressed: () => ref.read(provider.notifier).setItems(widget.items),
icon: const Icon(IconsaxOutline.refresh),
)
],
),
if (widget.items.length == 1) ItemBottomSheetPreview(item: widget.items.first),
],
),
),
child: Column(
children: [
Row(
children: [
Flexible(
child: OutlinedTextField(
label: 'New collection',
controller: controller,
onChanged: (value) => setState(() {}),
),
),
const SizedBox(width: 32),
IconButton(
onPressed: controller.text.isNotEmpty
? () async {
await ref.read(provider.notifier).addToNewCollection(
name: controller.text,
);
setState(() => controller.text = '');
}
: null,
icon: const Icon(Icons.add_rounded)),
],
),
Flexible(
child: ListView(
shrinkWrap: true,
padding: const EdgeInsets.symmetric(vertical: 12),
children: [
...collectonOptions.collections.entries.map(
(e) {
@ -125,25 +118,37 @@ class _AddToCollectionState extends ConsumerState<AddToCollection> {
},
);
} else {
return ListTile(
title: Text(e.key.name),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton(
onPressed: () async {
final response =
await ref.read(provider.notifier).addToCollection(boxSet: e.key, add: true);
if (context.mounted) {
fladderSnackbar(context,
title: response.isSuccessful
? "Added to ${e.key.name} collection"
: 'Unable to add to ${e.key.name} collection - (${response.statusCode}) - ${response.base.reasonPhrase}');
}
},
child: Icon(Icons.add_rounded, color: Theme.of(context).colorScheme.primary),
return Container(
margin: const EdgeInsets.all(8),
child: Card(
elevation: 0,
child: Padding(
padding: const EdgeInsets.all(8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: Text(
e.key.name,
style: Theme.of(context).textTheme.bodyLarge,
),
),
ElevatedButton(
onPressed: () async {
final response =
await ref.read(provider.notifier).addToCollection(boxSet: e.key, add: true);
if (context.mounted) {
fladderSnackbar(context,
title: response.isSuccessful
? "Added to ${e.key.name} collection"
: 'Unable to add to ${e.key.name} collection - (${response.statusCode}) - ${response.base.reasonPhrase}');
}
},
child: Icon(Icons.add_rounded, color: Theme.of(context).colorScheme.primary),
),
],
),
],
),
),
);
}
@ -152,23 +157,14 @@ class _AddToCollectionState extends ConsumerState<AddToCollection> {
],
),
),
Container(
color: Theme.of(context).colorScheme.surface,
child: Padding(
padding: const EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FilledButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(context.localized.close),
)
],
),
),
),
],
),
actions: [
FilledButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(context.localized.close),
)
],
);
}
}