Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions lib/pages/pinpad_views/create_pin_view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
Expand All @@ -9,7 +10,6 @@ import 'package:stackwallet/providers/global/secure_store_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/biometrics.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/background.dart';
Expand All @@ -35,10 +35,11 @@ class CreatePinView extends ConsumerStatefulWidget {
class _CreatePinViewState extends ConsumerState<CreatePinView> {
BoxDecoration get _pinPutDecoration {
return BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.textSubtitle3,
color: Theme.of(context).extension<StackColors>()!.infoItemIcons,
border: Border.all(
width: 1,
color: Theme.of(context).extension<StackColors>()!.textSubtitle3),
width: 1,
color: Theme.of(context).extension<StackColors>()!.infoItemIcons,
),
borderRadius: BorderRadius.circular(6),
);
}
Expand All @@ -57,10 +58,13 @@ class _CreatePinViewState extends ConsumerState<CreatePinView> {
late SecureStorageInterface _secureStore;
late Biometrics biometrics;

int pinCount = 1;

@override
initState() {
_secureStore = ref.read(secureStoreProvider);
biometrics = widget.biometrics;

super.initState();
}

Expand All @@ -71,11 +75,13 @@ class _CreatePinViewState extends ConsumerState<CreatePinView> {
_pinPutController2.dispose();
_pinPutFocusNode1.dispose();
_pinPutFocusNode2.dispose();

super.dispose();
}

@override
Widget build(BuildContext context) {
// int pinCount = 1;
return Background(
child: Scaffold(
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
Expand Down Expand Up @@ -116,7 +122,7 @@ class _CreatePinViewState extends ConsumerState<CreatePinView> {
height: 36,
),
CustomPinPut(
fieldsCount: Constants.pinLength,
fieldsCount: pinCount,
eachFieldHeight: 12,
eachFieldWidth: 12,
textStyle: STextStyles.label(context).copyWith(
Expand All @@ -140,21 +146,23 @@ class _CreatePinViewState extends ConsumerState<CreatePinView> {
),
isRandom:
ref.read(prefsChangeNotifierProvider).randomizePIN,
submittedFieldDecoration: _pinPutDecoration.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
border: Border.all(
width: 1,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
),
),
submittedFieldDecoration: _pinPutDecoration,
selectedFieldDecoration: _pinPutDecoration,
followingFieldDecoration: _pinPutDecoration,
onPinLengthChanged: (newLength) {
setState(() {
pinCount = newLength;
});
},
onSubmit: (String pin) {
if (pin.length == Constants.pinLength) {
if (pin.length < 4) {
showFloatingFlushBar(
type: FlushBarType.warning,
message: "PIN not long enough!",
iconAsset: Assets.svg.alertCircle,
context: context,
);
} else {
_pageController.nextPage(
duration: const Duration(milliseconds: 300),
curve: Curves.linear,
Expand Down Expand Up @@ -184,7 +192,7 @@ class _CreatePinViewState extends ConsumerState<CreatePinView> {
height: 36,
),
CustomPinPut(
fieldsCount: Constants.pinLength,
fieldsCount: pinCount,
eachFieldHeight: 12,
eachFieldWidth: 12,
textStyle: STextStyles.infoSmall(context).copyWith(
Expand Down
31 changes: 7 additions & 24 deletions lib/pages/pinpad_views/lock_screen_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import 'package:stackwallet/themes/stack_colors.dart';
// import 'package:stackwallet/providers/global/should_show_lockscreen_on_resume_state_provider.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/biometrics.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/show_loading.dart';
Expand Down Expand Up @@ -189,10 +188,11 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {

BoxDecoration get _pinPutDecoration {
return BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.textSubtitle2,
color: Theme.of(context).extension<StackColors>()!.infoItemIcons,
border: Border.all(
width: 1,
color: Theme.of(context).extension<StackColors>()!.textSubtitle2),
width: 1,
color: Theme.of(context).extension<StackColors>()!.infoItemIcons,
),
borderRadius: BorderRadius.circular(6),
);
}
Expand All @@ -202,6 +202,7 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {

late SecureStorageInterface _secureStore;
late Biometrics biometrics;
int pinCount = 1;

Widget get _body => Background(
child: SafeArea(
Expand Down Expand Up @@ -274,13 +275,7 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
height: 52,
),
CustomPinPut(
// customKey: CustomKey(
// onPressed: _checkUseBiometrics,
// iconAssetName: Platform.isIOS
// ? Assets.svg.faceId
// : Assets.svg.fingerprint,
// ),
fieldsCount: Constants.pinLength,
fieldsCount: pinCount,
eachFieldHeight: 12,
eachFieldWidth: 12,
textStyle: STextStyles.label(context).copyWith(
Expand All @@ -302,19 +297,7 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
.background,
counterText: "",
),
submittedFieldDecoration: _pinPutDecoration.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
border: Border.all(
width: 1,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
),
),
selectedFieldDecoration: _pinPutDecoration,
followingFieldDecoration: _pinPutDecoration,
submittedFieldDecoration: _pinPutDecoration,
isRandom: ref
.read(prefsChangeNotifierProvider)
.randomizePIN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/providers/global/secure_store_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/background.dart';
Expand All @@ -27,10 +26,11 @@ class ChangePinView extends ConsumerStatefulWidget {
class _ChangePinViewState extends ConsumerState<ChangePinView> {
BoxDecoration get _pinPutDecoration {
return BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.textSubtitle2,
color: Theme.of(context).extension<StackColors>()!.infoItemIcons,
border: Border.all(
width: 1,
color: Theme.of(context).extension<StackColors>()!.textSubtitle2),
width: 1,
color: Theme.of(context).extension<StackColors>()!.infoItemIcons,
),
borderRadius: BorderRadius.circular(6),
);
}
Expand All @@ -48,6 +48,8 @@ class _ChangePinViewState extends ConsumerState<ChangePinView> {

late final SecureStorageInterface _secureStore;

int pinCount = 1;

@override
void initState() {
_secureStore = ref.read(secureStoreProvider);
Expand Down Expand Up @@ -101,7 +103,7 @@ class _ChangePinViewState extends ConsumerState<ChangePinView> {
height: 52,
),
CustomPinPut(
fieldsCount: Constants.pinLength,
fieldsCount: pinCount,
eachFieldHeight: 12,
eachFieldWidth: 12,
textStyle: STextStyles.label(context).copyWith(
Expand All @@ -125,21 +127,18 @@ class _ChangePinViewState extends ConsumerState<ChangePinView> {
),
isRandom:
ref.read(prefsChangeNotifierProvider).randomizePIN,
submittedFieldDecoration: _pinPutDecoration.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
border: Border.all(
width: 1,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
),
),
submittedFieldDecoration: _pinPutDecoration,
selectedFieldDecoration: _pinPutDecoration,
followingFieldDecoration: _pinPutDecoration,
onSubmit: (String pin) {
if (pin.length == Constants.pinLength) {
if (pin.length < 4) {
showFloatingFlushBar(
type: FlushBarType.warning,
message: "PIN not long enough!",
iconAsset: Assets.svg.alertCircle,
context: context,
);
} else {
_pageController.nextPage(
duration: const Duration(milliseconds: 300),
curve: Curves.linear,
Expand All @@ -165,7 +164,7 @@ class _ChangePinViewState extends ConsumerState<ChangePinView> {
height: 52,
),
CustomPinPut(
fieldsCount: Constants.pinLength,
fieldsCount: pinCount,
eachFieldHeight: 12,
eachFieldWidth: 12,
textStyle: STextStyles.infoSmall(context).copyWith(
Expand All @@ -192,17 +191,7 @@ class _ChangePinViewState extends ConsumerState<ChangePinView> {
),
isRandom:
ref.read(prefsChangeNotifierProvider).randomizePIN,
submittedFieldDecoration: _pinPutDecoration.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
border: Border.all(
width: 1,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
),
),
submittedFieldDecoration: _pinPutDecoration,
selectedFieldDecoration: _pinPutDecoration,
followingFieldDecoration: _pinPutDecoration,
onSubmit: (String pin) async {
Expand Down
2 changes: 0 additions & 2 deletions lib/utilities/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ abstract class Constants {
static const int notificationsMax = 0xFFFFFFFF;
static const Duration networkAliveTimerDuration = Duration(seconds: 10);

static const int pinLength = 4;

// Enable Logger.print statements
static const bool disableLogger = false;

Expand Down
6 changes: 4 additions & 2 deletions lib/widgets/custom_pin_put/custom_pin_put.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ class CustomPinPut extends StatefulWidget {
this.mainAxisSize = MainAxisSize.max,
this.autofillHints,
this.customKey,
}) : assert(fieldsCount > 0),
super(key: key);
this.onPinLengthChanged,
}) : super(key: key);

final void Function(int)? onPinLengthChanged;

final double? width;
final double? height;
Expand Down
Loading