Merge pull request #67 from cake-tech/CWA-220-bug-fix-3

Cwa 220 bug fix 3
wownero
Oleksandr Sobol 4 years ago committed by GitHub
commit 5752b98c62

@ -8,6 +8,8 @@ import 'package:cake_wallet/src/stores/auth/auth_store.dart';
import 'package:cake_wallet/src/screens/pin_code/pin_code.dart'; import 'package:cake_wallet/src/screens/pin_code/pin_code.dart';
import 'package:cake_wallet/src/stores/settings/settings_store.dart'; import 'package:cake_wallet/src/stores/settings/settings_store.dart';
import 'package:cake_wallet/src/domain/common/biometric_auth.dart'; import 'package:cake_wallet/src/domain/common/biometric_auth.dart';
import 'package:cake_wallet/themes.dart';
import 'package:cake_wallet/theme_changer.dart';
typedef OnAuthenticationFinished = void Function(bool, AuthPageState); typedef OnAuthenticationFinished = void Function(bool, AuthPageState);
@ -26,6 +28,7 @@ class AuthPageState extends State<AuthPage> {
final _pinCodeKey = GlobalKey<PinCodeState>(); final _pinCodeKey = GlobalKey<PinCodeState>();
final _backArrowImageDarkTheme = final _backArrowImageDarkTheme =
Image.asset('assets/images/back_arrow_dark_theme.png'); Image.asset('assets/images/back_arrow_dark_theme.png');
final _backArrowImage = Image.asset('assets/images/back_arrow.png');
void changeProcessText(String text) { void changeProcessText(String text) {
_key.currentState.showSnackBar( _key.currentState.showSnackBar(
@ -39,6 +42,10 @@ class AuthPageState extends State<AuthPage> {
final authStore = Provider.of<AuthStore>(context); final authStore = Provider.of<AuthStore>(context);
final settingsStore = Provider.of<SettingsStore>(context); final settingsStore = Provider.of<SettingsStore>(context);
final _themeChanger = Provider.of<ThemeChanger>(context);
final _backButton = _themeChanger.getTheme() == Themes.darkTheme
? _backArrowImageDarkTheme : _backArrowImage;
if (settingsStore.allowBiometricalAuthentication) { if (settingsStore.allowBiometricalAuthentication) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
final biometricAuth = BiometricAuth(); final biometricAuth = BiometricAuth();
@ -134,7 +141,7 @@ class AuthPageState extends State<AuthPage> {
splashColor: Colors.transparent, splashColor: Colors.transparent,
padding: EdgeInsets.all(0), padding: EdgeInsets.all(0),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
child: _backArrowImageDarkTheme), child: _backButton),
), ),
) )
: Container(), : Container(),
@ -146,6 +153,7 @@ class AuthPageState extends State<AuthPage> {
(pin, _) => authStore.auth( (pin, _) => authStore.auth(
password: pin.fold('', (ac, val) => ac + '$val')), password: pin.fold('', (ac, val) => ac + '$val')),
false, false,
_pinCodeKey)); _pinCodeKey,
authStore: authStore,));
} }
} }

@ -28,6 +28,7 @@ class DashboardPageBodyState extends State<DashboardPageBody> {
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
endDrawer: MenuWidget(),
body: Container( body: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
@ -49,17 +50,16 @@ class DashboardPageBodyState extends State<DashboardPageBody> {
width: 44, width: 44,
child: ButtonTheme( child: ButtonTheme(
minWidth: double.minPositive, minWidth: double.minPositive,
child: FlatButton( child: Builder(
builder: (context) {
return FlatButton(
highlightColor: Colors.transparent, highlightColor: Colors.transparent,
splashColor: Colors.transparent, splashColor: Colors.transparent,
padding: EdgeInsets.all(0), padding: EdgeInsets.all(0),
onPressed: () async { onPressed: () => Scaffold.of(context).openEndDrawer(),
await showDialog<void>( child: menuButton);
builder: (_) => MenuWidget(), }
context: context ),
);
},
child: menuButton),
), ),
), ),
), ),

