fix: more detail redeem product
This commit is contained in:
parent
506f364b87
commit
d966108e9e
|
@ -4,6 +4,7 @@ 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/image/image_view.dart';
|
||||||
import 'package:cims_apps/application/component/text_title/text_title.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/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/core/utils/size_config.dart';
|
||||||
import 'package:cims_apps/features/dashboard/dashboard_account/view/portfolio/redeem_product/view/redeem_product.dart';
|
import 'package:cims_apps/features/dashboard/dashboard_account/view/portfolio/redeem_product/view/redeem_product.dart';
|
||||||
import 'package:cims_apps/features/dashboard/dashboard_account/view/portfolio/redeem_product/view_model/redeem_product_view_model.dart';
|
import 'package:cims_apps/features/dashboard/dashboard_account/view/portfolio/redeem_product/view_model/redeem_product_view_model.dart';
|
||||||
|
@ -18,29 +19,33 @@ class PortfolioDetailView extends StatelessWidget {
|
||||||
List<PortfolioProduct> listProduct = [
|
List<PortfolioProduct> listProduct = [
|
||||||
PortfolioProduct(
|
PortfolioProduct(
|
||||||
name: 'Gemilang Dana Kas Maxima',
|
name: 'Gemilang Dana Kas Maxima',
|
||||||
type: '',
|
type: 'Money Market',
|
||||||
yield: 8.17,
|
yield: 8.17,
|
||||||
priceUnit: 2600.79,
|
priceUnit: 2600.79,
|
||||||
funds: 6300000),
|
funds: 6300000,
|
||||||
|
totalUnit: 14520
|
||||||
|
),
|
||||||
PortfolioProduct(
|
PortfolioProduct(
|
||||||
name: 'Gemilang Dana Likuid',
|
name: 'Gemilang Dana Likuid',
|
||||||
type: '',
|
type: 'Sharia',
|
||||||
yield: 6.42,
|
yield: 6.42,
|
||||||
priceUnit: 1600.79,
|
priceUnit: 1600.79,
|
||||||
funds: 2340000),
|
funds: 2340000,
|
||||||
|
totalUnit: 232,
|
||||||
|
),
|
||||||
PortfolioProduct(
|
PortfolioProduct(
|
||||||
name: 'Gemilang Income Fund',
|
name: 'Gemilang Income Fund',
|
||||||
type: '',
|
type: 'Bonds',
|
||||||
yield: 8.17,
|
yield: 8.17,
|
||||||
priceUnit: 2600.79,
|
priceUnit: 2600.79,
|
||||||
funds: 6300000)
|
funds: 6300000,
|
||||||
|
totalUnit: 2450,
|
||||||
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
return MultiProvider(
|
return ChangeNotifierProvider(
|
||||||
providers: [
|
create: (context) => RedeemProductViewModel(),
|
||||||
ChangeNotifierProvider(create: (context) => RedeemProductViewModel())
|
|
||||||
],
|
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
body: SizedBox(
|
body: SizedBox(
|
||||||
|
@ -100,19 +105,20 @@ class PortfolioDetailView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24,),
|
const SizedBox(height: 24,),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ClipRRect(
|
child: Container(
|
||||||
borderRadius: BorderRadius.circular(0),
|
decoration: BoxDecoration(
|
||||||
child: Container(
|
borderRadius: BorderRadius.circular(12),
|
||||||
decoration: BoxDecoration(
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(12),
|
),
|
||||||
color: Colors.white,
|
child: Consumer<RedeemProductViewModel>(
|
||||||
),
|
builder: (context, provider, child) {
|
||||||
child: ListView(
|
return ListView(
|
||||||
padding: const EdgeInsets.all(24),
|
padding: const EdgeInsets.all(24),
|
||||||
children: [
|
children: listProduct.asMap().entries.map((e) {
|
||||||
cardPortfolio(context)
|
return cardPortfolio(context, e.value);
|
||||||
],
|
}).toList(),
|
||||||
),
|
);
|
||||||
|
}
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -125,7 +131,7 @@ class PortfolioDetailView extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget cardPortfolio(context) {
|
Widget cardPortfolio(context, PortfolioProduct product) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
@ -155,19 +161,19 @@ class PortfolioDetailView extends StatelessWidget {
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const TextTitle(title: 'Gemilang Dana Kas Maxima', fontSize: 16,),
|
TextTitle(title: product.name ?? '', fontSize: 16,),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(6),
|
padding: const EdgeInsets.all(6),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(40),
|
borderRadius: BorderRadius.circular(40),
|
||||||
color: ColorPalette.investTypeBgColor['Money Market']?.withOpacity(0.5) ?? Colors.white,
|
color: ColorPalette.investTypeBgColor[product.type!]?.withOpacity(0.5) ?? Colors.white,
|
||||||
border: Border.all(width: 2, color: ColorPalette.investTypeColor['Money Market']?.withOpacity(0.4) ?? Colors.white)
|
border: Border.all(width: 2, color: ColorPalette.investTypeColor[product.type!]?.withOpacity(0.4) ?? Colors.white)
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Money Market' ?? '',
|
product.type ?? '',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ColorPalette.investTypeColor['Money Market'],
|
color: ColorPalette.investTypeColor[product.type!],
|
||||||
fontWeight: FontWeight.w600
|
fontWeight: FontWeight.w600
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -187,8 +193,8 @@ class PortfolioDetailView extends StatelessWidget {
|
||||||
rowDescription('Present Value', 'Rp2.660.706', fontWeight: FontWeight.w700),
|
rowDescription('Present Value', 'Rp2.660.706', fontWeight: FontWeight.w700),
|
||||||
rowDescription('Investment Capital', 'Rp2.660.706'),
|
rowDescription('Investment Capital', 'Rp2.660.706'),
|
||||||
rowDescription('Advantages', 'Rp2.660.706'),
|
rowDescription('Advantages', 'Rp2.660.706'),
|
||||||
rowDescription('Purchase Price', 'Rp1.500,57'),
|
rowDescription('Purchase Price', NumberFormatter.numberCurrency(product.priceUnit, 'Rp ', 'id_ID')),
|
||||||
rowDescription('Number of Units', '14.002'),
|
rowDescription('Number of Units', '${product.totalUnit ?? 0}'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16,),
|
const SizedBox(height: 16,),
|
||||||
|
@ -206,6 +212,7 @@ class PortfolioDetailView extends StatelessWidget {
|
||||||
borderColor: ColorPalette.red600,
|
borderColor: ColorPalette.red600,
|
||||||
textColor: ColorPalette.red600,
|
textColor: ColorPalette.red600,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
Provider.of<RedeemProductViewModel>(context, listen: false).setProduct(product);
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
|
|
|
@ -42,8 +42,7 @@ class _RedeemProductState extends State<RedeemProduct> {
|
||||||
create: (context) => RedeemProductViewModel(),
|
create: (context) => RedeemProductViewModel(),
|
||||||
child: Consumer<RedeemProductViewModel>(
|
child: Consumer<RedeemProductViewModel>(
|
||||||
builder: (context, provider, child) {
|
builder: (context, provider, child) {
|
||||||
double amount = provider.getAmount ?? provider.getCurrentProduct.priceUnit! * provider.getCurrentProduct.totalUnit!;
|
amountController.text = NumberFormatter.numberCurrency(provider.getAmount!.toInt(), 'Rp ', 'id_ID', decimalDigits: 0);
|
||||||
amountController.text = NumberFormatter.numberCurrency(amount.toInt(), 'Rp ', 'id_ID', decimalDigits: 0);
|
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
@ -76,8 +75,8 @@ class _RedeemProductState extends State<RedeemProduct> {
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
segmentAmount(
|
segmentAmount(
|
||||||
context,
|
context,
|
||||||
provider.getAmount ?? provider.getCurrentProduct.priceUnit! * (provider.getCurrentProduct.totalUnit! / 2.0),
|
provider.getAmount!,
|
||||||
provider.getUnit ?? provider.getCurrentProduct.totalUnit! / 2.0,
|
provider.getUnit!,
|
||||||
(value) {
|
(value) {
|
||||||
provider.setUnit(value);
|
provider.setUnit(value);
|
||||||
},
|
},
|
||||||
|
|
|
@ -61,6 +61,8 @@ class RedeemProductViewModel extends ChangeNotifier {
|
||||||
|
|
||||||
void setProduct(PortfolioProduct product) {
|
void setProduct(PortfolioProduct product) {
|
||||||
currentProduct = product;
|
currentProduct = product;
|
||||||
|
amount = product.priceUnit! * (product.totalUnit! / 2.0);
|
||||||
|
unit = (product.totalUnit! / 2.0);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user