mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 09:17:35 +00:00
add loan detail page
This commit is contained in:
parent
60643d940a
commit
fe909c0ae6
11 changed files with 288 additions and 17 deletions
BIN
assets/fonts/Poppins-Bold.ttf
Normal file
BIN
assets/fonts/Poppins-Bold.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/Poppins-Medium.ttf
Normal file
BIN
assets/fonts/Poppins-Medium.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/Poppins-Regular.ttf
Normal file
BIN
assets/fonts/Poppins-Regular.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/Poppins-SemiBold.ttf
Normal file
BIN
assets/fonts/Poppins-SemiBold.ttf
Normal file
Binary file not shown.
|
@ -636,7 +636,10 @@ Future setup(
|
|||
|
||||
getIt.registerFactoryParam<LoanDetailViewModel, LoanItem, void>(
|
||||
(LoanItem loanDetail, _) {
|
||||
return LoanDetailViewModel(loanItem: loanDetail);
|
||||
return LoanDetailViewModel(
|
||||
loanItem: loanDetail,
|
||||
wallet: getIt.get<AppStore>().wallet,
|
||||
);
|
||||
});
|
||||
|
||||
getIt.registerFactoryParam<LoanDetailPage, LoanItem, void>(
|
||||
|
|
|
@ -16,8 +16,8 @@ class MarketPlacePage extends StatelessWidget {
|
|||
Text(
|
||||
S.of(context).market_place,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).accentTextTheme.display3.backgroundColor,
|
||||
),
|
||||
),
|
||||
|
|
|
@ -52,7 +52,14 @@ class LoanAccountPage extends BasePage {
|
|||
SyncIndicatorIcon(isSynced: loanAccountViewModel.status),
|
||||
),
|
||||
),
|
||||
super.middle(context),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
],
|
||||
);
|
||||
@override
|
||||
|
@ -158,7 +165,10 @@ class LoanAccountPage extends BasePage {
|
|||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
text: 'By logging in, you agree to the ',
|
||||
style: TextStyle(color: Color(0xff7A93BA), fontSize: 12),
|
||||
style: TextStyle(
|
||||
color: Color(0xff7A93BA),
|
||||
fontSize: 12,
|
||||
fontFamily: 'Poppins'),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'Terms and Conditions',
|
||||
|
|
|
@ -1,14 +1,259 @@
|
|||
import 'package:cake_wallet/di.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/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_detail_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
|
||||
class LoanDetailPage extends BasePage {
|
||||
LoanDetailPage({this.loanDetailViewModel});
|
||||
|
||||
final LoanDetailViewModel loanDetailViewModel;
|
||||
|
||||
@override
|
||||
String get title => 'Loan ${loanDetailViewModel.loanDetails.id}';
|
||||
|
||||
@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: loanDetailViewModel.status),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
return Container();
|
||||
return ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 130,
|
||||
width: double.infinity,
|
||||
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),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
child: LoanContent(),
|
||||
)
|
||||
],
|
||||
),
|
||||
bottomSection: Column(
|
||||
children: [
|
||||
SizedBox(height: 20),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () {},
|
||||
text: 'Increase Deposit',
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () {},
|
||||
text: 'Repay Desposit and Close',
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
),
|
||||
if (!loanDetailViewModel.isLoan)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () {},
|
||||
text: 'Withdraw and Close',
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LendContent extends StatelessWidget {
|
||||
const LendContent({
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
LoanDetailItem(
|
||||
title: 'Initial deposit',
|
||||
trailing: '101.53 USDT',
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
LoanDetailItem(
|
||||
title: 'Earned interest',
|
||||
trailing: '101.53 USDT',
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
LoanDetailItem(
|
||||
title: 'Current value',
|
||||
trailing: '101.53 USDT',
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
LoanDetailItem(
|
||||
title: 'Interest value',
|
||||
trailing: '12.23% APY',
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LoanContent extends StatelessWidget {
|
||||
const LoanContent({
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
LoanDetailItem(
|
||||
title: 'You got',
|
||||
trailing: '101.53 USDT',
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
LoanDetailItem(
|
||||
title: 'Your deposit',
|
||||
trailing: '101.53 USDT',
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
LoanDetailItem(
|
||||
title: 'Repayment',
|
||||
trailing: '101.53 USDT',
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
LoanDetailItem(
|
||||
title: 'Market price',
|
||||
trailing: '1,779.42 XMR/USDT',
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
LoanDetailItem(
|
||||
title: 'Liquidation price',
|
||||
trailing: '1,779.42 XMR/USDT',
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
LoanDetailItem(
|
||||
title: 'Buffer',
|
||||
subtitle:
|
||||
'How much XMR must fall in relation to USDT before liquidation',
|
||||
trailing: '44.8%',
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LoanDetailItem extends StatelessWidget {
|
||||
LoanDetailItem({
|
||||
@required this.title,
|
||||
this.subtitle,
|
||||
@required this.trailing,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final String trailing;
|
||||
|
||||
ThemeBase get currentTheme => getIt.get<SettingsStore>().currentTheme;
|
||||
|
||||
Color get textColor =>
|
||||
currentTheme.type == ThemeType.dark ? Colors.white : Color(0xff393939);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
subtitle != null
|
||||
? SizedBox(
|
||||
width: 200,
|
||||
child: Text(
|
||||
subtitle,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 12,
|
||||
fontStyle: FontStyle.italic,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
)
|
||||
: SizedBox.shrink(),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
trailing,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,19 +45,19 @@ class LoanTable extends StatelessWidget {
|
|||
Expanded(
|
||||
child: Text(
|
||||
'ID',
|
||||
style: TextStyle(color: textColor),
|
||||
style: TextStyle(color: textColor, fontSize: 16),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Amount',
|
||||
style: TextStyle(color: textColor),
|
||||
style: TextStyle(color: textColor, fontSize: 16),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Status',
|
||||
style: TextStyle(color: textColor),
|
||||
style: TextStyle(color: textColor, fontSize: 16),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 25),
|
||||
|
@ -68,9 +68,8 @@ class LoanTable extends StatelessWidget {
|
|||
children: [
|
||||
for (var i = 0; i < items.length; i++) ...[
|
||||
InkWell(
|
||||
onTap: ()=>Navigator.of(context).pushNamed(
|
||||
Routes.loanDetails,
|
||||
arguments: items[i]),
|
||||
onTap: () => Navigator.of(context)
|
||||
.pushNamed(Routes.loanDetails, arguments: items[i]),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
|
@ -82,19 +81,19 @@ class LoanTable extends StatelessWidget {
|
|||
Expanded(
|
||||
child: Text(
|
||||
'5395821325',
|
||||
style: TextStyle(color: textColor),
|
||||
style: TextStyle(color: textColor, fontSize: 14),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'10000 USDT',
|
||||
style: TextStyle(color: textColor),
|
||||
style: TextStyle(color: textColor, fontSize: 14),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Awaiting deposit',
|
||||
style: TextStyle(color: textColor),
|
||||
style: TextStyle(color: textColor, fontSize: 14),
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
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:flutter/foundation.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
part 'loan_account_view_model.g.dart';
|
||||
|
||||
|
@ -8,7 +9,7 @@ class LoanAccountViewModel = LoanAccountViewModelBase
|
|||
with _$LoanAccountViewModel;
|
||||
|
||||
abstract class LoanAccountViewModelBase with Store {
|
||||
LoanAccountViewModelBase({this.wallet}) {
|
||||
LoanAccountViewModelBase({@required this.wallet}) {
|
||||
isLoggedIn = false;
|
||||
_fetchLoanItems();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,26 @@
|
|||
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_detail_view_model.g.dart';
|
||||
|
||||
class LoanDetailViewModel = LoanDetailViewModelBase with _$LoanDetailViewModel;
|
||||
|
||||
abstract class LoanDetailViewModelBase with Store {
|
||||
LoanDetailViewModelBase({LoanItem loanItem}) {
|
||||
LoanDetailViewModelBase({
|
||||
LoanItem loanItem,
|
||||
this.wallet,
|
||||
}) {
|
||||
loanDetails = loanItem;
|
||||
}
|
||||
|
||||
@observable
|
||||
LoanItem loanDetails;
|
||||
|
||||
final WalletBase wallet;
|
||||
|
||||
bool isLoan = true;
|
||||
|
||||
@computed
|
||||
bool get status => wallet.syncStatus is SyncedSyncStatus;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue