CWA-215 | applied new design to address book page

This commit is contained in:
Oleksandr Sobol
2020-05-19 20:47:42 +03:00
parent 8769e93025
commit 3f1bb416d4
17 changed files with 179 additions and 109 deletions
@@ -10,6 +10,7 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
import 'package:cake_wallet/src/stores/address_book/address_book_store.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
class AddressBookPage extends BasePage {
AddressBookPage({this.isEditable = true});
@@ -17,14 +18,11 @@ class AddressBookPage extends BasePage {
final bool isEditable;
@override
bool get isModalBackButton => true;
Color get backgroundColor => PaletteDark.historyPanel;
@override
String get title => S.current.address_book;
@override
AppBarStyle get appBarStyle => AppBarStyle.withShadow;
@override
Widget trailing(BuildContext context) {
if (!isEditable) {
@@ -34,17 +32,17 @@ class AddressBookPage extends BasePage {
final addressBookStore = Provider.of<AddressBookStore>(context);
return Container(
width: 28.0,
height: 28.0,
width: 32.0,
height: 32.0,
decoration: BoxDecoration(
shape: BoxShape.circle, color: Theme.of(context).selectedRowColor),
shape: BoxShape.circle, color: PaletteDark.menuList),
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Icon(Icons.add, color: Palette.violet, size: 22.0),
Icon(Icons.add, color: Colors.white, size: 22.0),
ButtonTheme(
minWidth: 28.0,
height: 28.0,
minWidth: 32.0,
height: 32.0,
child: FlatButton(
shape: CircleBorder(),
onPressed: () async {
@@ -63,20 +61,30 @@ class AddressBookPage extends BasePage {
final addressBookStore = Provider.of<AddressBookStore>(context);
return Container(
color: PaletteDark.historyPanel,
padding: EdgeInsets.only(top: 20.0, bottom: 20.0),
child: Observer(
builder: (_) => ListView.separated(
separatorBuilder: (_, __) => Divider(
color: Theme.of(context).dividerTheme.color,
height: 1.0,
),
separatorBuilder: (_, __) => Container(
height: 1,
padding: EdgeInsets.only(left: 24),
color: PaletteDark.menuList,
child: Container(
height: 1,
color: PaletteDark.mainBackgroundColor,
),
),
itemCount: addressBookStore.contactList == null
? 0
: addressBookStore.contactList.length,
itemBuilder: (BuildContext context, int index) {
final contact = addressBookStore.contactList[index];
final image = _getCurrencyImage(contact.type);
final content = ListTile(
final isDrawTop = index == 0 ? true : false;
final isDrawBottom = index == addressBookStore.contactList.length - 1 ? true : false;
final content = GestureDetector(
onTap: () async {
if (!isEditable) {
Navigator.of(context).pop(contact);
@@ -86,39 +94,69 @@ class AddressBookPage extends BasePage {
final isCopied = await showNameAndAddressDialog(
context, contact.name, contact.address);
if (isCopied) {
if (isCopied != null && isCopied) {
await Clipboard.setData(
ClipboardData(text: contact.address));
Scaffold.of(context).showSnackBar(
SnackBar(
content: Text('Copied to Clipboard'),
content: Text(
S.of(context).copied_to_clipboard,
style: TextStyle(
color: Colors.white
),
),
backgroundColor: Colors.green,
duration: Duration(milliseconds: 1500),
),
);
}
},
leading: Container(
height: 25.0,
width: 48.0,
alignment: Alignment.center,
decoration: BoxDecoration(
color: _getCurrencyBackgroundColor(contact.type),
borderRadius: BorderRadius.circular(6.0),
),
child: Text(
contact.type.toString(),
style: TextStyle(
fontSize: 11.0,
color: _getCurrencyTextColor(contact.type),
child: Column(
children: <Widget>[
isDrawTop
? Container(
width: double.infinity,
height: 1,
color: PaletteDark.mainBackgroundColor,
)
: Offstage(),
Container(
width: double.infinity,
color: PaletteDark.menuList,
child: Padding(
padding: const EdgeInsets.only(left: 24, top: 16, bottom: 16, right: 24),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
image != null
? image
: Offstage(),
Padding(
padding: image != null
? EdgeInsets.only(left: 12)
: EdgeInsets.only(left: 0),
child: Text(
contact.name,
style: TextStyle(
fontSize: 14,
color: Colors.white
),
),
)
],
)
),
),
),
),
title: Text(
contact.name,
style: TextStyle(
fontSize: 16.0,
color: Theme.of(context).primaryTextTheme.title.color),
isDrawBottom
? Container(
width: double.infinity,
height: 1,
color: PaletteDark.mainBackgroundColor,
)
: Offstage(),
],
),
);
@@ -130,7 +168,7 @@ class AddressBookPage extends BasePage {
child: content,
secondaryActions: <Widget>[
IconSlideAction(
caption: 'Edit',
caption: S.of(context).edit,
color: Colors.blue,
icon: Icons.edit,
onTap: () async {
@@ -141,7 +179,7 @@ class AddressBookPage extends BasePage {
},
),
IconSlideAction(
caption: 'Delete',
caption: S.of(context).delete,
color: Colors.red,
icon: CupertinoIcons.delete,
onTap: () async {
@@ -171,95 +209,68 @@ class AddressBookPage extends BasePage {
));
}
Color _getCurrencyBackgroundColor(CryptoCurrency currency) {
Color color;
Image _getCurrencyImage(CryptoCurrency currency) {
Image image;
switch (currency) {
case CryptoCurrency.xmr:
color = Palette.cakeGreenWithOpacity;
image = Image.asset('assets/images/monero.png', height: 24, width: 24);
break;
case CryptoCurrency.ada:
color = Colors.blue[200];
image = null;
break;
case CryptoCurrency.bch:
color = Colors.orangeAccent;
image = null;
break;
case CryptoCurrency.bnb:
color = Colors.blue;
image = null;
break;
case CryptoCurrency.btc:
color = Colors.orange;
image = Image.asset('assets/images/bitcoin.png', height: 24, width: 24);
break;
case CryptoCurrency.dash:
color = Colors.blue;
image = null;
break;
case CryptoCurrency.eos:
color = Colors.orangeAccent;
image = null;
break;
case CryptoCurrency.eth:
color = Colors.black;
image = null;
break;
case CryptoCurrency.ltc:
color = Colors.blue[200];
image = Image.asset('assets/images/litecoin.png', height: 24, width: 24);
break;
case CryptoCurrency.nano:
color = Colors.orange;
image = null;
break;
case CryptoCurrency.trx:
color = Colors.black;
image = null;
break;
case CryptoCurrency.usdt:
color = Colors.blue[200];
image = null;
break;
case CryptoCurrency.xlm:
color = color = Colors.blue;
image = null;
break;
case CryptoCurrency.xrp:
color = Colors.orangeAccent;
image = null;
break;
default:
color = Colors.white;
image = null;
}
return color;
}
Color _getCurrencyTextColor(CryptoCurrency currency) {
Color color;
switch (currency) {
case CryptoCurrency.xmr:
color = Palette.cakeGreen;
break;
case CryptoCurrency.ltc:
case CryptoCurrency.ada:
case CryptoCurrency.usdt:
color = Palette.lightBlue;
break;
default:
color = Colors.white;
}
return color;
return image;
}
Future<bool> showAlertDialog(BuildContext context) async {
return await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text(
'Remove contact',
textAlign: TextAlign.center,
),
content: const Text(
'Are you sure that you want to remove selected contact?',
textAlign: TextAlign.center,
),
actions: <Widget>[
FlatButton(
onPressed: () => Navigator.of(context).pop( false),
child: const Text('Cancel')),
FlatButton(
onPressed: () => Navigator.of(context).pop(true),
child: const Text('Remove')),
],
return AlertWithTwoActions(
alertTitle: S.of(context).address_remove_contact,
alertContent: S.of(context).address_remove_content,
leftButtonText: S.of(context).remove,
rightButtonText: S.of(context).cancel,
actionLeftButton: () => Navigator.of(context).pop(true),
actionRightButton: () => Navigator.of(context).pop(false)
);
});
}
@@ -269,24 +280,13 @@ class AddressBookPage extends BasePage {
return await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(
name,
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold),
),
content: Text(
address,
textAlign: TextAlign.center,
),
actions: <Widget>[
FlatButton(
onPressed: () => Navigator.of(context).pop(false),
child: Text('Cancel')),
FlatButton(
onPressed: () => Navigator.of(context).pop(true),
child: Text('Copy'))
],
return AlertWithTwoActions(
alertTitle: name,
alertContent: address,
leftButtonText: S.of(context).copy,
rightButtonText: S.of(context).cancel,
actionLeftButton: () => Navigator.of(context).pop(true),
actionRightButton: () => Navigator.of(context).pop(false)
);
});
}