feat: diskon page
This commit is contained in:
parent
8c946ce3d9
commit
8e4a289625
@ -1,3 +1,4 @@
|
||||
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:enaklo_pos/core/components/custom_text_field.dart';
|
||||
@ -23,19 +24,10 @@ class _FormDiscountDialogState extends State<FormDiscountDialog> {
|
||||
final discountController = TextEditingController();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () => context.pop(),
|
||||
icon: const Icon(Icons.close),
|
||||
),
|
||||
const Text('Tambah Diskon'),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
return CustomModalDialog(
|
||||
title: widget.data == null ? 'Tambah Diskon' : 'Edit Diskon',
|
||||
contentPadding: const EdgeInsets.all(16.0),
|
||||
child: SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
width: context.deviceWidth / 3,
|
||||
child: Column(
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import 'package:enaklo_pos/core/components/buttons.dart';
|
||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/setting/bloc/discount/discount_bloc.dart';
|
||||
@ -5,7 +7,6 @@ import 'package:enaklo_pos/presentation/setting/bloc/discount/discount_bloc.dart
|
||||
import '../../home/widgets/custom_tab_bar.dart';
|
||||
import '../dialogs/form_discount_dialog.dart';
|
||||
import '../models/discount_model.dart';
|
||||
import '../widgets/add_data.dart';
|
||||
import '../widgets/manage_discount_card.dart';
|
||||
import '../widgets/settings_title.dart';
|
||||
|
||||
@ -49,12 +50,24 @@ class _DiscountPageState extends State<DiscountPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
return Column(
|
||||
children: [
|
||||
SettingsTitle(
|
||||
'Kelola Diskon',
|
||||
subtitle: 'Kelola diskon untuk produk Anda',
|
||||
actionWidget: [
|
||||
Button.outlined(
|
||||
onPressed: onAddDataTap,
|
||||
label: "Tambah Diskon",
|
||||
icon: Icon(Icons.add, color: AppColors.primary),
|
||||
)
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const SettingsTitle('Kelola Diskon'),
|
||||
const SizedBox(height: 24),
|
||||
CustomTabBar(
|
||||
tabTitles: const ['Semua'],
|
||||
initialTabIndex: 0,
|
||||
@ -70,8 +83,10 @@ class _DiscountPageState extends State<DiscountPage> {
|
||||
}, loaded: (discounts) {
|
||||
return GridView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: discounts.length + 1,
|
||||
itemCount: discounts.length,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
childAspectRatio: 0.85,
|
||||
@ -80,13 +95,7 @@ class _DiscountPageState extends State<DiscountPage> {
|
||||
mainAxisSpacing: 30.0,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return AddData(
|
||||
title: 'Tambah Diskon Baru',
|
||||
onPressed: onAddDataTap,
|
||||
);
|
||||
}
|
||||
final item = discounts[index - 1];
|
||||
final item = discounts[index];
|
||||
return ManageDiscountCard(
|
||||
data: item,
|
||||
onEditTap: () {},
|
||||
@ -126,6 +135,9 @@ class _DiscountPageState extends State<DiscountPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,11 +18,9 @@ class ManageDiscountCard extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
decoration: ShapeDecoration(
|
||||
shape: RoundedRectangleBorder(
|
||||
side: const BorderSide(width: 1, color: AppColors.card),
|
||||
borderRadius: BorderRadius.circular(19),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
@ -36,7 +34,7 @@ class ManageDiscountCard extends StatelessWidget {
|
||||
margin: const EdgeInsets.only(top: 30.0),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: AppColors.disabled.withOpacity(0.4),
|
||||
color: AppColors.primary.withOpacity(0.1),
|
||||
),
|
||||
child: Text(
|
||||
'${data.value!.replaceAll('.00', '')}%',
|
||||
@ -48,26 +46,15 @@ class ManageDiscountCard extends StatelessWidget {
|
||||
),
|
||||
const Spacer(),
|
||||
Center(
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: 'Nama Promo : ',
|
||||
children: [
|
||||
TextSpan(
|
||||
text: data.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: Text(
|
||||
data.name ?? "-",
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
|
||||
@ -27,6 +27,12 @@ class SettingsTitle extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: AppColors.background,
|
||||
width: 1.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user