mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
add lend page
This commit is contained in:
parent
d18d007f6a
commit
f1ec47e650
6 changed files with 148 additions and 1 deletions
|
@ -3,8 +3,10 @@ import 'package:cake_wallet/monero/monero.dart';
|
||||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||||
import 'package:cake_wallet/src/screens/loan/confirm_deposit_page.dart';
|
import 'package:cake_wallet/src/screens/loan/confirm_deposit_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/loan/increase_deposit_page.dart';
|
import 'package:cake_wallet/src/screens/loan/increase_deposit_page.dart';
|
||||||
|
import 'package:cake_wallet/src/screens/loan/lend_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/loan/loan_account_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/loan/loan_detail_page.dart';
|
||||||
|
import 'package:cake_wallet/view_model/loan/lend_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/loan/loan_account_view_model.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_detail_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/loan/loan_item.dart';
|
import 'package:cake_wallet/view_model/loan/loan_item.dart';
|
||||||
|
@ -656,5 +658,10 @@ Future setup(
|
||||||
|
|
||||||
getIt.registerFactory(() => ConfirmDepositPage());
|
getIt.registerFactory(() => ConfirmDepositPage());
|
||||||
|
|
||||||
|
getIt.registerFactory<LendViewModel>(
|
||||||
|
() => LendViewModel(wallet: getIt.get<AppStore>().wallet));
|
||||||
|
|
||||||
|
getIt.registerFactory(() => LendPage(lendViewModel: getIt.get<LendViewModel>()));
|
||||||
|
|
||||||
_isSetupFinished = true;
|
_isSetupFinished = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ 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/buy/pre_order_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/loan/confirm_deposit_page.dart';
|
import 'package:cake_wallet/src/screens/loan/confirm_deposit_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/loan/increase_deposit_page.dart';
|
import 'package:cake_wallet/src/screens/loan/increase_deposit_page.dart';
|
||||||
|
import 'package:cake_wallet/src/screens/loan/lend_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/loan/loan_account_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/loan/loan_detail_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/order_details/order_details_page.dart';
|
import 'package:cake_wallet/src/screens/order_details/order_details_page.dart';
|
||||||
|
@ -412,6 +413,11 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
||||||
case Routes.confirmDepositPage:
|
case Routes.confirmDepositPage:
|
||||||
return CupertinoPageRoute<void>(
|
return CupertinoPageRoute<void>(
|
||||||
builder: (_) => getIt.get<ConfirmDepositPage>());
|
builder: (_) => getIt.get<ConfirmDepositPage>());
|
||||||
|
|
||||||
|
case Routes.earnInterest:
|
||||||
|
return CupertinoPageRoute<void>(
|
||||||
|
builder: (_) => getIt.get<LendPage>());
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return MaterialPageRoute<void>(
|
return MaterialPageRoute<void>(
|
||||||
builder: (_) => Scaffold(
|
builder: (_) => Scaffold(
|
||||||
|
|
|
@ -64,4 +64,5 @@ class Routes {
|
||||||
static const loanDetails = '/loan_details';
|
static const loanDetails = '/loan_details';
|
||||||
static const increaseDeposit = '/increase_deposit';
|
static const increaseDeposit = '/increase_deposit';
|
||||||
static const confirmDepositPage = '/confrim_deposit';
|
static const confirmDepositPage = '/confrim_deposit';
|
||||||
|
static const earnInterest = '/earn_interest';
|
||||||
}
|
}
|
||||||
|
|
109
lib/src/screens/loan/lend_page.dart
Normal file
109
lib/src/screens/loan/lend_page.dart
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||||
|
import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator_icon.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/trail_button.dart';
|
||||||
|
import 'package:cake_wallet/themes/theme_base.dart';
|
||||||
|
import 'package:cake_wallet/view_model/loan/lend_view_model.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
|
|
||||||
|
class LendPage extends BasePage {
|
||||||
|
LendPage({@required this.lendViewModel}) : _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
final GlobalKey<FormState> _formKey;
|
||||||
|
|
||||||
|
final LendViewModel lendViewModel;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get title => 'Lend';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get titleColor => Colors.white;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get extendBodyBehindAppBar => true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
AppBarStyle get appBarStyle => AppBarStyle.transparent;
|
||||||
|
|
||||||
|
Color get textColor =>
|
||||||
|
currentTheme.type == ThemeType.dark ? Colors.white : Color(0xff393939);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget middle(BuildContext context) => Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 20.0),
|
||||||
|
child: Observer(
|
||||||
|
builder: (_) =>
|
||||||
|
SyncIndicatorIcon(isSynced: lendViewModel.status),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontFamily: 'Poppins',
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget trailing(context) => Observer(builder: (_) {
|
||||||
|
return TrailButton(
|
||||||
|
caption: S.of(context).clear,
|
||||||
|
onPressed: () {
|
||||||
|
_formKey.currentState.reset();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget body(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
color: Theme.of(context).backgroundColor,
|
||||||
|
child: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: ScrollableWithBottomSection(
|
||||||
|
contentPadding: EdgeInsets.only(bottom: 24),
|
||||||
|
content: Observer(
|
||||||
|
builder: (_) => Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: EdgeInsets.only(bottom: 32),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
bottomLeft: Radius.circular(24),
|
||||||
|
bottomRight: Radius.circular(24)),
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Theme.of(context)
|
||||||
|
.primaryTextTheme
|
||||||
|
.subtitle
|
||||||
|
.color,
|
||||||
|
Theme.of(context)
|
||||||
|
.primaryTextTheme
|
||||||
|
.subtitle
|
||||||
|
.decorationColor,
|
||||||
|
],
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(height: 100),
|
||||||
|
Text('Your deposit', style: TextStyle(color: Colors.white),)
|
||||||
|
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/routes.dart';
|
||||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator_icon.dart';
|
import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator_icon.dart';
|
||||||
import 'package:cake_wallet/src/screens/loan/widgets/loan_list_item.dart';
|
import 'package:cake_wallet/src/screens/loan/widgets/loan_list_item.dart';
|
||||||
|
@ -29,6 +30,9 @@ class LoanAccountPage extends BasePage {
|
||||||
@override
|
@override
|
||||||
String get title => 'Loan Account';
|
String get title => 'Loan Account';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get titleColor => Colors.white;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get extendBodyBehindAppBar => true;
|
bool get extendBodyBehindAppBar => true;
|
||||||
|
|
||||||
|
@ -141,7 +145,7 @@ class LoanAccountPage extends BasePage {
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(bottom: 12),
|
padding: EdgeInsets.only(bottom: 12),
|
||||||
child: PrimaryButton(
|
child: PrimaryButton(
|
||||||
onPressed: () {},
|
onPressed: () => Navigator.of(context).pushNamed(Routes.earnInterest),
|
||||||
text: 'Lend and Earn Interest',
|
text: 'Lend and Earn Interest',
|
||||||
color: Theme.of(context).accentTextTheme.body2.color,
|
color: Theme.of(context).accentTextTheme.body2.color,
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
|
|
20
lib/view_model/loan/lend_view_model.dart
Normal file
20
lib/view_model/loan/lend_view_model.dart
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import 'package:cw_core/sync_status.dart';
|
||||||
|
import 'package:cw_core/wallet_base.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:mobx/mobx.dart';
|
||||||
|
|
||||||
|
part 'lend_view_model.g.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class LendViewModel = LendViewModelBase
|
||||||
|
with _$LendViewModel;
|
||||||
|
|
||||||
|
abstract class LendViewModelBase with Store {
|
||||||
|
LendViewModelBase({@required this.wallet});
|
||||||
|
|
||||||
|
final WalletBase wallet;
|
||||||
|
|
||||||
|
@computed
|
||||||
|
bool get status => wallet.syncStatus is SyncedSyncStatus;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue