D1APP-12 authentication (password)
This commit is contained in:
parent
89a63b200c
commit
10b708d5c8
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -15,8 +15,9 @@ class DesignConfig {
|
|||
colorScheme: lightColorScheme,
|
||||
fontFamily: 'dana-fa',
|
||||
textTheme: const TextTheme(
|
||||
bodyText1: body1TextStyle,
|
||||
caption: captionTextStyle,
|
||||
bodyText1: body1Text,
|
||||
caption: captionText,
|
||||
subtitle2: subtitle2Text,
|
||||
),
|
||||
);
|
||||
|
||||
|
|
@ -36,10 +37,14 @@ class DesignConfig {
|
|||
brightness: Brightness.light,
|
||||
);
|
||||
|
||||
static const TextStyle body1TextStyle = TextStyle(
|
||||
static const TextStyle subtitle2Text = TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
);
|
||||
static const TextStyle body1Text = TextStyle(
|
||||
fontSize: 14,
|
||||
);
|
||||
static const TextStyle captionTextStyle = TextStyle(
|
||||
static const TextStyle captionText = TextStyle(
|
||||
fontSize: 13,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import 'package:didvan/config/design_config.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class DidvanText extends StatelessWidget {
|
||||
final TextStyle style;
|
||||
final TextStyle? style;
|
||||
final String text;
|
||||
final Color? color;
|
||||
final FontWeight? fontWeight;
|
||||
|
|
@ -11,7 +11,7 @@ class DidvanText extends StatelessWidget {
|
|||
const DidvanText(
|
||||
this.text, {
|
||||
Key? key,
|
||||
this.style = DesignConfig.body1TextStyle,
|
||||
this.style = DesignConfig.body1Text,
|
||||
this.color,
|
||||
this.fontSize,
|
||||
this.fontWeight,
|
||||
|
|
@ -21,7 +21,7 @@ class DidvanText extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return Text(
|
||||
text,
|
||||
style: style.copyWith(
|
||||
style: style!.copyWith(
|
||||
color: color,
|
||||
fontWeight: fontWeight,
|
||||
fontSize: fontSize,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class DidvanTextField extends StatefulWidget {
|
|||
final String? title;
|
||||
final String? hintText;
|
||||
final dynamic initialValue;
|
||||
final bool obsecureText;
|
||||
final String? Function(String? value)? validator;
|
||||
final TextInputType? textInputType;
|
||||
const DidvanTextField({
|
||||
|
|
@ -21,6 +22,7 @@ class DidvanTextField extends StatefulWidget {
|
|||
this.validator,
|
||||
this.textInputType,
|
||||
this.textAlign = TextAlign.right,
|
||||
this.obsecureText = false,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
|
@ -32,9 +34,11 @@ class _DidvanTextFieldState extends State<DidvanTextField> {
|
|||
final TextEditingController _controller = TextEditingController();
|
||||
|
||||
bool _hasError = false;
|
||||
bool _hideContent = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_hideContent = widget.obsecureText;
|
||||
_focusNode.addListener(() {
|
||||
setState(() {});
|
||||
});
|
||||
|
|
@ -50,20 +54,25 @@ class _DidvanTextFieldState extends State<DidvanTextField> {
|
|||
if (widget.title != null) DidvanText(widget.title!),
|
||||
if (widget.title != null) const SizedBox(height: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12).copyWith(
|
||||
left: widget.obsecureText ? 0 : 12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: _fillColor(),
|
||||
borderRadius: DesignConfig.lowBorderRadius,
|
||||
border: Border.all(color: _borderColor()),
|
||||
),
|
||||
child: TextFormField(
|
||||
obscureText: _hideContent,
|
||||
textAlign: widget.textAlign,
|
||||
keyboardType: widget.textInputType,
|
||||
focusNode: _focusNode,
|
||||
controller: _controller,
|
||||
onChanged: _onChanged,
|
||||
validator: _validator,
|
||||
obscuringCharacter: '*',
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: _suffixBuilder(),
|
||||
enabled: widget.enabled,
|
||||
border: InputBorder.none,
|
||||
hintText: widget.hintText,
|
||||
|
|
@ -96,6 +105,24 @@ class _DidvanTextFieldState extends State<DidvanTextField> {
|
|||
return Theme.of(context).colorScheme.surface;
|
||||
}
|
||||
|
||||
Widget? _suffixBuilder() {
|
||||
if (widget.obsecureText) {
|
||||
return FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_hideContent = !_hideContent;
|
||||
});
|
||||
},
|
||||
child: Icon(
|
||||
_hideContent ? Icons.remove_red_eye : Icons.remove_red_eye_outlined,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _onChanged(String value) {
|
||||
if (widget.onChanged != null) {
|
||||
widget.onChanged!(value);
|
||||
|
|
|
|||
12
pubspec.yaml
12
pubspec.yaml
|
|
@ -81,11 +81,19 @@ flutter:
|
|||
fonts:
|
||||
- family: dana-fa
|
||||
fonts:
|
||||
- asset: lib/assets/fonts/dana-fa.ttf
|
||||
- asset: lib/assets/fonts/Dana-FaNum-Black.ttf
|
||||
- asset: lib/assets/fonts/Dana-FaNum-Bold.ttf
|
||||
- asset: lib/assets/fonts/Dana-FaNum-SemiBold.ttf
|
||||
- asset: lib/assets/fonts/Dana-FaNum-ExtraBold.ttf
|
||||
- asset: lib/assets/fonts/Dana-FaNum-Light.ttf
|
||||
- asset: lib/assets/fonts/Dana-FaNum-Medium.ttf
|
||||
- asset: lib/assets/fonts/Dana-FaNum-Regular.ttf
|
||||
- asset: lib/assets/fonts/Dana-FaNum-Thin.ttf
|
||||
- asset: lib/assets/fonts/Dana-FaNum-UltraBold.ttf
|
||||
|
||||
- family: dana
|
||||
fonts:
|
||||
- asset: lib/assets/fonts/dana-fa.ttf
|
||||
- asset: lib/assets/fonts/Dana.ttf
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
|
|
|
|||
Loading…
Reference in New Issue