feat: product page
This commit is contained in:
parent
16230febc4
commit
ac17c4d830
@ -57,7 +57,7 @@ class HomeFeature extends StatelessWidget {
|
|||||||
title: 'Produk',
|
title: 'Produk',
|
||||||
color: const Color(0xFFFF9800),
|
color: const Color(0xFFFF9800),
|
||||||
icon: LineIcons.box,
|
icon: LineIcons.box,
|
||||||
onTap: () {},
|
onTap: () => context.router.push(ProductRoute()),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
327
lib/presentation/pages/product/product_page.dart
Normal file
327
lib/presentation/pages/product/product_page.dart
Normal file
@ -0,0 +1,327 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
import 'package:auto_route/auto_route.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:line_icons/line_icons.dart';
|
||||||
|
|
||||||
|
import '../../../common/theme/theme.dart';
|
||||||
|
import '../../components/button/button.dart';
|
||||||
|
import 'widgets/appbar.dart';
|
||||||
|
import 'widgets/category_delegate.dart';
|
||||||
|
import 'widgets/product_tile.dart';
|
||||||
|
|
||||||
|
@RoutePage()
|
||||||
|
class ProductPage extends StatefulWidget {
|
||||||
|
const ProductPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ProductPage> createState() => _ProductPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProductPageState extends State<ProductPage>
|
||||||
|
with TickerProviderStateMixin {
|
||||||
|
String selectedCategory = 'Semua';
|
||||||
|
List<String> categories = ['Semua', 'Makanan', 'Minuman', 'Snack', 'Dessert'];
|
||||||
|
|
||||||
|
// Animation
|
||||||
|
late AnimationController _rotationController;
|
||||||
|
late Animation<double> _rotationAnimation;
|
||||||
|
|
||||||
|
// Sample product data
|
||||||
|
List<Product> products = [
|
||||||
|
Product(
|
||||||
|
id: '1',
|
||||||
|
name: 'Nasi Goreng Special',
|
||||||
|
price: 25000,
|
||||||
|
category: 'Makanan',
|
||||||
|
stock: 50,
|
||||||
|
imageUrl: 'assets/images/nasi_goreng.jpg',
|
||||||
|
isActive: true,
|
||||||
|
),
|
||||||
|
Product(
|
||||||
|
id: '8',
|
||||||
|
name: 'Nasi Goreng',
|
||||||
|
price: 15000,
|
||||||
|
category: 'Makanan',
|
||||||
|
stock: 50,
|
||||||
|
imageUrl: 'assets/images/nasi_goreng.jpg',
|
||||||
|
isActive: true,
|
||||||
|
),
|
||||||
|
Product(
|
||||||
|
id: '9',
|
||||||
|
name: 'Nasi Goreng Telor',
|
||||||
|
price: 18000,
|
||||||
|
category: 'Makanan',
|
||||||
|
stock: 50,
|
||||||
|
imageUrl: 'assets/images/nasi_goreng.jpg',
|
||||||
|
isActive: true,
|
||||||
|
),
|
||||||
|
Product(
|
||||||
|
id: '10',
|
||||||
|
name: 'Mie Goreng ',
|
||||||
|
price: 18000,
|
||||||
|
category: 'Makanan',
|
||||||
|
stock: 50,
|
||||||
|
imageUrl: 'assets/images/nasi_goreng.jpg',
|
||||||
|
isActive: true,
|
||||||
|
),
|
||||||
|
Product(
|
||||||
|
id: '2',
|
||||||
|
name: 'Es Teh Manis',
|
||||||
|
price: 8000,
|
||||||
|
category: 'Minuman',
|
||||||
|
stock: 100,
|
||||||
|
imageUrl: 'assets/images/es_teh.jpg',
|
||||||
|
isActive: true,
|
||||||
|
),
|
||||||
|
Product(
|
||||||
|
id: '6',
|
||||||
|
name: 'Es Jeruk',
|
||||||
|
price: 10000,
|
||||||
|
category: 'Minuman',
|
||||||
|
stock: 100,
|
||||||
|
imageUrl: 'assets/images/es_teh.jpg',
|
||||||
|
isActive: true,
|
||||||
|
),
|
||||||
|
Product(
|
||||||
|
id: '7',
|
||||||
|
name: 'Es Kelapa',
|
||||||
|
price: 12000,
|
||||||
|
category: 'Minuman',
|
||||||
|
stock: 100,
|
||||||
|
imageUrl: 'assets/images/es_teh.jpg',
|
||||||
|
isActive: true,
|
||||||
|
),
|
||||||
|
Product(
|
||||||
|
id: '3',
|
||||||
|
name: 'Keripik Singkong',
|
||||||
|
price: 15000,
|
||||||
|
category: 'Snack',
|
||||||
|
stock: 25,
|
||||||
|
imageUrl: 'assets/images/keripik.jpg',
|
||||||
|
isActive: true,
|
||||||
|
),
|
||||||
|
Product(
|
||||||
|
id: '4',
|
||||||
|
name: 'Es Krim Vanilla',
|
||||||
|
price: 12000,
|
||||||
|
category: 'Dessert',
|
||||||
|
stock: 30,
|
||||||
|
imageUrl: 'assets/images/ice_cream.jpg',
|
||||||
|
isActive: false,
|
||||||
|
),
|
||||||
|
Product(
|
||||||
|
id: '5',
|
||||||
|
name: 'Ayam Bakar',
|
||||||
|
price: 35000,
|
||||||
|
category: 'Makanan',
|
||||||
|
stock: 20,
|
||||||
|
imageUrl: 'assets/images/ayam_bakar.jpg',
|
||||||
|
isActive: true,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
List<Product> get filteredProducts {
|
||||||
|
return products.where((product) {
|
||||||
|
bool matchesCategory =
|
||||||
|
selectedCategory == 'Semua' || product.category == selectedCategory;
|
||||||
|
return matchesCategory;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
initState() {
|
||||||
|
super.initState();
|
||||||
|
_rotationController = AnimationController(
|
||||||
|
duration: const Duration(seconds: 3),
|
||||||
|
vsync: this,
|
||||||
|
)..repeat();
|
||||||
|
_rotationAnimation = Tween<double>(
|
||||||
|
begin: 0,
|
||||||
|
end: 2 * math.pi,
|
||||||
|
).animate(_rotationController);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_rotationController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppColor.background,
|
||||||
|
body: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
_buildSliverAppBar(),
|
||||||
|
_buildCategoryFilter(),
|
||||||
|
_buildProductGrid(),
|
||||||
|
_buildEmptyState(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSliverAppBar() {
|
||||||
|
return SliverAppBar(
|
||||||
|
expandedHeight: 120.0,
|
||||||
|
floating: false,
|
||||||
|
pinned: true,
|
||||||
|
elevation: 0,
|
||||||
|
flexibleSpace: ProductAppbar(rotationAnimation: _rotationAnimation),
|
||||||
|
actions: [
|
||||||
|
ActionIconButton(onTap: () {}, icon: LineIcons.search),
|
||||||
|
ActionIconButton(onTap: _showAddProductDialog, icon: LineIcons.plus),
|
||||||
|
ActionIconButton(onTap: _showOptionsMenu, icon: LineIcons.filter),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildCategoryFilter() {
|
||||||
|
return SliverPersistentHeader(
|
||||||
|
pinned: true,
|
||||||
|
delegate: ProductCategoryHeaderDelegate(
|
||||||
|
categories: categories,
|
||||||
|
selectedCategory: selectedCategory,
|
||||||
|
onCategoryChanged: (category) {
|
||||||
|
setState(() {
|
||||||
|
selectedCategory = category;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildProductGrid() {
|
||||||
|
if (filteredProducts.isEmpty) {
|
||||||
|
return const SliverToBoxAdapter(child: SizedBox.shrink());
|
||||||
|
}
|
||||||
|
|
||||||
|
return SliverPadding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
sliver: SliverGrid(
|
||||||
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: 2,
|
||||||
|
childAspectRatio: 0.85,
|
||||||
|
crossAxisSpacing: 16.0,
|
||||||
|
mainAxisSpacing: 16.0,
|
||||||
|
),
|
||||||
|
delegate: SliverChildBuilderDelegate((context, index) {
|
||||||
|
final product = filteredProducts[index];
|
||||||
|
return ProductTile(product: product, onTap: () {});
|
||||||
|
}, childCount: filteredProducts.length),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildEmptyState() {
|
||||||
|
if (filteredProducts.isNotEmpty) {
|
||||||
|
return const SliverToBoxAdapter(child: SizedBox.shrink());
|
||||||
|
}
|
||||||
|
|
||||||
|
return SliverToBoxAdapter(
|
||||||
|
child: Container(
|
||||||
|
height: 300,
|
||||||
|
margin: const EdgeInsets.all(32.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.inventory_2_outlined,
|
||||||
|
size: 64,
|
||||||
|
color: AppColor.textLight,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
'Tidak ada produk ditemukan',
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColor.textSecondary,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Coba ubah filter atau tambah produk baru',
|
||||||
|
style: TextStyle(color: AppColor.textLight, fontSize: 14),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showAddProductDialog() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: const Text('Tambah Produk'),
|
||||||
|
content: const Text(
|
||||||
|
'Dialog tambah produk akan diimplementasikan di sini',
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: const Text('Batal'),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: const Text('Simpan'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showOptionsMenu() {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => Container(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.sort),
|
||||||
|
title: const Text('Urutkan'),
|
||||||
|
onTap: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.filter_list),
|
||||||
|
title: const Text('Filter Lanjutan'),
|
||||||
|
onTap: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.download),
|
||||||
|
title: const Text('Export Data'),
|
||||||
|
onTap: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Product Model
|
||||||
|
class Product {
|
||||||
|
final String id;
|
||||||
|
final String name;
|
||||||
|
final int price;
|
||||||
|
final String category;
|
||||||
|
final int stock;
|
||||||
|
final String imageUrl;
|
||||||
|
bool isActive;
|
||||||
|
|
||||||
|
Product({
|
||||||
|
required this.id,
|
||||||
|
required this.name,
|
||||||
|
required this.price,
|
||||||
|
required this.category,
|
||||||
|
required this.stock,
|
||||||
|
required this.imageUrl,
|
||||||
|
required this.isActive,
|
||||||
|
});
|
||||||
|
}
|
||||||
96
lib/presentation/pages/product/widgets/appbar.dart
Normal file
96
lib/presentation/pages/product/widgets/appbar.dart
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../common/theme/theme.dart';
|
||||||
|
|
||||||
|
class ProductAppbar extends StatelessWidget {
|
||||||
|
final Animation<double> rotationAnimation;
|
||||||
|
const ProductAppbar({super.key, required this.rotationAnimation});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return FlexibleSpaceBar(
|
||||||
|
centerTitle: true,
|
||||||
|
title: Text(
|
||||||
|
'Produk',
|
||||||
|
style: AppStyle.xl.copyWith(
|
||||||
|
color: AppColor.textWhite,
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
background: Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: AppColor.primaryGradient,
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Positioned(
|
||||||
|
right: -20,
|
||||||
|
top: -20,
|
||||||
|
child: AnimatedBuilder(
|
||||||
|
animation: rotationAnimation,
|
||||||
|
builder: (context, child) {
|
||||||
|
return Transform.rotate(
|
||||||
|
angle: rotationAnimation.value,
|
||||||
|
child: Container(
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: AppColor.white.withOpacity(0.1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
left: -30,
|
||||||
|
bottom: -30,
|
||||||
|
child: AnimatedBuilder(
|
||||||
|
animation: rotationAnimation,
|
||||||
|
builder: (context, child) {
|
||||||
|
return Transform.rotate(
|
||||||
|
angle: -rotationAnimation.value * 0.5,
|
||||||
|
child: Container(
|
||||||
|
width: 80,
|
||||||
|
height: 80,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: AppColor.white.withOpacity(0.05),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 80,
|
||||||
|
bottom: 30,
|
||||||
|
child: AnimatedBuilder(
|
||||||
|
animation: rotationAnimation,
|
||||||
|
builder: (context, child) {
|
||||||
|
return Transform.rotate(
|
||||||
|
angle: -rotationAnimation.value * 0.2,
|
||||||
|
child: Container(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
color: AppColor.white.withOpacity(0.08),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../common/theme/theme.dart';
|
||||||
|
|
||||||
|
class ProductCategoryHeaderDelegate extends SliverPersistentHeaderDelegate {
|
||||||
|
final List<String> categories;
|
||||||
|
final String selectedCategory;
|
||||||
|
final ValueChanged<String> onCategoryChanged;
|
||||||
|
|
||||||
|
ProductCategoryHeaderDelegate({
|
||||||
|
required this.categories,
|
||||||
|
required this.selectedCategory,
|
||||||
|
required this.onCategoryChanged,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(
|
||||||
|
BuildContext context,
|
||||||
|
double shrinkOffset,
|
||||||
|
bool overlapsContent,
|
||||||
|
) {
|
||||||
|
return Container(
|
||||||
|
color: AppColor.background,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
|
child: Container(
|
||||||
|
height: 50,
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: categories.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final category = categories[index];
|
||||||
|
final isSelected = selectedCategory == category;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.only(right: 12.0),
|
||||||
|
child: FilterChip(
|
||||||
|
label: Text(category),
|
||||||
|
selected: isSelected,
|
||||||
|
onSelected: (selected) => onCategoryChanged(category),
|
||||||
|
backgroundColor: AppColor.surface,
|
||||||
|
selectedColor: AppColor.primary,
|
||||||
|
checkmarkColor: AppColor.textWhite,
|
||||||
|
labelStyle: AppStyle.md.copyWith(
|
||||||
|
color: isSelected ? AppColor.textWhite : AppColor.textPrimary,
|
||||||
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||||
|
),
|
||||||
|
side: BorderSide(
|
||||||
|
color: isSelected ? AppColor.primary : AppColor.border,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
double get maxExtent => 66.0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
double get minExtent => 66.0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRebuild(ProductCategoryHeaderDelegate oldDelegate) {
|
||||||
|
return oldDelegate.selectedCategory != selectedCategory;
|
||||||
|
}
|
||||||
|
}
|
||||||
191
lib/presentation/pages/product/widgets/product_tile.dart
Normal file
191
lib/presentation/pages/product/widgets/product_tile.dart
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../common/theme/theme.dart';
|
||||||
|
import '../../../components/spacer/spacer.dart';
|
||||||
|
import '../product_page.dart';
|
||||||
|
|
||||||
|
class ProductTile extends StatelessWidget {
|
||||||
|
final Product product;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
const ProductTile({super.key, required this.product, required this.onTap});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: onTap,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.surface,
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
border: Border.all(
|
||||||
|
color: product.isActive
|
||||||
|
? AppColor.border
|
||||||
|
: AppColor.borderLight,
|
||||||
|
),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: AppColor.black.withOpacity(0.05),
|
||||||
|
blurRadius: 10,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [_buildProductImage(), _buildProductInfo()],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Overlay gray untuk produk yang tidak aktif
|
||||||
|
if (!product.isActive)
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.black.withOpacity(0.4),
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
vertical: 8,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.warning,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: AppColor.black.withOpacity(0.2),
|
||||||
|
blurRadius: 4,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.visibility_off,
|
||||||
|
color: AppColor.textWhite,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
SpaceWidth(6),
|
||||||
|
Text(
|
||||||
|
'NONAKTIF',
|
||||||
|
style: AppStyle.sm.copyWith(
|
||||||
|
color: AppColor.textWhite,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildProductImage() {
|
||||||
|
return Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: AppColor.borderLight,
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(12.0),
|
||||||
|
topRight: Radius.circular(12.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Icon(Icons.image, size: 32, color: AppColor.textLight),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildProductInfo() {
|
||||||
|
return Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
product.name,
|
||||||
|
style: AppStyle.sm.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: product.isActive
|
||||||
|
? AppColor.textPrimary
|
||||||
|
: AppColor.textSecondary,
|
||||||
|
),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
_formatPrice(product.price),
|
||||||
|
style: AppStyle.xs.copyWith(
|
||||||
|
color: product.isActive
|
||||||
|
? AppColor.primary
|
||||||
|
: AppColor.textSecondary,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
_buildBottomInfo(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBottomInfo() {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
'Stok: ${product.stock}',
|
||||||
|
style: AppStyle.xs.copyWith(
|
||||||
|
color: AppColor.textSecondary,
|
||||||
|
fontSize: 9,
|
||||||
|
),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.primaryLight.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(3.0),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
product.category,
|
||||||
|
style: AppStyle.xs.copyWith(
|
||||||
|
color: product.isActive
|
||||||
|
? AppColor.primary
|
||||||
|
: AppColor.textSecondary,
|
||||||
|
fontSize: 8,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _formatPrice(int price) {
|
||||||
|
return 'Rp ${price.toString().replaceAllMapped(RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]}.')}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -30,5 +30,8 @@ class AppRouter extends RootStackRouter {
|
|||||||
|
|
||||||
// Schedule
|
// Schedule
|
||||||
AutoRoute(page: ScheduleRoute.page),
|
AutoRoute(page: ScheduleRoute.page),
|
||||||
|
|
||||||
|
// Product
|
||||||
|
AutoRoute(page: ProductRoute.page),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,27 +19,29 @@ import 'package:apskel_owner_flutter/presentation/pages/language/language_page.d
|
|||||||
as _i3;
|
as _i3;
|
||||||
import 'package:apskel_owner_flutter/presentation/pages/main/main_page.dart'
|
import 'package:apskel_owner_flutter/presentation/pages/main/main_page.dart'
|
||||||
as _i5;
|
as _i5;
|
||||||
import 'package:apskel_owner_flutter/presentation/pages/profile/profile_page.dart'
|
import 'package:apskel_owner_flutter/presentation/pages/product/product_page.dart'
|
||||||
as _i6;
|
as _i6;
|
||||||
import 'package:apskel_owner_flutter/presentation/pages/report/report_page.dart'
|
import 'package:apskel_owner_flutter/presentation/pages/profile/profile_page.dart'
|
||||||
as _i7;
|
as _i7;
|
||||||
import 'package:apskel_owner_flutter/presentation/pages/schedule/schedule_page.dart'
|
import 'package:apskel_owner_flutter/presentation/pages/report/report_page.dart'
|
||||||
as _i8;
|
as _i8;
|
||||||
import 'package:apskel_owner_flutter/presentation/pages/splash/splash_page.dart'
|
import 'package:apskel_owner_flutter/presentation/pages/schedule/schedule_page.dart'
|
||||||
as _i9;
|
as _i9;
|
||||||
import 'package:apskel_owner_flutter/presentation/pages/transaction/transaction_page.dart'
|
import 'package:apskel_owner_flutter/presentation/pages/splash/splash_page.dart'
|
||||||
as _i10;
|
as _i10;
|
||||||
import 'package:auto_route/auto_route.dart' as _i11;
|
import 'package:apskel_owner_flutter/presentation/pages/transaction/transaction_page.dart'
|
||||||
|
as _i11;
|
||||||
|
import 'package:auto_route/auto_route.dart' as _i12;
|
||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i1.DailyTasksFormPage]
|
/// [_i1.DailyTasksFormPage]
|
||||||
class DailyTasksFormRoute extends _i11.PageRouteInfo<void> {
|
class DailyTasksFormRoute extends _i12.PageRouteInfo<void> {
|
||||||
const DailyTasksFormRoute({List<_i11.PageRouteInfo>? children})
|
const DailyTasksFormRoute({List<_i12.PageRouteInfo>? children})
|
||||||
: super(DailyTasksFormRoute.name, initialChildren: children);
|
: super(DailyTasksFormRoute.name, initialChildren: children);
|
||||||
|
|
||||||
static const String name = 'DailyTasksFormRoute';
|
static const String name = 'DailyTasksFormRoute';
|
||||||
|
|
||||||
static _i11.PageInfo page = _i11.PageInfo(
|
static _i12.PageInfo page = _i12.PageInfo(
|
||||||
name,
|
name,
|
||||||
builder: (data) {
|
builder: (data) {
|
||||||
return const _i1.DailyTasksFormPage();
|
return const _i1.DailyTasksFormPage();
|
||||||
@ -49,13 +51,13 @@ class DailyTasksFormRoute extends _i11.PageRouteInfo<void> {
|
|||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i2.HomePage]
|
/// [_i2.HomePage]
|
||||||
class HomeRoute extends _i11.PageRouteInfo<void> {
|
class HomeRoute extends _i12.PageRouteInfo<void> {
|
||||||
const HomeRoute({List<_i11.PageRouteInfo>? children})
|
const HomeRoute({List<_i12.PageRouteInfo>? children})
|
||||||
: super(HomeRoute.name, initialChildren: children);
|
: super(HomeRoute.name, initialChildren: children);
|
||||||
|
|
||||||
static const String name = 'HomeRoute';
|
static const String name = 'HomeRoute';
|
||||||
|
|
||||||
static _i11.PageInfo page = _i11.PageInfo(
|
static _i12.PageInfo page = _i12.PageInfo(
|
||||||
name,
|
name,
|
||||||
builder: (data) {
|
builder: (data) {
|
||||||
return const _i2.HomePage();
|
return const _i2.HomePage();
|
||||||
@ -65,13 +67,13 @@ class HomeRoute extends _i11.PageRouteInfo<void> {
|
|||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i3.LanguagePage]
|
/// [_i3.LanguagePage]
|
||||||
class LanguageRoute extends _i11.PageRouteInfo<void> {
|
class LanguageRoute extends _i12.PageRouteInfo<void> {
|
||||||
const LanguageRoute({List<_i11.PageRouteInfo>? children})
|
const LanguageRoute({List<_i12.PageRouteInfo>? children})
|
||||||
: super(LanguageRoute.name, initialChildren: children);
|
: super(LanguageRoute.name, initialChildren: children);
|
||||||
|
|
||||||
static const String name = 'LanguageRoute';
|
static const String name = 'LanguageRoute';
|
||||||
|
|
||||||
static _i11.PageInfo page = _i11.PageInfo(
|
static _i12.PageInfo page = _i12.PageInfo(
|
||||||
name,
|
name,
|
||||||
builder: (data) {
|
builder: (data) {
|
||||||
return const _i3.LanguagePage();
|
return const _i3.LanguagePage();
|
||||||
@ -81,13 +83,13 @@ class LanguageRoute extends _i11.PageRouteInfo<void> {
|
|||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i4.LoginPage]
|
/// [_i4.LoginPage]
|
||||||
class LoginRoute extends _i11.PageRouteInfo<void> {
|
class LoginRoute extends _i12.PageRouteInfo<void> {
|
||||||
const LoginRoute({List<_i11.PageRouteInfo>? children})
|
const LoginRoute({List<_i12.PageRouteInfo>? children})
|
||||||
: super(LoginRoute.name, initialChildren: children);
|
: super(LoginRoute.name, initialChildren: children);
|
||||||
|
|
||||||
static const String name = 'LoginRoute';
|
static const String name = 'LoginRoute';
|
||||||
|
|
||||||
static _i11.PageInfo page = _i11.PageInfo(
|
static _i12.PageInfo page = _i12.PageInfo(
|
||||||
name,
|
name,
|
||||||
builder: (data) {
|
builder: (data) {
|
||||||
return const _i4.LoginPage();
|
return const _i4.LoginPage();
|
||||||
@ -97,13 +99,13 @@ class LoginRoute extends _i11.PageRouteInfo<void> {
|
|||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i5.MainPage]
|
/// [_i5.MainPage]
|
||||||
class MainRoute extends _i11.PageRouteInfo<void> {
|
class MainRoute extends _i12.PageRouteInfo<void> {
|
||||||
const MainRoute({List<_i11.PageRouteInfo>? children})
|
const MainRoute({List<_i12.PageRouteInfo>? children})
|
||||||
: super(MainRoute.name, initialChildren: children);
|
: super(MainRoute.name, initialChildren: children);
|
||||||
|
|
||||||
static const String name = 'MainRoute';
|
static const String name = 'MainRoute';
|
||||||
|
|
||||||
static _i11.PageInfo page = _i11.PageInfo(
|
static _i12.PageInfo page = _i12.PageInfo(
|
||||||
name,
|
name,
|
||||||
builder: (data) {
|
builder: (data) {
|
||||||
return const _i5.MainPage();
|
return const _i5.MainPage();
|
||||||
@ -112,81 +114,97 @@ class MainRoute extends _i11.PageRouteInfo<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i6.ProfilePage]
|
/// [_i6.ProductPage]
|
||||||
class ProfileRoute extends _i11.PageRouteInfo<void> {
|
class ProductRoute extends _i12.PageRouteInfo<void> {
|
||||||
const ProfileRoute({List<_i11.PageRouteInfo>? children})
|
const ProductRoute({List<_i12.PageRouteInfo>? children})
|
||||||
|
: super(ProductRoute.name, initialChildren: children);
|
||||||
|
|
||||||
|
static const String name = 'ProductRoute';
|
||||||
|
|
||||||
|
static _i12.PageInfo page = _i12.PageInfo(
|
||||||
|
name,
|
||||||
|
builder: (data) {
|
||||||
|
return const _i6.ProductPage();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// generated route for
|
||||||
|
/// [_i7.ProfilePage]
|
||||||
|
class ProfileRoute extends _i12.PageRouteInfo<void> {
|
||||||
|
const ProfileRoute({List<_i12.PageRouteInfo>? children})
|
||||||
: super(ProfileRoute.name, initialChildren: children);
|
: super(ProfileRoute.name, initialChildren: children);
|
||||||
|
|
||||||
static const String name = 'ProfileRoute';
|
static const String name = 'ProfileRoute';
|
||||||
|
|
||||||
static _i11.PageInfo page = _i11.PageInfo(
|
static _i12.PageInfo page = _i12.PageInfo(
|
||||||
name,
|
name,
|
||||||
builder: (data) {
|
builder: (data) {
|
||||||
return const _i6.ProfilePage();
|
return const _i7.ProfilePage();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i7.ReportPage]
|
/// [_i8.ReportPage]
|
||||||
class ReportRoute extends _i11.PageRouteInfo<void> {
|
class ReportRoute extends _i12.PageRouteInfo<void> {
|
||||||
const ReportRoute({List<_i11.PageRouteInfo>? children})
|
const ReportRoute({List<_i12.PageRouteInfo>? children})
|
||||||
: super(ReportRoute.name, initialChildren: children);
|
: super(ReportRoute.name, initialChildren: children);
|
||||||
|
|
||||||
static const String name = 'ReportRoute';
|
static const String name = 'ReportRoute';
|
||||||
|
|
||||||
static _i11.PageInfo page = _i11.PageInfo(
|
static _i12.PageInfo page = _i12.PageInfo(
|
||||||
name,
|
name,
|
||||||
builder: (data) {
|
builder: (data) {
|
||||||
return const _i7.ReportPage();
|
return const _i8.ReportPage();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i8.SchedulePage]
|
/// [_i9.SchedulePage]
|
||||||
class ScheduleRoute extends _i11.PageRouteInfo<void> {
|
class ScheduleRoute extends _i12.PageRouteInfo<void> {
|
||||||
const ScheduleRoute({List<_i11.PageRouteInfo>? children})
|
const ScheduleRoute({List<_i12.PageRouteInfo>? children})
|
||||||
: super(ScheduleRoute.name, initialChildren: children);
|
: super(ScheduleRoute.name, initialChildren: children);
|
||||||
|
|
||||||
static const String name = 'ScheduleRoute';
|
static const String name = 'ScheduleRoute';
|
||||||
|
|
||||||
static _i11.PageInfo page = _i11.PageInfo(
|
static _i12.PageInfo page = _i12.PageInfo(
|
||||||
name,
|
name,
|
||||||
builder: (data) {
|
builder: (data) {
|
||||||
return const _i8.SchedulePage();
|
return const _i9.SchedulePage();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i9.SplashPage]
|
/// [_i10.SplashPage]
|
||||||
class SplashRoute extends _i11.PageRouteInfo<void> {
|
class SplashRoute extends _i12.PageRouteInfo<void> {
|
||||||
const SplashRoute({List<_i11.PageRouteInfo>? children})
|
const SplashRoute({List<_i12.PageRouteInfo>? children})
|
||||||
: super(SplashRoute.name, initialChildren: children);
|
: super(SplashRoute.name, initialChildren: children);
|
||||||
|
|
||||||
static const String name = 'SplashRoute';
|
static const String name = 'SplashRoute';
|
||||||
|
|
||||||
static _i11.PageInfo page = _i11.PageInfo(
|
static _i12.PageInfo page = _i12.PageInfo(
|
||||||
name,
|
name,
|
||||||
builder: (data) {
|
builder: (data) {
|
||||||
return const _i9.SplashPage();
|
return const _i10.SplashPage();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i10.TransactionPage]
|
/// [_i11.TransactionPage]
|
||||||
class TransactionRoute extends _i11.PageRouteInfo<void> {
|
class TransactionRoute extends _i12.PageRouteInfo<void> {
|
||||||
const TransactionRoute({List<_i11.PageRouteInfo>? children})
|
const TransactionRoute({List<_i12.PageRouteInfo>? children})
|
||||||
: super(TransactionRoute.name, initialChildren: children);
|
: super(TransactionRoute.name, initialChildren: children);
|
||||||
|
|
||||||
static const String name = 'TransactionRoute';
|
static const String name = 'TransactionRoute';
|
||||||
|
|
||||||
static _i11.PageInfo page = _i11.PageInfo(
|
static _i12.PageInfo page = _i12.PageInfo(
|
||||||
name,
|
name,
|
||||||
builder: (data) {
|
builder: (data) {
|
||||||
return const _i10.TransactionPage();
|
return const _i11.TransactionPage();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user