fix: provider view model agreement redeem and product

This commit is contained in:
2024-02-22 14:43:40 +07:00
parent a3148d8210
commit 176261923d
16 changed files with 501 additions and 287 deletions

View File

@@ -40,42 +40,50 @@ class _PlanViewState extends State<PlanView> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(height: 70, title: 'Investment Plan'),
body: SingleChildScrollView(
padding: EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RiskProfile(
totalScore: 26,
rowSuitableProduct: true
),
SizedBox(
height: 32,
),
Text('Your Goal in Investing',
style: TextStyle(
fontWeight: FontWeight.w700,
color: ColorPalette.slate800,
fontSize: 18
return ChangeNotifierProvider(
create: (context) => PlanViewModel(),
child: Scaffold(
appBar: CustomAppBar(
height: SizeConfig.height * 0.08,
title: 'Investment Plan',
leading: SizedBox(),
),
body: SingleChildScrollView(
padding: EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RiskProfile(
totalScore: 26,
rowSuitableProduct: true
),
),
SizedBox(
height: 24,
),
GoalInvestingView(
onListSelected: (p0) {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) {
return modalInvest(context, p0);
},
);
},
)
],
SizedBox(
height: 32,
),
Text('Your Goal in Investing',
style: TextStyle(
fontWeight: FontWeight.w700,
color: ColorPalette.slate800,
fontSize: 18
),
),
SizedBox(
height: 24,
),
GoalInvestingView(
onListSelected: (p0) {
print(p0);
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) {
return modalInvest(context, p0);
},
);
},
)
],
),
),
),
);

View File

@@ -5,9 +5,12 @@ import 'package:cims_apps/application/component/subscribe/total_payment_view.dar
import 'package:cims_apps/application/theme/color_palette.dart';
import 'package:cims_apps/core/route/route.dart';
import 'package:cims_apps/core/utils/size_config.dart';
import 'package:cims_apps/features/dashboard/dashboard_account/view/plan/view/step_invest_plan/options_starting_invest.dart';
import 'package:cims_apps/features/dashboard/dashboard_account/view/plan/view_model/plan_view_model.dart';
import 'package:cims_apps/features/dashboard/dashboard_account/view/product/view/product_view.dart';
import 'package:cims_apps/features/dashboard/dashboard_account/view/product/view_model/product_view_model.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class ResultOptionsProduct extends StatelessWidget {
final int totalInvest;
@@ -21,135 +24,169 @@ class ResultOptionsProduct extends StatelessWidget {
Product(name: 'Gemilang Kas 2 Kelas A', type: 'Shares', totalPercent: 0.1)
];
return Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16)
),
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Icon(Icons.arrow_back, color: ColorPalette.slate500),
Text('Results from your risk profile',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 18,
color: ColorPalette.slate800
),
),
Icon(Icons.close_rounded, color: ColorPalette.slate400)
],
),
const SizedBox(height: 32),
SingleChildScrollView(
return ChangeNotifierProvider(
create: (context) => PlanViewModel(),
child: Consumer<PlanViewModel>(
builder: (context, provider, child) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16)
),
padding: const EdgeInsets.all(24),
child: Column(
children: listProduct.asMap().entries.map((e) {
return Container(
margin: const EdgeInsets.only(bottom: 16),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: ColorPalette.slate200),
borderRadius: BorderRadius.circular(12),
boxShadow: const [
BoxShadow(
color: Color(0XFF1E293B0A)
)
]
),
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: () {
Navigator.pop(context);
showModalBottomSheet(
context: context,
builder: (context) {
return OptionsStartingInvest(totalInvest: totalInvest);
},
);
},
child: Icon(Icons.arrow_back, color: ColorPalette.slate500)
),
Text('Results from your risk profile',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 18,
color: ColorPalette.slate800
),
),
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Icon(Icons.close_rounded, color: ColorPalette.slate400)
)
],
),
const SizedBox(height: 32),
SingleChildScrollView(
child: Column(
children: [
Row(
children: [
const ImageView(image: PathAssets.iconGoogle, width: 30,),
const SizedBox(
width: 12,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: listProduct.asMap().entries.map((e) {
return Container(
margin: const EdgeInsets.only(bottom: 16),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: ColorPalette.slate200),
borderRadius: BorderRadius.circular(12),
boxShadow: const [
BoxShadow(
color: Color(0XFF1E293B0A)
)
]
),
child: Column(
children: [
Row(
children: [
Text(e.value.name ?? '',
style: const TextStyle(
fontWeight: FontWeight.w700,
color: ColorPalette.slate800,
const ImageView(image: PathAssets.iconGoogle, width: 30,),
const SizedBox(
width: 12,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(e.value.name ?? '',
style: const TextStyle(
fontWeight: FontWeight.w700,
color: ColorPalette.slate800,
),
),
const SizedBox(height: 4,),
Container(
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12),
decoration: BoxDecoration(
border: Border.all(color: ColorPalette.investTypeColor[e.value.type]!),
color: ColorPalette.investTypeBgColor[e.value.type],
borderRadius: BorderRadius.circular(40)
),
child: Text(e.value.type ?? '',
style: TextStyle(
color: ColorPalette.investTypeColor[e.value.type],
fontWeight: FontWeight.w600,
fontSize: 12
),
),
)
],
),
),
const SizedBox(height: 4,),
Container(
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12),
decoration: BoxDecoration(
border: Border.all(color: ColorPalette.investTypeColor[e.value.type]!),
color: ColorPalette.investTypeBgColor[e.value.type],
borderRadius: BorderRadius.circular(40)
),
child: Text(e.value.type ?? '',
style: TextStyle(
color: ColorPalette.investTypeColor[e.value.type],
fontWeight: FontWeight.w600,
fontSize: 12
),
Text('${(e.value.totalPercent! * 100).toInt()} %',
style: const TextStyle(
fontWeight: FontWeight.w700,
fontSize: 16,
color: ColorPalette.slate800
),
)
],
),
),
Text('${(e.value.totalPercent! * 100).toInt()} %',
style: const TextStyle(
fontWeight: FontWeight.w700,
fontSize: 16,
color: ColorPalette.slate800
const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: Divider(height: 1, color: ColorPalette.slate200),
),
)
],
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: Divider(height: 1, color: ColorPalette.slate200),
),
GestureDetector(
onTap: () {
routePush(context, page: ProductView(selectedProduct: e.value, seeMore: true));
},
child: const Text('See More',
style: TextStyle(
color: ColorPalette.slate500,
fontWeight: FontWeight.w600,
),
GestureDetector(
onTap: () {
routePush(context, page: ProductView(selectedProduct: e.value, seeMore: true));
},
child: const Text('See More',
style: TextStyle(
color: ColorPalette.slate500,
fontWeight: FontWeight.w600,
),
),
)
],
),
)
],
);
}).toList(),
),
);
}).toList(),
),
const SizedBox(
height: 16,
),
ButtonView(
name: 'Next',
onPressed: () {
Navigator.pop(context);
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) =>
ChangeNotifierProvider(
create: (context) => PlanViewModel(),
child: Consumer<PlanViewModel>(
builder: (context, planProvider, _) {
return TotalPaymentView(
listProduct: listProduct,
totalInvest: totalInvest,
isAgree: planProvider.isAgree,
onTapAgree: planProvider.setAgree,
);
}
),
)
);
},
width: SizeConfig.width,
heightWrapContent: true,
contentPadding: const EdgeInsets.symmetric(vertical: 16),
marginVertical: 0,
)
],
),
),
const SizedBox(
height: 16,
),
ButtonView(
name: 'Next',
onPressed: () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) =>
TotalPaymentView(
listProduct: listProduct,
totalInvest: totalInvest,
)
);
},
width: SizeConfig.width,
heightWrapContent: true,
contentPadding: const EdgeInsets.symmetric(vertical: 16),
marginVertical: 0,
)
],
);
}
),
);
}

View File

@@ -3,4 +3,10 @@ import 'package:flutter/material.dart';
class PlanViewModel extends ChangeNotifier {
List<Product> listProduct = [];
bool isAgree = false;
void setAgree() {
isAgree = !isAgree;
notifyListeners();
}
}

View File

