mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-12 09:32:33 +00:00
add loan details page
This commit is contained in:
parent
336a0e2fec
commit
60643d940a
12 changed files with 539 additions and 384 deletions
20
lib/di.dart
20
lib/di.dart
|
@ -2,6 +2,10 @@ import 'package:cake_wallet/entities/wake_lock.dart';
|
|||
import 'package:cake_wallet/monero/monero.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/src/screens/loan/loan_account_page.dart';
|
||||
import 'package:cake_wallet/src/screens/loan/loan_detail_page.dart';
|
||||
import 'package:cake_wallet/view_model/loan/loan_account_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/loan/loan_detail_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/loan/loan_item.dart';
|
||||
import 'package:cw_core/unspent_coins_info.dart';
|
||||
import 'package:cake_wallet/core/backup_service.dart';
|
||||
import 'package:cw_core/wallet_service.dart';
|
||||
|
@ -624,7 +628,21 @@ Future setup(
|
|||
|
||||
getIt.registerFactory(() => WakeLock());
|
||||
|
||||
getIt.registerFactory(() => LoanAccountPage());
|
||||
getIt.registerFactory<LoanAccountViewModel>(
|
||||
() => LoanAccountViewModel(wallet: getIt.get<AppStore>().wallet));
|
||||
|
||||
getIt.registerFactory(() =>
|
||||
LoanAccountPage(loanAccountViewModel: getIt.get<LoanAccountViewModel>()));
|
||||
|
||||
getIt.registerFactoryParam<LoanDetailViewModel, LoanItem, void>(
|
||||
(LoanItem loanDetail, _) {
|
||||
return LoanDetailViewModel(loanItem: loanDetail);
|
||||
});
|
||||
|
||||
getIt.registerFactoryParam<LoanDetailPage, LoanItem, void>(
|
||||
(LoanItem loanItem, _) => LoanDetailPage(
|
||||
loanDetailViewModel:
|
||||
getIt.get<LoanDetailViewModel>(param1: loanItem)));
|
||||
|
||||
_isSetupFinished = true;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import 'package:cake_wallet/entities/contact_record.dart';
|
||||
import 'package:cake_wallet/buy/order.dart';
|
||||
import 'package:cake_wallet/entities/transaction_description.dart';
|
||||
import 'package:cake_wallet/src/screens/backup/backup_page.dart';
|
||||
import 'package:cake_wallet/src/screens/backup/edit_backup_password_page.dart';
|
||||
import 'package:cake_wallet/src/screens/buy/buy_webview_page.dart';
|
||||
import 'package:cake_wallet/src/screens/buy/pre_order_page.dart';
|
||||
import 'package:cake_wallet/src/screens/loan/loan_account_page.dart';
|
||||
import 'package:cake_wallet/src/screens/loan/loan_detail_page.dart';
|
||||
import 'package:cake_wallet/src/screens/order_details/order_details_page.dart';
|
||||
import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
|
||||
import 'package:cake_wallet/src/screens/restore/restore_from_backup_page.dart';
|
||||
|
@ -14,10 +14,8 @@ import 'package:cake_wallet/src/screens/seed/pre_seed_page.dart';
|
|||
import 'package:cake_wallet/src/screens/support/support_page.dart';
|
||||
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_details_page.dart';
|
||||
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_list_page.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/view_model/buy/buy_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/loan/loan_item.dart';
|
||||
import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart';
|
||||
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_item.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
|
@ -27,7 +25,6 @@ import 'package:cake_wallet/utils/language_list.dart';
|
|||
import 'package:cake_wallet/view_model/wallet_new_vm.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_restoration_from_keys_vm.dart';
|
||||
import 'package:cake_wallet/entities/contact.dart';
|
||||
import 'package:cake_wallet/exchange/trade.dart';
|
||||
import 'package:cw_core/transaction_info.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
|
@ -67,7 +64,6 @@ import 'package:cake_wallet/src/screens/exchange/exchange_template_page.dart';
|
|||
import 'package:cake_wallet/src/screens/exchange_trade/exchange_confirm_page.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_page.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cake_wallet/wallet_type_utils.dart';
|
||||
|
||||
RouteSettings currentRouteSettings;
|
||||
|
@ -401,6 +397,10 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
return CupertinoPageRoute<void>(
|
||||
fullscreenDialog: true, builder: (_) => getIt.get<LoanAccountPage>());
|
||||
|
||||
case Routes.loanDetails:
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (_) =>
|
||||
getIt.get<LoanDetailPage>(param1: settings.arguments as LoanItem));
|
||||
|
||||
default:
|
||||
return MaterialPageRoute<void>(
|
||||
|
|
|
@ -8,7 +8,8 @@ class Routes {
|
|||
static const restoreOptions = '/restore_options';
|
||||
static const restoreOptionsFromWelcome = '/restore_options_from_welcome';
|
||||
static const restoreWalletOptions = '/restore_seed_keys';
|
||||
static const restoreWalletOptionsFromWelcome = '/restore_wallet_options_from_welcome';
|
||||
static const restoreWalletOptionsFromWelcome =
|
||||
'/restore_wallet_options_from_welcome';
|
||||
static const restoreWalletFromSeed = '/restore_wallet_from_seed';
|
||||
static const restoreWalletFromKeys = '/restore_wallet_from_keys';
|
||||
static const dashboard = '/dashboard';
|
||||
|
@ -60,4 +61,5 @@ class Routes {
|
|||
static const moneroRestoreWalletFromWelcome = '/monero_restore_wallet';
|
||||
static const moneroNewWalletFromWelcome = '/monero_new_wallet';
|
||||
static const loanAccount = '/loan_account';
|
||||
}
|
||||
static const loanDetails = '/loan_details';
|
||||
}
|
||||
|
|
|
@ -1,26 +1,37 @@
|
|||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/screens/dashboard/widgets/action_button.dart';
|
||||
import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator_icon.dart';
|
||||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||
import 'package:cake_wallet/src/screens/loan/widgets/loan_list_item.dart';
|
||||
import 'package:cake_wallet/src/screens/loan/widgets/loan_login_section.dart';
|
||||
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
import 'package:cake_wallet/view_model/loan/loan_account_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:keyboard_actions/keyboard_actions.dart';
|
||||
|
||||
class LoanAccountPage extends BasePage {
|
||||
LoanAccountPage({Key key});
|
||||
LoanAccountPage({@required this.loanAccountViewModel})
|
||||
: _emailFocus = FocusNode(),
|
||||
_emailController = TextEditingController(),
|
||||
_codeFocus = FocusNode(),
|
||||
_codeController = TextEditingController();
|
||||
|
||||
final LoanAccountViewModel loanAccountViewModel;
|
||||
|
||||
final FocusNode _emailFocus;
|
||||
final TextEditingController _emailController;
|
||||
|
||||
final FocusNode _codeFocus;
|
||||
final TextEditingController _codeController;
|
||||
|
||||
@override
|
||||
String get title => 'Loan Account';
|
||||
|
||||
@override
|
||||
Color get titleColor => Colors.white;
|
||||
|
||||
@override
|
||||
bool get resizeToAvoidBottomInset => false;
|
||||
|
||||
@override
|
||||
bool get extendBodyBehindAppBar => true;
|
||||
|
||||
|
@ -36,336 +47,139 @@ class LoanAccountPage extends BasePage {
|
|||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 20.0),
|
||||
child: SyncIndicatorIcon(isSynced: false),
|
||||
child: Observer(
|
||||
builder: (_) =>
|
||||
SyncIndicatorIcon(isSynced: loanAccountViewModel.status),
|
||||
),
|
||||
),
|
||||
super.middle(context),
|
||||
],
|
||||
);
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
return ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 14),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(24),
|
||||
bottomRight: Radius.circular(24)),
|
||||
gradient: LinearGradient(colors: [
|
||||
Theme.of(context).primaryTextTheme.subhead.color,
|
||||
Theme.of(context).primaryTextTheme.subhead.decorationColor,
|
||||
], begin: Alignment.topLeft, end: Alignment.bottomRight),
|
||||
return KeyboardActions(
|
||||
config: KeyboardActionsConfig(
|
||||
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
|
||||
keyboardBarColor:
|
||||
Theme.of(context).accentTextTheme.body2.backgroundColor,
|
||||
nextFocus: false,
|
||||
actions: [
|
||||
KeyboardActionsItem(
|
||||
focusNode: _emailFocus,
|
||||
toolbarButtons: [(_) => KeyboardDoneButton()],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(height: 150),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: BaseTextFormField(
|
||||
textColor: Colors.white,
|
||||
hintText: 'Email OR Phone Number',
|
||||
placeholderTextStyle:
|
||||
TextStyle(color: Colors.white54),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 90,
|
||||
child: PrimaryButton(
|
||||
onPressed: () {},
|
||||
text: 'Get code',
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
radius: 6,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 37),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: BaseTextFormField(
|
||||
textColor: Colors.white,
|
||||
hintText: 'SMS / Email Code',
|
||||
placeholderTextStyle:
|
||||
TextStyle(color: Colors.white54),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
SizedBox(
|
||||
width: 70,
|
||||
child: PrimaryButton(
|
||||
onPressed: () {},
|
||||
text: 'Verify',
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
radius: 6,
|
||||
textColor: Colors.white),
|
||||
),
|
||||
SizedBox(width: 10)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 100),
|
||||
],
|
||||
KeyboardActionsItem(
|
||||
focusNode: _codeFocus,
|
||||
toolbarButtons: [(_) => KeyboardDoneButton()],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
]),
|
||||
child: Container(
|
||||
height: 0,
|
||||
color: Theme.of(context).backgroundColor,
|
||||
child: ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: Column(
|
||||
children: [
|
||||
SizedBox(height: 40),
|
||||
Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
dividerColor: Colors.transparent,
|
||||
hoverColor: Colors.transparent,
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 14),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(24),
|
||||
bottomRight: Radius.circular(24)),
|
||||
gradient: LinearGradient(colors: [
|
||||
Theme.of(context).primaryTextTheme.subhead.color,
|
||||
Theme.of(context).primaryTextTheme.subhead.decorationColor,
|
||||
], begin: Alignment.topLeft, end: Alignment.bottomRight),
|
||||
),
|
||||
child: ExpansionTile(
|
||||
initiallyExpanded: true,
|
||||
trailing: Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
color: textColor,
|
||||
size: 30,
|
||||
),
|
||||
childrenPadding: EdgeInsets.symmetric(horizontal: 20),
|
||||
title: Text(
|
||||
'My Lending/Earning',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: textColor,
|
||||
fontSize: 24,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(
|
||||
'Log in above to lend',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: textColor,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 130),
|
||||
Observer(builder: (_) {
|
||||
final isLoggedIn = loanAccountViewModel.isLoggedIn;
|
||||
if (isLoggedIn) return SizedBox(width: double.infinity);
|
||||
return LoanLoginSection(
|
||||
emailController: _emailController,
|
||||
emailFocus: _emailFocus,
|
||||
codeFocus: _codeFocus,
|
||||
codeController: _codeController,
|
||||
);
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
dividerColor: Colors.transparent,
|
||||
hoverColor: Colors.transparent,
|
||||
),
|
||||
child: ExpansionTile(
|
||||
initiallyExpanded: true,
|
||||
trailing: Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
color: textColor,
|
||||
size: 30,
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(height: 40),
|
||||
LoanListItem(
|
||||
textColor: textColor,
|
||||
title: 'My Lending/Earning',
|
||||
loginText: 'Log in above to lend',
|
||||
loanAccountViewModel: loanAccountViewModel,
|
||||
emptyListText: 'No open lendings/earnings yet',
|
||||
),
|
||||
childrenPadding: EdgeInsets.symmetric(horizontal: 20),
|
||||
title: Text(
|
||||
'My Borrowing',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: textColor,
|
||||
fontSize: 24,
|
||||
),
|
||||
LoanListItem(
|
||||
textColor: textColor,
|
||||
title: 'My Borrowing',
|
||||
loginText: 'Log in above to borrow with collateral',
|
||||
emptyListText: 'No open loans yet',
|
||||
loanAccountViewModel: loanAccountViewModel,
|
||||
),
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(
|
||||
'Log in above to borrow with collateral',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: textColor,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
Table(),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
bottomSection: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () {},
|
||||
text: 'Lend and Earn Interest',
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
text: 'By logging in, you agree to the ',
|
||||
style: TextStyle(color: Color(0xff7A93BA), fontSize: 12),
|
||||
bottomSection: Observer(builder: (_) {
|
||||
return Column(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'Terms and Conditions',
|
||||
style: TextStyle(decoration: TextDecoration.underline),
|
||||
),
|
||||
TextSpan(text: ' and '),
|
||||
TextSpan(
|
||||
text: 'Privacy Policy of CoinRabbit',
|
||||
style: TextStyle(decoration: TextDecoration.underline),
|
||||
)
|
||||
if (loanAccountViewModel.isLoggedIn) ...[
|
||||
SizedBox(height: 20),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () {},
|
||||
text: 'Lend and Earn Interest',
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () {},
|
||||
text: ' Borrow with Collateral',
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
] else
|
||||
RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
text: 'By logging in, you agree to the ',
|
||||
style: TextStyle(color: Color(0xff7A93BA), fontSize: 12),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'Terms and Conditions',
|
||||
style:
|
||||
TextStyle(decoration: TextDecoration.underline),
|
||||
),
|
||||
TextSpan(text: ' and '),
|
||||
TextSpan(
|
||||
text: 'Privacy Policy of CoinRabbit',
|
||||
style:
|
||||
TextStyle(decoration: TextDecoration.underline),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10)
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Table extends StatelessWidget {
|
||||
const Table({Key key}) : super(key: key);
|
||||
|
||||
Color get textColor =>
|
||||
getIt.get<SettingsStore>().currentTheme.type == ThemeType.dark
|
||||
? Colors.white
|
||||
: Color(0xff393939);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'ID',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Amount',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Status',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 25),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Color(0xffF1EDFF),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'5395821325',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'10000 USDT',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Awaiting deposit',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Color(0xffF1EDFF),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'5395821325',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'10000 USDT',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Awaiting deposit',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Color(0xffF1EDFF),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'5395821325',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'10000 USDT',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Awaiting deposit',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
14
lib/src/screens/loan/loan_detail_page.dart
Normal file
14
lib/src/screens/loan/loan_detail_page.dart
Normal file
|
@ -0,0 +1,14 @@
|
|||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/view_model/loan/loan_detail_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LoanDetailPage extends BasePage {
|
||||
LoanDetailPage({this.loanDetailViewModel});
|
||||
|
||||
final LoanDetailViewModel loanDetailViewModel;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
69
lib/src/screens/loan/widgets/loan_list_item.dart
Normal file
69
lib/src/screens/loan/widgets/loan_list_item.dart
Normal file
|
@ -0,0 +1,69 @@
|
|||
import 'package:cake_wallet/src/screens/loan/widgets/loan_table.dart';
|
||||
import 'package:cake_wallet/view_model/loan/loan_account_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
|
||||
class LoanListItem extends StatelessWidget {
|
||||
const LoanListItem({
|
||||
Key key,
|
||||
@required this.textColor,
|
||||
@required this.title,
|
||||
@required this.loginText,
|
||||
@required this.loanAccountViewModel,
|
||||
@required this.emptyListText,
|
||||
}) : super(key: key);
|
||||
|
||||
final Color textColor;
|
||||
final String title;
|
||||
final String loginText;
|
||||
final String emptyListText;
|
||||
final LoanAccountViewModel loanAccountViewModel;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
dividerColor: Colors.transparent,
|
||||
hoverColor: Colors.transparent,
|
||||
),
|
||||
child: Observer(builder: (_) {
|
||||
return ExpansionTile(
|
||||
initiallyExpanded: true,
|
||||
trailing: Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
color: textColor,
|
||||
size: 30,
|
||||
),
|
||||
childrenPadding: EdgeInsets.symmetric(horizontal: 20),
|
||||
title: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: textColor,
|
||||
fontSize: 24,
|
||||
),
|
||||
),
|
||||
children: [
|
||||
if (!loanAccountViewModel.isLoggedIn)
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(
|
||||
loginText,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: textColor,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
LoanTable(
|
||||
loanItems: loanAccountViewModel.items,
|
||||
emptyListText: emptyListText,
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
81
lib/src/screens/loan/widgets/loan_login_section.dart
Normal file
81
lib/src/screens/loan/widgets/loan_login_section.dart
Normal file
|
@ -0,0 +1,81 @@
|
|||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LoanLoginSection extends StatelessWidget {
|
||||
const LoanLoginSection({
|
||||
@required this.emailFocus,
|
||||
@required this.codeFocus,
|
||||
@required this.emailController,
|
||||
@required this.codeController,
|
||||
});
|
||||
|
||||
final FocusNode emailFocus;
|
||||
final TextEditingController emailController;
|
||||
|
||||
final FocusNode codeFocus;
|
||||
final TextEditingController codeController;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: BaseTextFormField(
|
||||
textColor: Colors.white,
|
||||
hintText: 'Email OR Phone Number',
|
||||
focusNode: emailFocus,
|
||||
controller: emailController,
|
||||
placeholderTextStyle: TextStyle(color: Colors.white54),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 90,
|
||||
child: PrimaryButton(
|
||||
onPressed: () {},
|
||||
text: 'Get code',
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
radius: 6,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 37),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: BaseTextFormField(
|
||||
textColor: Colors.white,
|
||||
hintText: 'SMS / Email Code',
|
||||
focusNode: codeFocus,
|
||||
controller: codeController,
|
||||
placeholderTextStyle: TextStyle(color: Colors.white54),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
SizedBox(
|
||||
width: 70,
|
||||
child: PrimaryButton(
|
||||
onPressed: () {},
|
||||
text: 'Verify',
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
radius: 6,
|
||||
textColor: Colors.white),
|
||||
),
|
||||
SizedBox(width: 10)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 100),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
112
lib/src/screens/loan/widgets/loan_table.dart
Normal file
112
lib/src/screens/loan/widgets/loan_table.dart
Normal file
|
@ -0,0 +1,112 @@
|
|||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
import 'package:cake_wallet/view_model/loan/loan_item.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LoanTable extends StatelessWidget {
|
||||
LoanTable({
|
||||
@required this.loanItems,
|
||||
@required this.emptyListText,
|
||||
});
|
||||
final List<LoanItem> loanItems;
|
||||
final String emptyListText;
|
||||
|
||||
Color get textColor =>
|
||||
getIt.get<SettingsStore>().currentTheme.type == ThemeType.dark
|
||||
? Colors.white
|
||||
: Color(0xff393939);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final items = loanItems;
|
||||
if (items == null || items.isEmpty)
|
||||
return Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: Text(
|
||||
emptyListText,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: textColor,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'ID',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Amount',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Status',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 25),
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
for (var i = 0; i < items.length; i++) ...[
|
||||
InkWell(
|
||||
onTap: ()=>Navigator.of(context).pushNamed(
|
||||
Routes.loanDetails,
|
||||
arguments: items[i]),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Color(0xffF1EDFF),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'5395821325',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'10000 USDT',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Awaiting deposit',
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
]
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ class PrimaryButton extends StatelessWidget {
|
|||
this.isDisabled = false,
|
||||
this.isDottedBorder = false,
|
||||
this.borderColor = Colors.black,
|
||||
this.radius,
|
||||
this.radius = 26.0,
|
||||
this.onDisabledPressed});
|
||||
|
||||
final VoidCallback onPressed;
|
||||
|
@ -45,9 +45,7 @@ class PrimaryButton extends StatelessWidget {
|
|||
style: TextStyle(
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isDisabled
|
||||
? textColor.withOpacity(0.5)
|
||||
: textColor)),
|
||||
color: isDisabled ? textColor.withOpacity(0.5) : textColor)),
|
||||
));
|
||||
|
||||
return isDottedBorder
|
||||
|
@ -65,11 +63,11 @@ class PrimaryButton extends StatelessWidget {
|
|||
class LoadingPrimaryButton extends StatelessWidget {
|
||||
const LoadingPrimaryButton(
|
||||
{@required this.onPressed,
|
||||
@required this.text,
|
||||
@required this.color,
|
||||
@required this.textColor,
|
||||
this.isDisabled = false,
|
||||
this.isLoading = false});
|
||||
@required this.text,
|
||||
@required this.color,
|
||||
@required this.textColor,
|
||||
this.isDisabled = false,
|
||||
this.isLoading = false});
|
||||
|
||||
final VoidCallback onPressed;
|
||||
final Color color;
|
||||
|
@ -87,35 +85,32 @@ class LoadingPrimaryButton extends StatelessWidget {
|
|||
onPressed: (isLoading || isDisabled) ? null : onPressed,
|
||||
color: color,
|
||||
disabledColor: color.withOpacity(0.5),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(26.0)),
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(26.0)),
|
||||
child: isLoading
|
||||
? CupertinoActivityIndicator(animating: true)
|
||||
: Text(text,
|
||||
style: TextStyle(
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isDisabled
|
||||
? textColor.withOpacity(0.5)
|
||||
: textColor
|
||||
)),
|
||||
style: TextStyle(
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color:
|
||||
isDisabled ? textColor.withOpacity(0.5) : textColor)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class PrimaryIconButton extends StatelessWidget {
|
||||
const PrimaryIconButton({
|
||||
@required this.onPressed,
|
||||
@required this.iconData,
|
||||
@required this.text,
|
||||
@required this.color,
|
||||
@required this.borderColor,
|
||||
@required this.iconColor,
|
||||
@required this.iconBackgroundColor,
|
||||
@required this.textColor,
|
||||
this.mainAxisAlignment = MainAxisAlignment.start,
|
||||
this.radius = 26
|
||||
});
|
||||
const PrimaryIconButton(
|
||||
{@required this.onPressed,
|
||||
@required this.iconData,
|
||||
@required this.text,
|
||||
@required this.color,
|
||||
@required this.borderColor,
|
||||
@required this.iconColor,
|
||||
@required this.iconBackgroundColor,
|
||||
@required this.textColor,
|
||||
this.mainAxisAlignment = MainAxisAlignment.start,
|
||||
this.radius = 26});
|
||||
|
||||
final VoidCallback onPressed;
|
||||
final IconData iconData;
|
||||
|
@ -150,8 +145,7 @@ class PrimaryIconButton extends StatelessWidget {
|
|||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle, color: iconBackgroundColor),
|
||||
child: Center(
|
||||
child: Icon(iconData, color: iconColor, size: 22.0)
|
||||
),
|
||||
child: Icon(iconData, color: iconColor, size: 22.0)),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -159,9 +153,7 @@ class PrimaryIconButton extends StatelessWidget {
|
|||
height: 52.0,
|
||||
child: Center(
|
||||
child: Text(text,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: textColor)),
|
||||
style: TextStyle(fontSize: 16.0, color: textColor)),
|
||||
),
|
||||
)
|
||||
],
|
||||
|
@ -192,28 +184,26 @@ class PrimaryImageButton extends StatelessWidget {
|
|||
minWidth: double.infinity,
|
||||
height: 52.0,
|
||||
child: FlatButton(
|
||||
onPressed: onPressed,
|
||||
color: color,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(color: borderColor),
|
||||
borderRadius: BorderRadius.circular(26.0)),
|
||||
child:Center(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
image,
|
||||
SizedBox(width: 15),
|
||||
Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: textColor
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
));
|
||||
onPressed: onPressed,
|
||||
color: color,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(color: borderColor),
|
||||
borderRadius: BorderRadius.circular(26.0)),
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
image,
|
||||
SizedBox(width: 15),
|
||||
Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: textColor),
|
||||
)
|
||||
],
|
||||
),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
|
36
lib/view_model/loan/loan_account_view_model.dart
Normal file
36
lib/view_model/loan/loan_account_view_model.dart
Normal file
|
@ -0,0 +1,36 @@
|
|||
import 'package:cake_wallet/view_model/loan/loan_item.dart';
|
||||
import 'package:cw_core/sync_status.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
part 'loan_account_view_model.g.dart';
|
||||
|
||||
class LoanAccountViewModel = LoanAccountViewModelBase
|
||||
with _$LoanAccountViewModel;
|
||||
|
||||
abstract class LoanAccountViewModelBase with Store {
|
||||
LoanAccountViewModelBase({this.wallet}) {
|
||||
isLoggedIn = false;
|
||||
_fetchLoanItems();
|
||||
}
|
||||
|
||||
final WalletBase wallet;
|
||||
|
||||
@computed
|
||||
bool get status => wallet.syncStatus is SyncedSyncStatus;
|
||||
|
||||
@observable
|
||||
bool isLoggedIn;
|
||||
|
||||
@observable
|
||||
List<LoanItem> items;
|
||||
|
||||
Future<void> _fetchLoanItems() async {
|
||||
await Future<void>.delayed(Duration(seconds: 5));
|
||||
isLoggedIn = true;
|
||||
items = [
|
||||
LoanItem(id: '2133432', amount: 20000, status: 'Awaiting deposit'),
|
||||
LoanItem(id: '2133432', amount: 20000, status: 'Awaiting deposit'),
|
||||
LoanItem(id: '2133432', amount: 20000, status: 'Awaiting deposit')
|
||||
];
|
||||
}
|
||||
}
|
13
lib/view_model/loan/loan_detail_view_model.dart
Normal file
13
lib/view_model/loan/loan_detail_view_model.dart
Normal file
|
@ -0,0 +1,13 @@
|
|||
import 'package:cake_wallet/view_model/loan/loan_item.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
part 'loan_detail_view_model.g.dart';
|
||||
|
||||
class LoanDetailViewModel = LoanDetailViewModelBase with _$LoanDetailViewModel;
|
||||
|
||||
abstract class LoanDetailViewModelBase with Store {
|
||||
LoanDetailViewModelBase({LoanItem loanItem}) {
|
||||
loanDetails = loanItem;
|
||||
}
|
||||
|
||||
LoanItem loanDetails;
|
||||
}
|
6
lib/view_model/loan/loan_item.dart
Normal file
6
lib/view_model/loan/loan_item.dart
Normal file
|
@ -0,0 +1,6 @@
|
|||
class LoanItem {
|
||||
LoanItem({this.id, this.amount, this.status});
|
||||
final String id;
|
||||
final double amount;
|
||||
final String status;
|
||||
}
|
Loading…
Reference in a new issue