Skip to content

Commit

Permalink
Multi-line texts on items + better icon padding / click
Browse files Browse the repository at this point in the history
  • Loading branch information
gruvw committed Nov 25, 2023
1 parent ec9246d commit 5aed4e5
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/global/styles/layouts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class ButtonLayout {
abstract class TextInputLayout {
static const borderWidth = 2.0;

static const contentVerticalPadding = 2.0;
static const contentVerticalPadding = 8.0;
static const contentHorizontalPadding = 10.0;

static const errorMaxLines = 10;
Expand Down
39 changes: 21 additions & 18 deletions lib/widgets/collections/collection_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,16 @@ class CollectionEntry extends StatelessWidget {
if (leading != null)
Column(
children: [
IconButton(
color: UIColors.primary,
disabledColor: UIColors.primary,
onPressed: leadingOnClick,
icon: leading!,
style: IconButton.styleFrom(
// Reset material padding and boxes
padding: const EdgeInsets.only(
right: CollectionLayout.contentHorizontalPadding,
InkWell(
onTap: leadingOnClick,
child: Padding(
padding: const EdgeInsets.fromLTRB(
0,
CollectionLayout.contentVerticalPadding,
CollectionLayout.contentHorizontalPadding,
CollectionLayout.contentVerticalPadding,
),
minimumSize: Size.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
child: leading!,
),
),
],
Expand All @@ -68,12 +66,18 @@ class CollectionEntry extends StatelessWidget {
child: InkWell(
hoverColor: UIColors.none,
onTap: onClick,
child: Text(
this.content,
overflow: wrap ? null : TextOverflow.ellipsis,
style: UITexts.normalText.copyWith(
fontWeight: isFat ? FontWeight.w600 : FontWeight.normal,
color: reversed ? UIColors.secondary : UIColors.primary,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: CollectionLayout.contentVerticalPadding,
),
child: Text(
this.content,
maxLines: wrap ? null : 1,
overflow: wrap ? null : TextOverflow.ellipsis,
style: UITexts.normalText.copyWith(
fontWeight: isFat ? FontWeight.w600 : FontWeight.normal,
color: reversed ? UIColors.secondary : UIColors.primary,
),
),
),
),
Expand Down Expand Up @@ -113,7 +117,6 @@ class CollectionEntry extends StatelessWidget {
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: CollectionLayout.contentVerticalPadding,
horizontal: CollectionLayout.contentHorizontalPadding,
),
child: content,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class CollectionPage extends ConsumerWidget {
builder: (_) => TextDialog(
title: "New Item Text",
submitText: "Create",
wrap: true,
capitalization: TextCapitalization.sentences,
placeholder: UIPlaceholders.itemText,
validation: validItemText,
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/collections/dialogs/edit_item_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class EditItemTextDialog extends ConsumerWidget {
return TextDialog(
title: "Edit Item Text",
submitText: "Edit",
wrap: true,
capitalization: TextCapitalization.sentences,
placeholder: UIPlaceholders.itemText,
initialValue: item.text,
Expand Down
3 changes: 3 additions & 0 deletions lib/widgets/components/input/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class TextInput extends HookWidget {
final bool? obscureText;
final TextCapitalization? capitalization;
final bool autoFocus;
final bool wrap;
final void Function(String value)? onChanged;

const TextInput({
Expand All @@ -25,6 +26,7 @@ class TextInput extends HookWidget {
this.obscureText,
this.onChanged,
this.capitalization,
this.wrap = false,
this.autoFocus = false,
});

Expand Down Expand Up @@ -75,6 +77,7 @@ class TextInput extends HookWidget {
style: UITexts.normalText,
cursorColor: UIColors.primary,
onChanged: onChanged,
maxLines: wrap ? null : 1,
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(
vertical: TextInputLayout.contentVerticalPadding,
Expand Down
3 changes: 3 additions & 0 deletions lib/widgets/components/modals/text_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class TextDialog extends HookWidget {
final String? submitText;
final String? cancelText;
final TextCapitalization? capitalization;
final bool wrap;

const TextDialog({
super.key,
Expand All @@ -30,6 +31,7 @@ class TextDialog extends HookWidget {
this.submitText,
this.cancelText,
this.capitalization,
this.wrap = false,
});

@override
Expand Down Expand Up @@ -59,6 +61,7 @@ class TextDialog extends HookWidget {
},
body: TextInput(
autoFocus: true,
wrap: wrap,
controller: offlineNameController,
placeholder: placeholder,
label: inputLabel,
Expand Down

0 comments on commit 5aed4e5

Please sign in to comment.