@@ -152,8 +152,8 @@ class _PortofolioViewState extends State<PortofolioView> {
const SizedBox(
height: 12,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -162,7 +162,7 @@ class _PortofolioViewState extends State<PortofolioView> {
children: [
Icon(Icons.add, size: 18, color: ColorPalette.primary),
SizedBox(width: 4),
Text('Create',
const Text('Create',
style: TextStyle(
color: ColorPalette.primary,
fontWeight: FontWeight.w600
@@ -173,7 +173,7 @@ class _PortofolioViewState extends State<PortofolioView> {
],
),
),
...listColumnPortofolio(),
// ...listColumnPortofolio(),
cardPortfolio()
],
),
@@ -388,11 +388,11 @@ class _PortofolioViewState extends State<PortofolioView> {
Widget cardPortfolio() {
return GestureDetector(
onTap: () {
routePush(context, page: PortfolioDetailView());
routePush(context, page: const PortfolioDetailView());
},
child: Container(
margin: EdgeInsets.symmetric(horizontal: 24),
padding: EdgeInsets.all(16),
margin: const EdgeInsets.symmetric(horizontal: 24),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(color: ColorPalette.slate200)
@@ -402,7 +402,7 @@ class _PortofolioViewState extends State<PortofolioView> {
Row(
children: [
Container(
padding: EdgeInsets.all(4),
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: ColorPalette.blue200.withOpacity(0.5),
borderRadius: BorderRadius.circular(8)
@@ -412,8 +412,8 @@ class _PortofolioViewState extends State<PortofolioView> {
width: SizeConfig.width * 0.07
)
),
SizedBox(width: 8),
Column(
const SizedBox(width: 8),
const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextTitle(title: 'Education', fontSize: 16,),
@@ -427,11 +427,11 @@ class _PortofolioViewState extends State<PortofolioView> {
),
],
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
const Padding(
padding: EdgeInsets.symmetric(vertical: 8),
child: Divider(height: 1, color: ColorPalette.slate200),
),
Row(
const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(

View File

@@ -1,7 +1,10 @@
import 'package:cims_apps/application/assets/path_assets.dart';
import 'package:cims_apps/application/component/button/button_view.dart';
import 'package:cims_apps/application/component/image/image_view.dart';
import 'package:cims_apps/application/component/radio_agreement.dart';
import 'package:cims_apps/application/component/text_title/text_title.dart';
import 'package:cims_apps/application/theme/color_palette.dart';
import 'package:cims_apps/core/utils/number_formatter.dart';
import 'package:cims_apps/core/utils/size_config.dart';
import 'package:cims_apps/features/dashboard/dashboard_account/view/portfolio/redeem_product/view_model/redeem_product_view_model.dart';
import 'package:flutter/material.dart';
@@ -24,7 +27,7 @@ class TotalRedeem extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Investment Funds that You Cash Out',
const Text('Investment Funds that You Cash Out',
style: TextStyle(
fontWeight: FontWeight.w600,
color: ColorPalette.slate800,
@@ -33,18 +36,18 @@ class TotalRedeem extends StatelessWidget {
),
GestureDetector(
onTap: () => Navigator.pop(context),
child: Icon(Icons.close_rounded, color: ColorPalette.slate800,)
child: const Icon(Icons.close_rounded, color: ColorPalette.slate800,)
)
],
),
),
Divider(height: 1, color: ColorPalette.slate200,),
const Divider(height: 1, color: ColorPalette.slate200,),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
child: cardProduct(provider.getCurrentProduct, provider.getUnit!),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 24),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -64,9 +67,9 @@ class TotalRedeem extends StatelessWidget {
],
),
),
SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
const SizedBox(height: 16),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 24),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -86,8 +89,59 @@ class TotalRedeem extends StatelessWidget {
],
),
),
SizedBox(height: 16,),
const SizedBox(height: 16,),
Container(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 16),
color: ColorPalette.slate200.withOpacity(0.5),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextTitle(
title: 'Estimated Funds Disbursed',
color: ColorPalette.slate500,
fontSize: 16,
)
),
Expanded(
child: Text(
NumberFormatter.numberCurrency((provider.getCurrentProduct.priceUnit! * provider.getUnit!).toInt(), 'Rp ', 'id_ID', decimalDigits: 0),
textAlign: TextAlign.end,
style: TextStyle(
color: ColorPalette.slate800,
fontWeight: FontWeight.w700,
fontSize: 18
),
)
)
],
),
),
RadioAgreement(
isAgree: provider.isAgree,
desc: 'I agree to the sale of the mutual funds listed on this page. I understand that the total funds disbursed are approximate. The amount received may change according to the closing price of the mutual fund on the day of sale.',
onTap: provider.setAgree
),
const SizedBox(height: 24),
ButtonView(
disabled: !provider.isAgree,
name: 'Redeem',
textSize: 20,
marginVertical: 0,
disabledBgColor: ColorPalette.slate200.withOpacity(0.5),
textColor: !provider.isAgree ? ColorPalette.slate400 : Colors.white,
onPressed: () {
Navigator.pop(context);
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) {
return TotalRedeem();
},
);
},
),
const SizedBox(height: 24)
],
);
}

