From bb86e39d6084d64446a5743e9e9e99752ff376dc Mon Sep 17 00:00:00 2001 From: danemadsen Date: Sun, 12 May 2024 20:12:35 +1000 Subject: [PATCH] small ui changes --- lib/static/utilities.dart | 5 +++ .../character_customization_page.dart | 33 ++++++------------- .../widgets/tiles/text_field_list_tile.dart | 29 +++++++--------- 3 files changed, 27 insertions(+), 40 deletions(-) diff --git a/lib/static/utilities.dart b/lib/static/utilities.dart index 28513250..d635d56b 100644 --- a/lib/static/utilities.dart +++ b/lib/static/utilities.dart @@ -60,4 +60,9 @@ class Utilities { return File(path)..writeAsBytesSync(buffer); } + + static String capitalizeFirst(String word) { + if (word.isEmpty) return word; + return word[0].toUpperCase() + word.substring(1).toLowerCase(); + } } \ No newline at end of file diff --git a/lib/ui/mobile/pages/character/character_customization_page.dart b/lib/ui/mobile/pages/character/character_customization_page.dart index ecb600a0..9ed8be6c 100644 --- a/lib/ui/mobile/pages/character/character_customization_page.dart +++ b/lib/ui/mobile/pages/character/character_customization_page.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:maid/providers/character.dart'; +import 'package:maid/static/utilities.dart'; import 'package:maid/ui/mobile/pages/character/character_browser_page.dart'; import 'package:maid/ui/mobile/widgets/appbars/generic_app_bar.dart'; import 'package:maid/ui/mobile/widgets/dialogs.dart'; @@ -244,28 +245,14 @@ class _CharacterCustomizationPageState extends State endIndent: 10, color: Theme.of(context).colorScheme.primary, ), - ListTile( - title: Row( - children: [ - const Expanded( - child: Text("Name"), - ), - Expanded( - flex: 2, - child: TextField( - cursorColor: - Theme.of(context).colorScheme.secondary, - decoration: const InputDecoration( - labelText: "Name", - ), - controller: nameController, - onChanged: (value) { - character.name = value; - }, - ), - ), - ], - ), + TextFieldListTile( + headingText: 'Name', + labelText: 'Name', + controller: nameController, + onChanged: (value) { + character.name = value; + }, + multiline: false, ), TextFieldListTile( headingText: 'Description', @@ -427,7 +414,7 @@ class _CharacterCustomizationPageState extends State for (int i = 0; i < character.examples.length; i++) TextFieldListTile( headingText: - '${character.examples[i]["role"]} content', + '${Utilities.capitalizeFirst(character.examples[i]["role"])} Content', labelText: character.examples[i]["role"], controller: exampleControllers[i], onChanged: (value) { diff --git a/lib/ui/mobile/widgets/tiles/text_field_list_tile.dart b/lib/ui/mobile/widgets/tiles/text_field_list_tile.dart index fd2ded0b..4f0e8060 100644 --- a/lib/ui/mobile/widgets/tiles/text_field_list_tile.dart +++ b/lib/ui/mobile/widgets/tiles/text_field_list_tile.dart @@ -22,25 +22,20 @@ class TextFieldListTile extends StatelessWidget{ @override Widget build(BuildContext context) { return ListTile( - title: Row( + title: Column( children: [ - Expanded( - child: Text(headingText), - ), - Expanded( - flex: 2, - child: TextField( - keyboardType: multiline ? TextInputType.multiline : TextInputType.text, - maxLines: multiline ? null : 1, - cursorColor: Theme.of(context).colorScheme.secondary, - controller: controller ?? TextEditingController(text: initialValue), - decoration: InputDecoration( - labelText: labelText, - ), - onSubmitted: onSubmitted, - onChanged: onChanged, + Text(headingText), + TextField( + keyboardType: multiline ? TextInputType.multiline : TextInputType.text, + maxLines: multiline ? null : 1, + cursorColor: Theme.of(context).colorScheme.secondary, + controller: controller ?? TextEditingController(text: initialValue), + decoration: InputDecoration( + labelText: labelText, ), - ), + onSubmitted: onSubmitted, + onChanged: onChanged, + ) ], ), );