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