@ -1,7 +1,5 @@
import 'dart:async';
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:cake_wallet/palette.dart';
import 'package:cake_wallet/src/screens/dashboard/wallet_menu.dart'; import 'package:cake_wallet/src/screens/dashboard/wallet_menu.dart';
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart'; import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -19,7 +17,6 @@ class MenuWidgetState extends State<MenuWidget> {
double screenWidth; double screenWidth;
double screenHeight; double screenHeight;
double opacity; double opacity;
bool isDraw;
double headerHeight; double headerHeight;
double tileHeight; double tileHeight;
@ -32,7 +29,6 @@ class MenuWidgetState extends State<MenuWidget> {
screenWidth = 0; screenWidth = 0;
screenHeight = 0; screenHeight = 0;
opacity = 0; opacity = 0;
isDraw = false;
headerHeight = 120; headerHeight = 120;
tileHeight = 75; tileHeight = 75;
@ -59,10 +55,6 @@ class MenuWidgetState extends State<MenuWidget> {
fromBottomEdge *= scale; fromBottomEdge *= scale;
} }
}); });
Timer(Duration(milliseconds: 350), () =>
setState(() => isDraw = true)
);
} }
@override @override
@ -71,54 +63,39 @@ class MenuWidgetState extends State<MenuWidget> {
final walletStore = Provider.of<WalletStore>(context); final walletStore = Provider.of<WalletStore>(context);
final itemCount = walletMenu.items.length; final itemCount = walletMenu.items.length;
return GestureDetector( return Row(
onTap: () => Navigator.of(context).pop(),
child: Container(
color: Colors.transparent,
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 3.0, sigmaY: 3.0),
child: Container(
decoration: BoxDecoration(color: PaletteDark.darkNightBlue.withOpacity(0.75)),
child: Row(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Padding( Padding(
padding: EdgeInsets.only(left: 24), padding: EdgeInsets.only(left: 24),
child: isDraw child: Container(
? Container(
height: 60, height: 60,
width: 4, width: 4,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(2)), borderRadius: BorderRadius.all(Radius.circular(2)),
color: Theme.of(context).hintColor // color: Theme.of(context).hintColor
), ),
) )
: Container(
height: 60,
width: 4,
)
), ),
SizedBox(width: 12), SizedBox(width: 12),
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: () => null, onTap: () => null,
child: Container( child: Container(
width: double.infinity,
height: double.infinity,
alignment: Alignment.centerRight,
child: AnimatedContainer(
alignment: Alignment.centerLeft,
width: menuWidth, width: menuWidth,
height: double.infinity, height: double.infinity,
duration: Duration(milliseconds: 500),
curve: Curves.fastOutSlowIn,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.only(topLeft: Radius.circular(24), bottomLeft: Radius.circular(24)), borderRadius: BorderRadius.only(
color: Theme.of(context).primaryTextTheme.display1.color.withOpacity(opacity) topLeft: Radius.circular(24),
), bottomLeft: Radius.circular(24)),
child: isDraw color: Theme.of(context).primaryTextTheme.display1.color
? ListView.separated( ),
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(24),
bottomLeft: Radius.circular(24)),
child: ListView.separated(
itemBuilder: (_, index) { itemBuilder: (_, index) {
if (index == 0) { if (index == 0) {
@ -248,17 +225,12 @@ class MenuWidgetState extends State<MenuWidget> {
height: 1, height: 1,
color: Theme.of(context).dividerColor, color: Theme.of(context).dividerColor,
), ),
itemCount: itemCount + 1) itemCount: itemCount + 1),
: Offstage()
), ),
), ),
) )
) )
], ],
)
),
),
),
); );
} }
} }