View File

@@ -35,6 +35,8 @@ class RedeemProductViewModel extends ChangeNotifier {
double? get getAmount => amount;
double? get getUnit => unit;
bool isAgree = false;
void setCurrentAcc(Account account) {
currentAccount = account;
notifyListeners();
@@ -61,4 +63,9 @@ class RedeemProductViewModel extends ChangeNotifier {
currentProduct = product;
notifyListeners();
}
void setAgree() {
isAgree = !isAgree;
notifyListeners();
}
}

View File

@@ -2,6 +2,7 @@ import 'package:cims_apps/application/component/subscribe/goal_investing_view.da
import 'package:cims_apps/application/component/subscribe/input_investment_view.dart';
import 'package:cims_apps/application/component/subscribe/total_payment_view.dart';
import 'package:cims_apps/application/theme/color_palette.dart';
import 'package:cims_apps/features/dashboard/dashboard_account/view/plan/view_model/plan_view_model.dart';
import 'package:cims_apps/features/dashboard/dashboard_account/view/product/view_model/product_view_model.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@@ -11,10 +12,9 @@ class SelectGoalInvesting extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => ProductViewModel(),)
],
return ChangeNotifierProvider(
create: (context) => ProductViewModel(),
child: Consumer<ProductViewModel>(
builder: (context, provider, child) {
return Container(
@@ -51,23 +51,39 @@ class SelectGoalInvesting extends StatelessWidget {
context: context,
isScrollControlled: true,
builder: (context) {
return InputInvestmentView(
selectedPlan: p0,
nextMove: (value) {
Navigator.pop(context);
int formatIntParse = int.parse(value.replaceAll('Rp ', '').replaceAll(',', ''));
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) =>
TotalPaymentView(
listProduct: [
provider.getSelectedProduct
],
totalInvest: formatIntParse,
)
);
},
return ChangeNotifierProvider(
create: (context) => ProductViewModel(),
child: Consumer<ProductViewModel>(
builder: (context, provider, child) {
return InputInvestmentView(
selectedPlan: p0,
nextMove: (value) {
Navigator.pop(context);
int formatIntParse = int.parse(value.replaceAll('Rp ', '').replaceAll(',', ''));
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) =>
ChangeNotifierProvider(
create: (context) => ProductViewModel(),
child: Consumer<ProductViewModel>(
builder: (context, provider, child) {
return TotalPaymentView(
listProduct: [
provider.getSelectedProduct
],
totalInvest: formatIntParse,
isAgree: provider.isAgree,
onTapAgree: provider.setAgree,
);
}
),
)
);
},
);
}
),
);
},
);

View File

@@ -14,6 +14,7 @@ class ProductViewModel extends ChangeNotifier {
Product get getSelectedProduct => selectedProduct;
double totalInvestment = 0;
bool isAgree = false;
void setSelectedProduct(Product product) {
selectedProduct = product;
@@ -24,4 +25,9 @@ class ProductViewModel extends ChangeNotifier {
totalInvestment = value;
notifyListeners();
}
void setAgree() {
isAgree = !isAgree;
notifyListeners();
}
}

View File

@@ -8,7 +8,7 @@ class ProfileView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(height: SizeConfig.height * .1, title: 'Profile'),
appBar: CustomAppBar(height: SizeConfig.height * .08, title: 'Profile'),
);
}
}

View File

@@ -8,8 +8,7 @@ class TransactionView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar:
CustomAppBar(height: SizeConfig.height * .1, title: 'Transaction'),
appBar: CustomAppBar(height: SizeConfig.height * 0.08, title: 'Transaction'),
);
}
}