prasule/lib/pw/platformfield.dart
Matyáš Caras ef52caa836
feat: creating debt scenarios
also changed way of loading selected wallet
2024-07-19 17:34:45 +02:00

92 lines
2.7 KiB
Dart

// SPDX-FileCopyrightText: (C) 2024 Matyáš Caras
//
// SPDX-License-Identifier: AGPL-3.0-only
// ignore_for_file: public_member_api_docs
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:prasule/pw/platformwidget.dart';
/// A [PlatformWidget] implementation of a text field
class PlatformField extends PlatformWidget<TextFormField, CupertinoTextField> {
const PlatformField(
{super.key,
this.controller,
this.enabled,
this.labelText,
this.obscureText = false,
this.autocorrect = false,
this.keyboardType,
this.inputFormatters = const [],
this.onChanged,
this.autofillHints,
this.textStyle,
this.textAlign = TextAlign.start,
this.maxLines = 1,
this.focusNode,
this.inputBorder = const OutlineInputBorder(),
this.suffix,
this.prefix,
this.validator});
final TextEditingController? controller;
final bool? enabled;
final bool obscureText;
final String? labelText;
final bool autocorrect;
final TextInputType? keyboardType;
final List<TextInputFormatter> inputFormatters;
final void Function(String)? onChanged;
final List<String>? autofillHints;
final TextStyle? textStyle;
final TextAlign textAlign;
final int? maxLines;
final InputBorder inputBorder;
final FocusNode? focusNode;
final Widget? suffix;
final Widget? prefix;
final String? Function(String?)? validator;
@override
TextFormField createAndroidWidget(BuildContext context) => TextFormField(
textAlign: textAlign,
controller: controller,
enabled: enabled,
obscureText: obscureText,
decoration: InputDecoration(
labelText: labelText,
border: inputBorder,
suffix: suffix,
prefix: prefix,
),
autocorrect: autocorrect,
keyboardType: keyboardType,
focusNode: focusNode,
style: textStyle,
inputFormatters: inputFormatters,
onChanged: onChanged,
autofillHints: autofillHints,
maxLines: maxLines,
validator: validator,
);
@override
CupertinoTextField createIosWidget(BuildContext context) =>
CupertinoTextField(
textAlign: textAlign,
controller: controller,
enabled: enabled ?? true,
obscureText: obscureText,
placeholder: labelText,
autocorrect: autocorrect,
keyboardType: keyboardType,
inputFormatters: inputFormatters,
onChanged: onChanged,
focusNode: focusNode,
maxLines: maxLines,
style: textStyle,
prefix: prefix,
suffix: suffix,
);
}