Commit 97dc415
Changed files (4)
lib
components
screens
lib/components/dialoges/add_export_column_dialoge.dart
@@ -95,7 +95,9 @@ class _AddExportColumnDialogeState extends State<AddExportColumnDialoge> with Si
children: [
TextFormField(
initialValue: csvTitle,
- decoration: getInputDecoration(localizations.csvTitle),
+ decoration: InputDecoration(
+ labelText: localizations.csvTitle,
+ ),
validator: (value) => (value != null && value.isNotEmpty) ? null : localizations.errNoValue,
onSaved: (value) => setState(() {csvTitle = value!;}),
),
@@ -181,7 +183,7 @@ class _AddExportColumnDialogeState extends State<AddExportColumnDialoge> with Si
Column _createFormatInput(AppLocalizations localizations,
BuildContext context,
- String inputHint,
+ String labelText,
String inputDocumentation,
String initialValue,
void Function(String) onChanged,
@@ -192,7 +194,8 @@ class _AddExportColumnDialogeState extends State<AddExportColumnDialoge> with Si
TextFormField(
initialValue: initialValue,
onChanged: onChanged,
- decoration: getInputDecoration(inputHint).copyWith(
+ decoration: InputDecoration(
+ labelText: labelText,
suffixIcon: IconButton(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
@@ -209,15 +212,15 @@ class _AddExportColumnDialogeState extends State<AddExportColumnDialoge> with Si
Column _createRecordFormatInput(AppLocalizations localizations, BuildContext context) =>
_createFormatInput(localizations,
- context,
- localizations.fieldFormat,
- localizations.exportFieldFormatDocumentation,
- recordPattern ?? '',
- (value) => setState(() {
- recordPattern = value;
- }),
- (value) => (type == _FormatterType.time || value != null && value.isNotEmpty) ? null
- : localizations.errNoValue
+ context,
+ localizations.fieldFormat,
+ localizations.exportFieldFormatDocumentation,
+ recordPattern ?? '',
+ (value) => setState(() {
+ recordPattern = value;
+ }),
+ (value) => (type == _FormatterType.time || value != null && value.isNotEmpty) ? null
+ : localizations.errNoValue
);
Column _createTimeFormatInput(AppLocalizations localizations, BuildContext context) =>
@@ -233,23 +236,6 @@ class _AddExportColumnDialogeState extends State<AddExportColumnDialoge> with Si
: localizations.errNoValue
);
- InputDecoration getInputDecoration(String? labelText) {
- final border = OutlineInputBorder(
- borderSide: BorderSide(
- width: 3,
- color: Theme.of(context).primaryColor,
- ),
- borderRadius: BorderRadius.circular(20)
- );
- return InputDecoration(
- hintText: labelText,
- labelText: labelText,
- errorMaxLines: 5,
- border: border,
- enabledBorder: border,
- );
- }
-
void _saveForm() {
if (formKey.currentState?.validate() ?? false) {
formKey.currentState!.save();
lib/components/dialoges/add_measurement_dialoge.dart
@@ -145,7 +145,7 @@ class _AddEntryDialogeState extends State<AddEntryDialoge> {
Widget buildValueInput(AppLocalizations localizations, {
int? initialValue,
- String? hintText,
+ String? labelText,
void Function(String?)? onSaved,
FocusNode? focusNode,
TextEditingController? controller,
@@ -155,7 +155,9 @@ class _AddEntryDialogeState extends State<AddEntryDialoge> {
return Expanded(
child: TextFormField(
initialValue: initialValue?.toString(),
- decoration: getInputDecoration(hintText),
+ decoration: InputDecoration(
+ labelText: labelText,
+ ),
keyboardType: TextInputType.number,
focusNode: focusNode,
onSaved: onSaved,
@@ -186,36 +188,18 @@ class _AddEntryDialogeState extends State<AddEntryDialoge> {
);
}
-
- InputDecoration getInputDecoration(String? labelText) {
- final border = OutlineInputBorder(
- borderSide: BorderSide(
- width: 2,
- color: Theme.of(context).primaryColor,
- ),
- borderRadius: BorderRadius.circular(20)
- );
- return InputDecoration(
- hintText: labelText,
- labelText: labelText,
- errorMaxLines: 5,
- border: border,
- enabledBorder: border,
- );
- }
+
/// Build the border all fields have.
RoundedRectangleBorder buildShapeBorder([Color? color]) => RoundedRectangleBorder(
- side: BorderSide(
- width: 2,
- color: color ?? Theme.of(context).primaryColor
- ),
+ side: Theme.of(context).inputDecorationTheme.border!.borderSide,
borderRadius: BorderRadius.circular(20)
);
@override
Widget build(BuildContext context) {
final localizations = AppLocalizations.of(context)!;
+ print(Theme.of(context).inputDecorationTheme.border);
return FullscreenDialoge(
onActionButtonPressed: () {
if (formKey.currentState?.validate() ?? false) {
@@ -253,13 +237,13 @@ class _AddEntryDialogeState extends State<AddEntryDialoge> {
children: [
buildValueInput(localizations,
focusNode: sysFocusNode,
- hintText: localizations.sysLong,
+ labelText: localizations.sysLong,
controller: sysController,
onSaved: (value) => setState(() => systolic = int.tryParse(value ?? '')),
),
const SizedBox(width: 16,),
buildValueInput(localizations,
- hintText: localizations.diaLong,
+ labelText: localizations.diaLong,
initialValue: widget.initialRecord?.diastolic,
onSaved: (value) => setState(() => diastolic = int.tryParse(value ?? '')),
focusNode: diaFocusNode,
@@ -272,7 +256,7 @@ class _AddEntryDialogeState extends State<AddEntryDialoge> {
),
const SizedBox(width: 16,),
buildValueInput(localizations,
- hintText: localizations.pulLong,
+ labelText: localizations.pulLong,
initialValue: widget.initialRecord?.pulse,
focusNode: pulFocusNode,
onSaved: (value) => setState(() => pulse = int.tryParse(value ?? '')),
@@ -284,7 +268,9 @@ class _AddEntryDialogeState extends State<AddEntryDialoge> {
child: TextFormField(
initialValue: widget.initialRecord?.notes,
focusNode: noteFocusNode,
- decoration: getInputDecoration(localizations.addNote),
+ decoration: InputDecoration(
+ labelText: localizations.addNote,
+ ),
minLines: 1,
maxLines: 4,
onChanged: (value) {
@@ -318,7 +304,6 @@ class _AddEntryDialogeState extends State<AddEntryDialoge> {
isExpanded: true,
value: widget.settings.medications
.where((e) => e.id == medicineId).firstOrNull,
- decoration: getInputDecoration(null),
items: [
for (final e in widget.settings.medications)
DropdownMenuItem(
@@ -350,7 +335,9 @@ class _AddEntryDialogeState extends State<AddEntryDialoge> {
Expanded(
child: TextFormField(
initialValue: medicineDosis?.toString(),
- decoration: getInputDecoration(localizations.dosis),
+ decoration: InputDecoration(
+ labelText: localizations.dosis,
+ ),
keyboardType: TextInputType.number,
onSaved: (value) => setState(() {
final dosis = int.tryParse(value ?? '')?.toDouble()
lib/screens/settings_screen.dart
@@ -29,6 +29,7 @@ class SettingsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
+ print(Theme.of(context).inputDecorationTheme.border);
final localizations = AppLocalizations.of(context)!;
return Scaffold(
appBar: AppBar(
lib/main.dart
@@ -127,7 +127,29 @@ class AppRoot extends StatelessWidget {
],
supportedLocales: AppLocalizations.supportedLocales,
locale: settings.language,
- home: const AppHome(),
+ home: Builder(
+ builder: (context) {
+ final inputBorder = OutlineInputBorder(
+ borderSide: BorderSide(
+ width: 3,
+ color: Theme.of(context).primaryColor,
+ ),
+ borderRadius: BorderRadius.circular(20)
+ );
+
+ final theme = Theme.of(context).copyWith(
+ inputDecorationTheme: InputDecorationTheme(
+ errorMaxLines: 5,
+ border: inputBorder,
+ enabledBorder: inputBorder,
+ ),
+ );
+ return Theme(
+ data: theme,
+ child: const AppHome()
+ );
+ }
+ ),
);
});
}