From 53c12d7bc098cbeb1a452d09c20de0c825bf8076 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 6 Jan 2021 15:34:04 +0200 Subject: [PATCH] CAKE-227 | applied null to subname for btc wallet in the dashboard_view_model.dart; deleted isDrawBottom from trade_details_page.dart, transaction_details_page.dart, standart_list_row.dart, textfield_list_row.dart; applied SectionStandardList to trade_details_page.dart and transaction_details_page.dart --- .../trade_details/trade_details_page.dart | 35 +++--- .../transaction_details_page.dart | 69 +++++------- .../widgets/textfield_list_row.dart | 97 +++++++--------- lib/src/widgets/standart_list_row.dart | 105 ++++++++---------- .../dashboard/dashboard_view_model.dart | 2 + 5 files changed, 126 insertions(+), 182 deletions(-) diff --git a/lib/src/screens/trade_details/trade_details_page.dart b/lib/src/screens/trade_details/trade_details_page.dart index f108e85bd..e4cad6547 100644 --- a/lib/src/screens/trade_details/trade_details_page.dart +++ b/lib/src/screens/trade_details/trade_details_page.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/src/widgets/standard_list.dart'; import 'package:cake_wallet/utils/show_bar.dart'; import 'package:cake_wallet/view_model/trade_details_view_model.dart'; import 'package:flutter/material.dart'; @@ -18,35 +19,25 @@ class TradeDetailsPage extends BasePage { @override Widget body(BuildContext context) { - return Container(child: Observer(builder: (_) { - return ListView.separated( - separatorBuilder: (_, __) => Container( - height: 1, - padding: EdgeInsets.only(left: 24), - color: Theme.of(context).backgroundColor, - child: Container( - height: 1, - color: Theme.of(context) - .primaryTextTheme - .title - .backgroundColor)), - itemCount: tradeDetailsViewModel.items.length, - itemBuilder: (BuildContext context, int index) { + return Observer(builder: (_) { + return SectionStandardList( + sectionCount: 1, + itemCounter: (int _) => tradeDetailsViewModel.items.length, + itemBuilder: (_, __, index) { final item = tradeDetailsViewModel.items[index]; - final isDrawBottom = - index == tradeDetailsViewModel.items.length - 1 ? true : false; return GestureDetector( onTap: () { Clipboard.setData(ClipboardData(text: '${item.value}')); - showBar(context, S.of(context).copied_to_clipboard); + showBar(context, S + .of(context) + .copied_to_clipboard); }, child: StandartListRow( - title: '${item.title}', - value: '${item.value}', - isDrawBottom: isDrawBottom, + title: '${item.title}', + value: '${item.value}' )); }); - })); + }); } -} +} \ No newline at end of file diff --git a/lib/src/screens/transaction_details/transaction_details_page.dart b/lib/src/screens/transaction_details/transaction_details_page.dart index a0e1b3c7a..d7a265a9a 100644 --- a/lib/src/screens/transaction_details/transaction_details_page.dart +++ b/lib/src/screens/transaction_details/transaction_details_page.dart @@ -1,5 +1,6 @@ import 'package:cake_wallet/src/screens/transaction_details/textfield_list_item.dart'; import 'package:cake_wallet/src/screens/transaction_details/widgets/textfield_list_row.dart'; +import 'package:cake_wallet/src/widgets/standard_list.dart'; import 'package:cake_wallet/utils/show_bar.dart'; import 'package:cake_wallet/view_model/transaction_details_view_model.dart'; import 'package:flutter/material.dart'; @@ -19,50 +20,34 @@ class TransactionDetailsPage extends BasePage { @override Widget body(BuildContext context) { - return Container( - child: ListView.separated( - separatorBuilder: (context, index) => Container( - height: 1, - padding: EdgeInsets.only(left: 24), - color: Theme.of(context).backgroundColor, - child: Container( - height: 1, - color: - Theme.of(context).primaryTextTheme.title.backgroundColor, - ), - ), - itemCount: transactionDetailsViewModel.items.length, - itemBuilder: (context, index) { - final item = transactionDetailsViewModel.items[index]; - final isDrawBottom = - index == transactionDetailsViewModel.items.length - 1 - ? true : false; + return SectionStandardList( + sectionCount: 1, + itemCounter: (int _) => transactionDetailsViewModel.items.length, + itemBuilder: (_, __, index) { + final item = transactionDetailsViewModel.items[index]; - if (item is StandartListItem) { - return GestureDetector( - onTap: () { - Clipboard.setData(ClipboardData(text: item.value)); - showBar(context, - S.of(context).transaction_details_copied(item.title)); - }, - child: StandartListRow( - title: '${item.title}:', - value: item.value, - isDrawBottom: isDrawBottom), - ); - } + if (item is StandartListItem) { + return GestureDetector( + onTap: () { + Clipboard.setData(ClipboardData(text: item.value)); + showBar(context, + S.of(context).transaction_details_copied(item.title)); + }, + child: StandartListRow( + title: '${item.title}:', + value: item.value), + ); + } - if (item is TextFieldListItem) { - return TextFieldListRow( - title: item.title, - value: item.value, - onSubmitted: item.onSubmitted, - isDrawBottom: isDrawBottom, - ); - } + if (item is TextFieldListItem) { + return TextFieldListRow( + title: item.title, + value: item.value, + onSubmitted: item.onSubmitted, + ); + } - return null; - }), - ); + return null; + }); } } diff --git a/lib/src/screens/transaction_details/widgets/textfield_list_row.dart b/lib/src/screens/transaction_details/widgets/textfield_list_row.dart index 92e1fb601..777f9bbfa 100644 --- a/lib/src/screens/transaction_details/widgets/textfield_list_row.dart +++ b/lib/src/screens/transaction_details/widgets/textfield_list_row.dart @@ -8,8 +8,7 @@ class TextFieldListRow extends StatelessWidget { this.value, this.titleFontSize = 14, this.valueFontSize = 16, - this.onSubmitted, - this.isDrawBottom = false}) { + this.onSubmitted}) { _textController = TextEditingController(); _textController.text = value; @@ -20,69 +19,53 @@ class TextFieldListRow extends StatelessWidget { final double titleFontSize; final double valueFontSize; final Function(String value) onSubmitted; - final bool isDrawBottom; TextEditingController _textController; @override Widget build(BuildContext context) { - return Column( - children: [ - Container( - width: double.infinity, - color: Theme.of(context).backgroundColor, - child: Padding( - padding: - const EdgeInsets.only(left: 24, top: 16, bottom: 16, right: 24), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(title, - style: TextStyle( - fontSize: titleFontSize, - fontWeight: FontWeight.w500, - color: Theme.of(context) - .primaryTextTheme.overline.color), - textAlign: TextAlign.left), - TextField( - controller: _textController, - keyboardType: TextInputType.multiline, - textInputAction: TextInputAction.done, - maxLines: null, - textAlign: TextAlign.start, - style: TextStyle( + return Container( + width: double.infinity, + color: Theme.of(context).backgroundColor, + child: Padding( + padding: + const EdgeInsets.only(left: 24, top: 16, bottom: 16, right: 24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(title, + style: TextStyle( + fontSize: titleFontSize, + fontWeight: FontWeight.w500, + color: Theme.of(context) + .primaryTextTheme.overline.color), + textAlign: TextAlign.left), + TextField( + controller: _textController, + keyboardType: TextInputType.multiline, + textInputAction: TextInputAction.done, + maxLines: null, + textAlign: TextAlign.start, + style: TextStyle( + fontSize: valueFontSize, + fontWeight: FontWeight.w500, + color: Theme.of(context) + .primaryTextTheme.title.color), + decoration: InputDecoration( + isDense: true, + contentPadding: EdgeInsets.only(top: 12, bottom: 0), + hintText: S.of(context).enter_your_note, + hintStyle: TextStyle( fontSize: valueFontSize, fontWeight: FontWeight.w500, color: Theme.of(context) - .primaryTextTheme.title.color), - decoration: InputDecoration( - isDense: true, - contentPadding: EdgeInsets.only(top: 12, bottom: 0), - hintText: S.of(context).enter_your_note, - hintStyle: TextStyle( - fontSize: valueFontSize, - fontWeight: FontWeight.w500, - color: Theme.of(context) - .primaryTextTheme.overline.color), - border: InputBorder.none - ), - onSubmitted: (value) => onSubmitted.call(value), - ) - ]), - ), - ), - isDrawBottom - ? Container( - height: 1, - padding: EdgeInsets.only(left: 24), - color: Theme.of(context).backgroundColor, - child: Container( - height: 1, - color: Theme.of(context).primaryTextTheme.title.backgroundColor, - ), - ) - : Offstage(), - ], + .primaryTextTheme.overline.color), + border: InputBorder.none + ), + onSubmitted: (value) => onSubmitted.call(value), + ) + ]), + ), ); } } diff --git a/lib/src/widgets/standart_list_row.dart b/lib/src/widgets/standart_list_row.dart index d29e84065..4ed0ac4c9 100644 --- a/lib/src/widgets/standart_list_row.dart +++ b/lib/src/widgets/standart_list_row.dart @@ -7,77 +7,60 @@ class StandartListRow extends StatelessWidget { this.value, this.titleFontSize = 14, this.valueFontSize = 16, - this.image, - this.isDrawBottom = false}); + this.image}); final String title; final String value; final double titleFontSize; final double valueFontSize; final Image image; - final bool isDrawBottom; @override Widget build(BuildContext context) { - return Column( - children: [ - Container( - width: double.infinity, - color: Theme.of(context).backgroundColor, - child: Padding( - padding: - const EdgeInsets.only(left: 24, top: 16, bottom: 16, right: 24), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(title, - style: TextStyle( - fontSize: titleFontSize, - fontWeight: FontWeight.w500, - color: - Theme.of(context).primaryTextTheme.overline.color), - textAlign: TextAlign.left), - Padding( - padding: const EdgeInsets.only(top: 12), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Text(value, - style: TextStyle( - fontSize: valueFontSize, - fontWeight: FontWeight.w500, - color: Theme.of(context) - .primaryTextTheme - .title - .color)), - ), - image != null - ? Padding( - padding: EdgeInsets.only(left: 24), - child: image, - ) - : Offstage() - ], + return Container( + width: double.infinity, + color: Theme.of(context).backgroundColor, + child: Padding( + padding: + const EdgeInsets.only(left: 24, top: 16, bottom: 16, right: 24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(title, + style: TextStyle( + fontSize: titleFontSize, + fontWeight: FontWeight.w500, + color: + Theme.of(context).primaryTextTheme.overline.color), + textAlign: TextAlign.left), + Padding( + padding: const EdgeInsets.only(top: 12), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text(value, + style: TextStyle( + fontSize: valueFontSize, + fontWeight: FontWeight.w500, + color: Theme.of(context) + .primaryTextTheme + .title + .color)), ), - ) - ]), - ), - ), - isDrawBottom - ? Container( - height: 1, - padding: EdgeInsets.only(left: 24), - color: Theme.of(context).backgroundColor, - child: Container( - height: 1, - color: Theme.of(context).primaryTextTheme.title.backgroundColor, - ), - ) - : Offstage(), - ], + image != null + ? Padding( + padding: EdgeInsets.only(left: 24), + child: image, + ) + : Offstage() + ], + ), + ) + ]), + ), ); } } diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 420586997..37177311f 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -231,6 +231,8 @@ abstract class DashboardViewModelBase with Store { _onMoneroTransactionsUpdate(wallet); } else { + subname = null; + transactions.clear(); transactions.addAll(wallet.transactionHistory.transactions.values.map(