|
|
|
|
@ -208,19 +208,19 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
|
|
|
|
|
return widget.hideDefaultKeyboard
|
|
|
|
|
? _pinBoxRow(context)
|
|
|
|
|
: GestureDetector(
|
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
|
onTap: () {
|
|
|
|
|
if (hasFocus) {
|
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
|
Future.delayed(Duration(milliseconds: 100), () {
|
|
|
|
|
FocusScope.of(context).requestFocus(focusNode);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
FocusScope.of(context).requestFocus(focusNode);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: _pinBoxRow(context),
|
|
|
|
|
);
|
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
|
onTap: () {
|
|
|
|
|
if (hasFocus) {
|
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
|
Future.delayed(Duration(milliseconds: 100), () {
|
|
|
|
|
FocusScope.of(context).requestFocus(focusNode);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
FocusScope.of(context).requestFocus(focusNode);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: _pinBoxRow(context),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _otpTextInput() {
|
|
|
|
|
@ -318,13 +318,13 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
Widget _buildPinCode(int i, BuildContext context) {
|
|
|
|
|
final bool isFilled = i < text.length;
|
|
|
|
|
final bool isFilled = i < text.length && strList[i].isNotEmpty; // Check both conditions
|
|
|
|
|
final bool isCurrent = i == currentIndex;
|
|
|
|
|
final bool isFocused = hasFocus && isCurrent;
|
|
|
|
|
|
|
|
|
|
// Colors based on state
|
|
|
|
|
Color bgColor = Colors.white;
|
|
|
|
|
Color borderColor = widget.defaultBorderColor;
|
|
|
|
|
Color borderColor = Colors.white;
|
|
|
|
|
Color textColor = Colors.black;
|
|
|
|
|
|
|
|
|
|
if (widget.hasError) {
|
|
|
|
|
@ -333,12 +333,13 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
|
|
|
|
|
} else if (isFocused) {
|
|
|
|
|
borderColor = Colors.transparent;
|
|
|
|
|
bgColor = Colors.white;
|
|
|
|
|
textColor = Colors.white;
|
|
|
|
|
textColor = Colors.black; // Changed from white to black for better visibility
|
|
|
|
|
} else if (isFilled) {
|
|
|
|
|
borderColor = Colors.green;
|
|
|
|
|
bgColor = Colors.green;
|
|
|
|
|
textColor = Colors.white;
|
|
|
|
|
}
|
|
|
|
|
// When cleared/empty, colors remain as default initialized above
|
|
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
key: ValueKey<String>("container$i"),
|
|
|
|
|
@ -448,7 +449,7 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
|
|
|
|
|
softWrap: true,
|
|
|
|
|
key: ValueKey<String>("$text$i"),
|
|
|
|
|
style: widget.pinTextStyle?.copyWith(color: textColor, fontSize: fontSize, fontWeight: fontWeight, fontFamily: context.fontFamily) ??
|
|
|
|
|
TextStyle(color: textColor, fontSize: fontSize, fontWeight: fontWeight, fontFamily: context.fontFamily, ),
|
|
|
|
|
TextStyle(color: textColor, fontSize: fontSize, fontWeight: fontWeight, fontFamily: context.fontFamily,),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
@ -461,6 +462,7 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Widget _animatedTextBox(String text, int i, Color textColor) {
|
|
|
|
|
@ -483,5 +485,4 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
|
|
|
|
|
// TextStyle(color: textColor, fontSize: 24, fontWeight: FontWeight.bold),
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
// }}
|
|
|
|
|
|