@ -77,8 +77,6 @@ class NodeListPageBodyState extends State<NodeListPageBody> {
final nodeList = Provider.of<NodeListStore>(context); final nodeList = Provider.of<NodeListStore>(context);
final settings = Provider.of<SettingsStore>(context); final settings = Provider.of<SettingsStore>(context);
final trashImage = Image.asset('assets/images/trash.png', height: 32, width: 32, color: Colors.white);
final currentColor = Theme.of(context).accentTextTheme.subtitle.decorationColor; final currentColor = Theme.of(context).accentTextTheme.subtitle.decorationColor;
final notCurrentColor = Theme.of(context).accentTextTheme.title.backgroundColor; final notCurrentColor = Theme.of(context).accentTextTheme.title.backgroundColor;
@ -194,12 +192,16 @@ class NodeListPageBodyState extends State<NodeListPageBody> {
await nodeList.remove(node: node), await nodeList.remove(node: node),
direction: DismissDirection.endToStart, direction: DismissDirection.endToStart,
background: Container( background: Container(
padding: EdgeInsets.only(right: 10.0, top: 2), padding: EdgeInsets.only(right: 10.0),
alignment: AlignmentDirectional.centerEnd, alignment: AlignmentDirectional.centerEnd,
color: Palette.red, color: Palette.red,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: <Widget>[
trashImage, const Icon(
CupertinoIcons.delete,
color: Colors.white,
),
Text( Text(
S.of(context).delete, S.of(context).delete,
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),

@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/src/stores/settings/settings_store.dart'; import 'package:cake_wallet/src/stores/settings/settings_store.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/stores/auth/auth_store.dart';
import 'package:cake_wallet/src/domain/common/biometric_auth.dart';
abstract class PinCodeWidget extends StatefulWidget { abstract class PinCodeWidget extends StatefulWidget {
PinCodeWidget({Key key, this.onPinCodeEntered, this.hasLengthSwitcher}) PinCodeWidget({Key key, this.onPinCodeEntered, this.hasLengthSwitcher})
@ -14,21 +16,26 @@ abstract class PinCodeWidget extends StatefulWidget {
class PinCode extends PinCodeWidget { class PinCode extends PinCodeWidget {
PinCode(Function(List<int> pin, PinCodeState state) onPinCodeEntered, PinCode(Function(List<int> pin, PinCodeState state) onPinCodeEntered,
bool hasLengthSwitcher, Key key) bool hasLengthSwitcher, Key key, {this.authStore})
: super( : super(
key: key, key: key,
onPinCodeEntered: onPinCodeEntered, onPinCodeEntered: onPinCodeEntered,
hasLengthSwitcher: hasLengthSwitcher); hasLengthSwitcher: hasLengthSwitcher);
final AuthStore authStore;
@override @override
PinCodeState createState() => PinCodeState(); PinCodeState createState() => PinCodeState(authStore: authStore);
} }
class PinCodeState<T extends PinCodeWidget> extends State<T> { class PinCodeState<T extends PinCodeWidget> extends State<T> {
PinCodeState({this.authStore});
static const defaultPinLength = 4; static const defaultPinLength = 4;
static const sixPinLength = 6; static const sixPinLength = 6;
static const fourPinLength = 4; static const fourPinLength = 4;
final _gridViewKey = GlobalKey(); final _gridViewKey = GlobalKey();
final AuthStore authStore;
final _key = GlobalKey<ScaffoldState>();
int pinLength = defaultPinLength; int pinLength = defaultPinLength;
List<int> pin = List<int>.filled(defaultPinLength, null); List<int> pin = List<int>.filled(defaultPinLength, null);
@ -83,9 +90,11 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
} }
@override @override
Widget build(BuildContext context) => Scaffold(body: body(context)); Widget build(BuildContext context) => Scaffold(key: _key, body: body(context));
Widget body(BuildContext context) { Widget body(BuildContext context) {
final settingsStore = Provider.of<SettingsStore>(context);
final deleteIconImage = Image.asset( final deleteIconImage = Image.asset(
'assets/images/delete_icon.png', 'assets/images/delete_icon.png',
color: Theme.of(context).primaryTextTheme.title.color, color: Theme.of(context).primaryTextTheme.title.color,
@ -161,10 +170,35 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
margin: EdgeInsets.only( margin: EdgeInsets.only(
left: marginLeft, right: marginRight), left: marginLeft, right: marginRight),
child: FlatButton( child: FlatButton(
onPressed: () {}, onPressed: (widget.hasLengthSwitcher ||
!settingsStore.allowBiometricalAuthentication)
? null
: () {
if (authStore != null) {
WidgetsBinding.instance.addPostFrameCallback((_) {
final biometricAuth = BiometricAuth();
biometricAuth.isAuthenticated().then(
(isAuth) {
if (isAuth) {
authStore.biometricAuth();
_key.currentState.showSnackBar(
SnackBar(
content: Text(S.of(context).authenticated),
backgroundColor: Colors.green,
),
);
}
}
);
});
}
},
color: Theme.of(context).backgroundColor, color: Theme.of(context).backgroundColor,
shape: CircleBorder(), shape: CircleBorder(),
child: faceImage, child: (widget.hasLengthSwitcher ||
!settingsStore.allowBiometricalAuthentication)
? Offstage()
: faceImage,
), ),
); );
} else if (index == 10) { } else if (index == 10) {

@ -245,7 +245,10 @@ class ReceivePageState extends State<ReceivePage> {
), ),
), ),
Observer( Observer(
builder: (_) => ListView.separated( builder: (_) {
subaddressListStore.updateShortAddressShow();
return ListView.separated(
separatorBuilder: (context, index) => Divider( separatorBuilder: (context, index) => Divider(
height: 1, height: 1,
color: Theme.of(context).dividerColor, color: Theme.of(context).dividerColor,
@ -301,12 +304,24 @@ class ReceivePageState extends State<ReceivePage> {
final isCurrent = final isCurrent =
walletStore.subaddress.address == subaddress.address; walletStore.subaddress.address == subaddress.address;
final label = subaddress.label.isNotEmpty final content = Observer(
builder: (_) {
final isShortAddressShow = subaddressListStore.isShortAddressShow[index];
final label = index == 0
? 'Primary subaddress'
: subaddress.label.isNotEmpty
? subaddress.label ? subaddress.label
: subaddress.address; : subaddress.address;
final content = InkWell( return InkWell(
onTap: () => walletStore.setSubaddress(subaddress), onTap: () => walletStore.setSubaddress(subaddress),
onLongPress: () {
if (subaddress.label.isNotEmpty) {
return;
}
subaddressListStore.setShortAddressShow(index, !isShortAddressShow);
},
child: Container( child: Container(
color: isCurrent ? currentColor : notCurrentColor, color: isCurrent ? currentColor : notCurrentColor,
padding: EdgeInsets.only( padding: EdgeInsets.only(
@ -317,9 +332,10 @@ class ReceivePageState extends State<ReceivePage> {
), ),
child: Text( child: Text(
label, label,
maxLines: isShortAddressShow ? 1 : 10,
overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontSize: subaddress.label.isNotEmpty fontSize: 18,
? 18 : 10,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: isCurrent color: isCurrent
? currentTextColor ? currentTextColor
@ -328,8 +344,10 @@ class ReceivePageState extends State<ReceivePage> {
), ),
), ),
); );
}
);
return isCurrent return isCurrent || index == 0
? content ? content
: Slidable( : Slidable(
key: Key(subaddress.address), key: Key(subaddress.address),
@ -348,7 +366,8 @@ class ReceivePageState extends State<ReceivePage> {
} }
); );
} }
) );
}
), ),
], ],
), ),

@ -33,10 +33,8 @@ abstract class ExchangeStoreBase with Store {
provider = initialProvider; provider = initialProvider;
depositCurrency = initialDepositCurrency; depositCurrency = initialDepositCurrency;
receiveCurrency = initialReceiveCurrency; receiveCurrency = initialReceiveCurrency;
/*isDepositAddressEnabled = !(depositCurrency == walletStore.type); isDepositAddressEnabled = !(depositCurrency == walletStore.type);
isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);*/ isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);
isDepositAddressEnabled = true;
isReceiveAddressEnabled = true;
depositAmount = ''; depositAmount = '';
receiveAmount = ''; receiveAmount = '';
depositAddress = ''; depositAddress = '';
@ -109,16 +107,16 @@ abstract class ExchangeStoreBase with Store {
void changeDepositCurrency({CryptoCurrency currency}) { void changeDepositCurrency({CryptoCurrency currency}) {
depositCurrency = currency; depositCurrency = currency;
_onPairChange(); _onPairChange();
/*isDepositAddressEnabled = !(depositCurrency == walletStore.type); isDepositAddressEnabled = !(depositCurrency == walletStore.type);
isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);*/ isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);
} }
@action @action
void changeReceiveCurrency({CryptoCurrency currency}) { void changeReceiveCurrency({CryptoCurrency currency}) {
receiveCurrency = currency; receiveCurrency = currency;
_onPairChange(); _onPairChange();
/*isDepositAddressEnabled = !(depositCurrency == walletStore.type); isDepositAddressEnabled = !(depositCurrency == walletStore.type);
isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);*/ isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);
} }
@action @action
@ -242,8 +240,8 @@ abstract class ExchangeStoreBase with Store {
receiveCurrency = CryptoCurrency.btc; receiveCurrency = CryptoCurrency.btc;
depositAddress = depositCurrency == walletStore.type ? walletStore.address : ''; depositAddress = depositCurrency == walletStore.type ? walletStore.address : '';
receiveAddress = receiveCurrency == walletStore.type ? walletStore.address : ''; receiveAddress = receiveCurrency == walletStore.type ? walletStore.address : '';
/*isDepositAddressEnabled = !(depositCurrency == walletStore.type); isDepositAddressEnabled = !(depositCurrency == walletStore.type);
isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);*/ isReceiveAddressEnabled = !(receiveCurrency == walletStore.type);
_onPairChange(); _onPairChange();
} }

@ -15,6 +15,7 @@ class SubaddressListStore = SubaddressListStoreBase with _$SubaddressListStore;
abstract class SubaddressListStoreBase with Store { abstract class SubaddressListStoreBase with Store {
SubaddressListStoreBase({@required WalletService walletService}) { SubaddressListStoreBase({@required WalletService walletService}) {
subaddresses = ObservableList<Subaddress>(); subaddresses = ObservableList<Subaddress>();
isShortAddressShow = ObservableList<bool>();
if (walletService.currentWallet != null) { if (walletService.currentWallet != null) {
_onWalletChanged(walletService.currentWallet); _onWalletChanged(walletService.currentWallet);
@ -27,12 +28,20 @@ abstract class SubaddressListStoreBase with Store {
@observable @observable
ObservableList<Subaddress> subaddresses; ObservableList<Subaddress> subaddresses;
@observable
ObservableList<bool> isShortAddressShow;
SubaddressList _subaddressList; SubaddressList _subaddressList;
StreamSubscription<Wallet> _onWalletChangeSubscription; StreamSubscription<Wallet> _onWalletChangeSubscription;
StreamSubscription<List<Subaddress>> _onSubaddressesChangeSubscription; StreamSubscription<List<Subaddress>> _onSubaddressesChangeSubscription;
StreamSubscription<Account> _onAccountChangeSubscription; StreamSubscription<Account> _onAccountChangeSubscription;
Account _account; Account _account;
@action
void setShortAddressShow(int index, bool isShow) {
isShortAddressShow[index] = isShow;
}
@override @override
void dispose() { void dispose() {
if (_onSubaddressesChangeSubscription != null) { if (_onSubaddressesChangeSubscription != null) {
@ -47,6 +56,10 @@ abstract class SubaddressListStoreBase with Store {
super.dispose(); super.dispose();
} }
void updateShortAddressShow() {
isShortAddressShow = ObservableList.of(List.generate(subaddresses.length, (i) => true));
}
Future<void> _updateSubaddressList({int accountIndex}) async { Future<void> _updateSubaddressList({int accountIndex}) async {
await _subaddressList.refresh(accountIndex: accountIndex); await _subaddressList.refresh(accountIndex: accountIndex);
subaddresses = ObservableList.of(_subaddressList.getAll()); subaddresses = ObservableList.of(_subaddressList.getAll());

Loading…
Cancel
Save