51 lines
1.6 KiB
Dart
51 lines
1.6 KiB
Dart
// Flutter imports:
|
|
import 'package:flutter/material.dart';
|
|
import 'package:pin_code_fields/pin_code_fields.dart';
|
|
import 'package:remever/common/resources.dart';
|
|
import 'package:remever/components/extensions/context.dart';
|
|
|
|
class PinCode extends StatefulWidget {
|
|
const PinCode({super.key, required this.pinController});
|
|
|
|
final TextEditingController pinController;
|
|
|
|
@override
|
|
State<PinCode> createState() => _PinCodeState();
|
|
}
|
|
|
|
class _PinCodeState extends State<PinCode> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return PinCodeTextField(
|
|
controller: widget.pinController,
|
|
appContext: context,
|
|
length: 6,
|
|
keyboardType: TextInputType.number,
|
|
animationType: AnimationType.slide,
|
|
hapticFeedbackTypes: HapticFeedbackTypes.medium,
|
|
autoFocus: true,
|
|
enableActiveFill: true,
|
|
cursorColor: AppColors.primary,
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) return 'Поле не может быть пустым';
|
|
if (value.length < 5) return 'Слишком мало символов';
|
|
return null;
|
|
},
|
|
pinTheme: PinTheme(
|
|
fieldWidth: 48.w,
|
|
fieldHeight: 62.h,
|
|
borderRadius: BorderRadius.circular(8).r,
|
|
activeFillColor: AppColors.white,
|
|
selectedFillColor: AppColors.white,
|
|
inactiveColor: AppColors.white,
|
|
|
|
selectedColor: AppColors.white,
|
|
activeColor: AppColors.white,
|
|
shape: PinCodeFieldShape.box,
|
|
inactiveFillColor: AppColors.white,
|
|
),
|
|
onCompleted: (String value) async {},
|
|
);
|
|
}
|
|
}
|