Adds a fancy textfield helper
This commit is contained in:
parent
6537863dc5
commit
8463e6e179
3 changed files with 77 additions and 2 deletions
|
@ -2,5 +2,5 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class LibACFlutterConstants {
|
class LibACFlutterConstants {
|
||||||
static const Color TITLEBAR_COLOR = Color.fromARGB(255, 99, 0, 0);
|
static const Color TITLEBAR_COLOR = Color.fromARGB(255, 99, 0, 0);
|
||||||
static const VERSION = "1.0.020325+1224";
|
static const VERSION = "1.0.031525+0222";
|
||||||
}
|
}
|
||||||
|
|
75
lib/TextFields.dart
Normal file
75
lib/TextFields.dart
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
enum InputType {
|
||||||
|
Text,
|
||||||
|
Number,
|
||||||
|
Date;
|
||||||
|
|
||||||
|
TextInputType getType() {
|
||||||
|
switch (this) {
|
||||||
|
case Text:
|
||||||
|
return TextInputType.text;
|
||||||
|
case Number:
|
||||||
|
return TextInputType.number;
|
||||||
|
case Date:
|
||||||
|
return TextInputType.datetime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TextInputFormatter> getFormatters() {
|
||||||
|
var lst = [];
|
||||||
|
|
||||||
|
switch (this) {
|
||||||
|
case Text:
|
||||||
|
return [FilteringTextInputFormatter.deny("")];
|
||||||
|
case Number:
|
||||||
|
return [FilteringTextInputFormatter.digitsOnly];
|
||||||
|
case Date:
|
||||||
|
return [
|
||||||
|
FilteringTextInputFormatter.digitsOnly,
|
||||||
|
FilteringTextInputFormatter.allow("-"),
|
||||||
|
FilteringTextInputFormatter.allow("/")
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class HighlightTextfield extends StatelessWidget {
|
||||||
|
TextEditingController controller;
|
||||||
|
InputType inputStyle;
|
||||||
|
Color selected;
|
||||||
|
Color inactive;
|
||||||
|
HighlightTextfield(
|
||||||
|
{required this.controller,
|
||||||
|
required this.inputStyle,
|
||||||
|
required this.selected,
|
||||||
|
required this.inactive});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return TextField(
|
||||||
|
controller: controller,
|
||||||
|
keyboardType: inputStyle.getType(),
|
||||||
|
inputFormatters: inputStyle.getFormatters(),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: selected,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: inactive,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateColors(Color active, Color inactive) {
|
||||||
|
selected = active;
|
||||||
|
this.inactive = inactive;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
name: libacflutter
|
name: libacflutter
|
||||||
description: "A new Flutter package project."
|
description: "A new Flutter package project."
|
||||||
version: 1.0.020325+1224
|
version: 1.0.031525+0222
|
||||||
homepage: https://zontreck.com
|
homepage: https://zontreck.com
|
||||||
publish_to: https://git.zontreck.com/api/packages/Packages/pub
|
publish_to: https://git.zontreck.com/api/packages/Packages/pub
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue