CWA-201 | moved WalletTile class to wallet_tile.dart; changed design for PrimaryImageButton; changed background color for wallet_list_page; added short address to current wallet in the wallet_tile

This commit is contained in:
Oleksandr Sobol 2020-04-24 15:01:19 +03:00
parent 28d8cd43dc
commit 6a799df7da
13 changed files with 216 additions and 194 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

View file

@ -9,7 +9,9 @@ import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart'; import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
import 'package:cake_wallet/src/stores/wallet_list/wallet_list_store.dart'; import 'package:cake_wallet/src/stores/wallet_list/wallet_list_store.dart';
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
import 'package:cake_wallet/src/screens/wallet_list/wallet_menu.dart'; import 'package:cake_wallet/src/screens/wallet_list/wallet_menu.dart';
import 'package:cake_wallet/src/screens/wallet_list/widgets/wallet_tile.dart';
class WalletListPage extends BasePage { class WalletListPage extends BasePage {
@ -27,17 +29,20 @@ class WalletListBody extends StatefulWidget {
class WalletListBodyState extends State<WalletListBody> { class WalletListBodyState extends State<WalletListBody> {
final moneroIcon = Image.asset('assets/images/monero.png', height: 24, width: 24); final moneroIcon = Image.asset('assets/images/monero.png', height: 24, width: 24);
final newWalletImage = Image.asset('assets/images/new_wallet.png', height: 12, width: 12, color: PaletteDark.historyPanel);
final restoreWalletImage = Image.asset('assets/images/restore_wallet.png', height: 12, width: 12, color: Colors.white,);
WalletListStore _walletListStore; WalletListStore _walletListStore;
ScrollController scrollController = ScrollController(); ScrollController scrollController = ScrollController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final walletStore = Provider.of<WalletStore>(context);
_walletListStore = Provider.of<WalletListStore>(context); _walletListStore = Provider.of<WalletListStore>(context);
return SafeArea( return SafeArea(
child: Container( child: Container(
padding: EdgeInsets.only(top: 32), padding: EdgeInsets.only(top: 32),
color: PaletteDark.menuHeader, color: PaletteDark.historyPanel,
child: ScrollableWithBottomSection( child: ScrollableWithBottomSection(
contentPadding: EdgeInsets.only(bottom: 20), contentPadding: EdgeInsets.only(bottom: 20),
content: Container( content: Container(
@ -46,7 +51,7 @@ class WalletListBodyState extends State<WalletListBody> {
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (_, index) => Divider( separatorBuilder: (_, index) => Divider(
color: PaletteDark.menuHeader, height: 16), color: PaletteDark.historyPanel, height: 16),
itemCount: _walletListStore.wallets.length, itemCount: _walletListStore.wallets.length,
itemBuilder: (__, index) { itemBuilder: (__, index) {
final wallet = _walletListStore.wallets[index]; final wallet = _walletListStore.wallets[index];
@ -55,6 +60,13 @@ class WalletListBodyState extends State<WalletListBody> {
final isCurrentWallet = final isCurrentWallet =
_walletListStore.isCurrentWallet(wallet); _walletListStore.isCurrentWallet(wallet);
String shortAddress = '';
if (isCurrentWallet) {
shortAddress = walletStore.subaddress.address;
shortAddress = shortAddress.replaceRange(4, shortAddress.length - 4, '...');
}
final walletMenu = WalletMenu(context); final walletMenu = WalletMenu(context);
final items = walletMenu.generateItemsForWalletMenu(isCurrentWallet); final items = walletMenu.generateItemsForWalletMenu(isCurrentWallet);
final colors = walletMenu.generateColorsForWalletMenu(isCurrentWallet); final colors = walletMenu.generateColorsForWalletMenu(isCurrentWallet);
@ -75,7 +87,7 @@ class WalletListBodyState extends State<WalletListBody> {
max: screenWidth, max: screenWidth,
image: moneroIcon, image: moneroIcon,
walletName: wallet.name, walletName: wallet.name,
walletAddress: '', walletAddress: shortAddress,
isCurrent: isCurrentWallet isCurrent: isCurrentWallet
), ),
), ),
@ -87,7 +99,28 @@ class WalletListBodyState extends State<WalletListBody> {
final color = colors[index]; final color = colors[index];
final image = images[index]; final image = images[index];
final content = Center( final radius = index == 0 ? 12.0 : 0.0;
return GestureDetector(
onTap: () {
scrollController.animateTo(0.0, duration: Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
walletMenu.action(
walletMenu.listItems.indexOf(item), wallet, isCurrentWallet);
},
child: Container(
height: 108,
width: 108,
color: PaletteDark.historyPanel,
child: Container(
padding: EdgeInsets.only(left: 5, right: 5),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(radius),
bottomLeft: Radius.circular(radius)
),
color: color
),
child: Center(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
@ -103,46 +136,8 @@ class WalletListBodyState extends State<WalletListBody> {
) )
], ],
), ),
);
if (index == 0) {
return GestureDetector(
onTap: () {
scrollController.animateTo(0.0, duration: Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
walletMenu.action(
walletMenu.listItems.indexOf(item), wallet, isCurrentWallet);
},
child: Container(
height: 108,
width: 108,
color: PaletteDark.menuHeader,
child: Container(
padding: EdgeInsets.only(left: 5, right: 5),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12),
bottomLeft: Radius.circular(12)
),
color: color
),
child: content,
), ),
), ),
);
}
return GestureDetector(
onTap: () {
scrollController.animateTo(0.0, duration: Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
walletMenu.action(
walletMenu.listItems.indexOf(item), wallet, isCurrentWallet);
},
child: Container(
height: 108,
width: 108,
padding: EdgeInsets.only(left: 5, right: 5),
color: color,
child: content,
), ),
); );
}, },
@ -156,143 +151,22 @@ class WalletListBodyState extends State<WalletListBody> {
), ),
), ),
bottomSection: Column(children: <Widget>[ bottomSection: Column(children: <Widget>[
PrimaryIconButton( PrimaryImageButton(
onPressed: () => Navigator.of(context).pushNamed(Routes.newWallet), onPressed: () => Navigator.of(context).pushNamed(Routes.newWallet),
iconData: Icons.add, image: newWalletImage,
color: Theme.of(context).primaryTextTheme.button.backgroundColor, text: S.of(context).wallet_list_create_new_wallet,
borderColor: color: Colors.white,
Theme.of(context).primaryTextTheme.button.decorationColor, textColor: PaletteDark.historyPanel),
iconColor: Palette.violet,
iconBackgroundColor: Theme.of(context).primaryIconTheme.color,
text: S.of(context).wallet_list_create_new_wallet),
SizedBox(height: 10.0), SizedBox(height: 10.0),
PrimaryIconButton( PrimaryImageButton(
onPressed: () => onPressed: () =>
Navigator.of(context).pushNamed(Routes.restoreWalletOptions), Navigator.of(context).pushNamed(Routes.restoreWalletOptions),
iconData: Icons.refresh, image: restoreWalletImage,
text: S.of(context).wallet_list_restore_wallet, text: S.of(context).wallet_list_restore_wallet,
color: Theme.of(context).accentTextTheme.button.backgroundColor, color: PaletteDark.historyPanelButton,
borderColor: textColor: Colors.white)
Theme.of(context).accentTextTheme.button.decorationColor,
iconColor: Theme.of(context).primaryTextTheme.caption.color,
iconBackgroundColor: Theme.of(context).accentIconTheme.color)
])), ])),
) )
); );
} }
} }
class WalletTile extends SliverPersistentHeaderDelegate {
WalletTile({
@required this.min,
@required this.max,
@required this.image,
@required this.walletName,
@required this.walletAddress,
@required this.isCurrent
});
final double min;
final double max;
final Image image;
final String walletName;
final String walletAddress;
final bool isCurrent;
@override
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
double opacity = 1 - shrinkOffset / (max - min);
opacity = opacity >= 0 ? opacity : 0;
double panelWidth = 12 * opacity;
panelWidth = panelWidth < 12 ? 0 : 12;
final currentColor = isCurrent
? Colors.white
: PaletteDark.menuHeader;
return Stack(
fit: StackFit.expand,
overflow: Overflow.visible,
children: <Widget>[
Positioned(
top: 0,
right: max - 4,
child: Container(
height: 108,
width: 4,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(topRight: Radius.circular(4), bottomRight: Radius.circular(4)),
color: currentColor
),
),
),
Positioned(
top: 0,
right: 12,
child: Container(
height: 108,
width: max - 16,
padding: EdgeInsets.only(left: 20, right: 20),
color: PaletteDark.menuHeader,
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
image,
SizedBox(width: 10),
Text(
walletName,
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.white
),
)
],
)
],
),
),
),
Positioned(
top: 0,
right: 0,
child: Opacity(
opacity: opacity,
child: Container(
height: 108,
width: panelWidth,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(topLeft: Radius.circular(12), bottomLeft: Radius.circular(12)),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
PaletteDark.walletCardTopEndSync,
PaletteDark.walletCardBottomEndSync
]
)
),
),
)
),
],
);
}
@override
double get maxExtent => max;
@override
double get minExtent => min;
@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) => true;
}

View file

@ -27,7 +27,7 @@ class WalletMenu {
final List<Image> listImages = [ final List<Image> listImages = [
Image.asset('assets/images/load.png', height: 32, width: 32, color: Colors.white), Image.asset('assets/images/load.png', height: 32, width: 32, color: Colors.white),
Image.asset('assets/images/eye.png', height: 32, width: 32, color: Colors.white), Image.asset('assets/images/eye_action.png', height: 32, width: 32, color: Colors.white),
Image.asset('assets/images/trash.png', height: 32, width: 32, color: Colors.white), Image.asset('assets/images/trash.png', height: 32, width: 32, color: Colors.white),
Image.asset('assets/images/scanner.png', height: 32, width: 32, color: Colors.white) Image.asset('assets/images/scanner.png', height: 32, width: 32, color: Colors.white)
]; ];

View file

@ -0,0 +1,135 @@
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/palette.dart';
class WalletTile extends SliverPersistentHeaderDelegate {
WalletTile({
@required this.min,
@required this.max,
@required this.image,
@required this.walletName,
@required this.walletAddress,
@required this.isCurrent
});
final double min;
final double max;
final Image image;
final String walletName;
final String walletAddress;
final bool isCurrent;
@override
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
double opacity = 1 - shrinkOffset / (max - min);
opacity = opacity >= 0 ? opacity : 0;
double panelWidth = 12 * opacity;
panelWidth = panelWidth < 12 ? 0 : 12;
final currentColor = isCurrent
? Colors.white
: PaletteDark.historyPanel;
return Stack(
fit: StackFit.expand,
overflow: Overflow.visible,
children: <Widget>[
Positioned(
top: 0,
right: max - 4,
child: Container(
height: 108,
width: 4,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(topRight: Radius.circular(4), bottomRight: Radius.circular(4)),
color: currentColor
),
),
),
Positioned(
top: 0,
right: 12,
child: Container(
height: 108,
width: max - 16,
padding: EdgeInsets.only(left: 20, right: 20),
color: PaletteDark.historyPanel,
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
image,
SizedBox(width: 10),
Text(
walletName,
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.white
),
)
],
),
isCurrent ? SizedBox(height: 5) : Offstage(),
isCurrent
? Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(width: 34),
Text(
walletAddress,
style: TextStyle(
fontSize: 12,
color: PaletteDark.walletCardText
),
)
],
)
: Offstage()
],
),
),
),
Positioned(
top: 0,
right: 0,
child: Opacity(
opacity: opacity,
child: Container(
height: 108,
width: panelWidth,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(topLeft: Radius.circular(12), bottomLeft: Radius.circular(12)),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
PaletteDark.walletCardTopEndSync,
PaletteDark.walletCardBottomEndSync
]
)
),
),
)
),
],
);
}
@override
double get maxExtent => max;
@override
double get minExtent => min;
@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) => true;
}

View file

@ -143,29 +143,42 @@ class PrimaryImageButton extends StatelessWidget {
{@required this.onPressed, {@required this.onPressed,
@required this.image, @required this.image,
@required this.text, @required this.text,
this.color = Palette.purple, @required this.color,
this.borderColor = Palette.deepPink, @required this.textColor});
this.iconColor = Colors.black});
final VoidCallback onPressed; final VoidCallback onPressed;
final Image image; final Image image;
final Color color; final Color color;
final Color borderColor; final Color textColor;
final Color iconColor;
final String text; final String text;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ButtonTheme( return ButtonTheme(
minWidth: double.infinity, minWidth: double.infinity,
height: 58.0, height: 52.0,
child: FlatButton( child: FlatButton(
onPressed: onPressed, onPressed: onPressed,
color: color, color: color,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
side: BorderSide(color: borderColor), borderRadius: BorderRadius.circular(26.0)),
borderRadius: BorderRadius.circular(12.0)), child:Center(
child: Row( child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
image,
SizedBox(width: 15),
Text(
text,
style: TextStyle(
fontSize: 15,
color: textColor
),
)
],
),
)
/*Row(
children: <Widget>[ children: <Widget>[
Container( Container(
width: 28.0, width: 28.0,
@ -192,7 +205,7 @@ class PrimaryImageButton extends StatelessWidget {
) )
])) ]))
], ],
), ),*/
)); ));
} }
} }