refact:tidy up code

This commit is contained in:
pahmiudahgede 2025-05-14 20:17:38 +07:00
parent 438c95746f
commit 45e35e6e85
14 changed files with 266 additions and 538 deletions

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:rijig_mobile/core/utils/guide.dart';
class ActivityScreen extends StatefulWidget { class ActivityScreen extends StatefulWidget {
const ActivityScreen({super.key}); const ActivityScreen({super.key});
@ -12,6 +13,7 @@ class _ActivityScreenState extends State<ActivityScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final titleofscreen = "Aktivitas"; final titleofscreen = "Aktivitas";
return Scaffold( return Scaffold(
backgroundColor: whiteColor,
body: Center(child: Text("ini adalah halaman $titleofscreen")), body: Center(child: Text("ini adalah halaman $titleofscreen")),
); );
} }

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:rijig_mobile/core/utils/guide.dart';
class CartScreen extends StatefulWidget { class CartScreen extends StatefulWidget {
const CartScreen({super.key}); const CartScreen({super.key});
@ -12,6 +13,7 @@ class _CartScreenState extends State<CartScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final titleofscreen = "Cart"; final titleofscreen = "Cart";
return Scaffold( return Scaffold(
backgroundColor: whiteColor,
body: Center(child: Text("ini adalah halaman $titleofscreen")), body: Center(child: Text("ini adalah halaman $titleofscreen")),
); );
} }

View File

@ -1,67 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class Categories extends StatelessWidget {
const Categories({super.key});
@override
Widget build(BuildContext context) {
List<Map<String, dynamic>> categories = [
{"icon": "assets/icons/Flash Icon.svg", "text": "Flash Deal"},
{"icon": "assets/icons/Bill Icon.svg", "text": "Bill"},
{"icon": "assets/icons/Game Icon.svg", "text": "Game"},
{"icon": "assets/icons/Gift Icon.svg", "text": "Daily Gift"},
{"icon": "assets/icons/Discover.svg", "text": "More"},
];
return Padding(
padding: const EdgeInsets.all(20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(
categories.length,
(index) => CategoryCard(
icon: categories[index]["icon"],
text: categories[index]["text"],
press: () {},
),
),
),
);
}
}
class CategoryCard extends StatelessWidget {
const CategoryCard({
super.key,
required this.icon,
required this.text,
required this.press,
});
final String icon, text;
final GestureTapCallback press;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: press,
child: Column(
children: [
Container(
padding: const EdgeInsets.all(16),
height: 56,
width: 56,
decoration: BoxDecoration(
color: const Color(0xFFFFECDF),
borderRadius: BorderRadius.circular(10),
),
child: SvgPicture.asset(icon),
),
const SizedBox(height: 4),
Text(text, textAlign: TextAlign.center)
],
),
);
}
}

View File

@ -1,62 +0,0 @@
import 'package:flutter/material.dart';
class DiscountBanner extends StatelessWidget {
const DiscountBanner({super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildCard(
'Pendapatan',
'Rp 35.000',
Icons.account_balance_wallet,
),
_buildCard('Sampah', '10 Kg', Icons.delete),
],
),
],
),
);
}
Widget _buildCard(String title, String value, IconData icon) {
return Expanded(
child: Card(
elevation: 4,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
// Icon on the left
Icon(icon, color: Colors.blue, size: 40),
SizedBox(width: 10),
// Column for title and value on the right
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
SizedBox(height: 8),
Text(
value,
style: TextStyle(fontSize: 14, color: Colors.black54),
),
],
),
],
),
),
),
);
}
}

View File

@ -1,37 +0,0 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:iconsax_flutter/iconsax_flutter.dart';
import 'package:rijig_mobile/core/utils/guide.dart';
class HomeHeader extends StatelessWidget {
const HomeHeader({super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Rijig", style: Tulisan.heading(color: primaryColor)),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Icon(Iconsax.notification),
Gap(10),
Icon(Iconsax.message_2),
],
),
],
),
),
const SizedBox(width: 16),
],
),
);
}
}

View File

@ -1,65 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
// import '../../../constants.dart';
class IconBtnWithCounter extends StatelessWidget {
const IconBtnWithCounter({
super.key,
required this.svgSrc,
this.numOfitem = 0,
required this.press,
});
final String svgSrc;
final int numOfitem;
final GestureTapCallback press;
@override
Widget build(BuildContext context) {
return InkWell(
borderRadius: BorderRadius.circular(100),
onTap: press,
child: Stack(
clipBehavior: Clip.none,
children: [
Container(
padding: const EdgeInsets.all(12),
height: 46,
width: 46,
decoration: BoxDecoration(
// color: kSecondaryColor.withOpacity(0.1),
shape: BoxShape.circle,
),
child: SvgPicture.asset(svgSrc),
),
if (numOfitem != 0)
Positioned(
top: -3,
right: 0,
child: Container(
height: 20,
width: 20,
decoration: BoxDecoration(
color: const Color(0xFFFF4848),
shape: BoxShape.circle,
border: Border.all(width: 1.5, color: Colors.white),
),
child: Center(
child: Text(
"$numOfitem",
style: const TextStyle(
fontSize: 12,
height: 1,
fontWeight: FontWeight.w600,
color: Colors.white,
),
),
),
),
)
],
),
);
}
}

View File

@ -1,52 +0,0 @@
import 'package:flutter/material.dart';
import 'package:rijig_mobile/features/home/model/product.dart';
import 'package:rijig_mobile/features/home/components/product_card.dart';
class PopularProducts extends StatelessWidget {
const PopularProducts({super.key});
@override
Widget build(BuildContext context) {
return Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Artikel",
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.black,
),
),
],
),
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
...List.generate(demoProducts.length, (index) {
if (demoProducts[index].isPopular) {
return Padding(
padding: const EdgeInsets.only(left: 20),
child: ProductCard(
product: demoProducts[index],
onPress: () {},
),
);
}
return const SizedBox.shrink(); // here by default width and height is 0
}),
const SizedBox(width: 20),
],
),
),
],
);
}
}

View File

@ -1,34 +0,0 @@
// import 'package:flutter/material.dart';
// import '../../../constants.dart';
// class SearchField extends StatelessWidget {
// const SearchField({
// Key? key,
// }) : super(key: key);
// @override
// Widget build(BuildContext context) {
// return Form(
// child: TextFormField(
// onChanged: (value) {},
// decoration: InputDecoration(
// filled: true,
// fillColor: kSecondaryColor.withOpacity(0.1),
// contentPadding:
// const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
// border: searchOutlineInputBorder,
// focusedBorder: searchOutlineInputBorder,
// enabledBorder: searchOutlineInputBorder,
// hintText: "Search product",
// prefixIcon: const Icon(Icons.search),
// ),
// ),
// );
// }
// }
// const searchOutlineInputBorder = OutlineInputBorder(
// borderRadius: BorderRadius.all(Radius.circular(12)),
// borderSide: BorderSide.none,
// );

View File

@ -1,130 +0,0 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
class SpecialOffers extends StatelessWidget {
const SpecialOffers({super.key});
@override
Widget build(BuildContext context) {
return Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Important!",
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.black,
),
),
],
),
// child: SectionTitle(
// title: "Special for you",
// // press: () {},
// ),
),
const Gap(15),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
SpecialOfferCard(
image: "assets/image/Image Banner 2.png",
category: "Smartphone",
numOfBrands: 18,
press: () {
// Navigator.pushNamed(context, ProductsScreen.routeName);
},
),
SpecialOfferCard(
image: "assets/image/Image Banner 3.png",
category: "Fashion",
numOfBrands: 24,
press: () {
// Navigator.pushNamed(context, ProductsScreen.routeName);
},
),
const SizedBox(width: 20),
],
),
),
],
);
}
}
class SpecialOfferCard extends StatelessWidget {
const SpecialOfferCard({
super.key,
required this.category,
required this.image,
required this.numOfBrands,
required this.press,
});
final String category, image;
final int numOfBrands;
final GestureTapCallback press;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(left: 20),
child: GestureDetector(
onTap: press,
child: SizedBox(
width: 242,
height: 100,
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Stack(
children: [
Image.asset(image, fit: BoxFit.cover),
Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.black54,
Colors.black38,
Colors.black26,
Colors.transparent,
],
),
),
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 15,
vertical: 10,
),
child: Text.rich(
TextSpan(
style: const TextStyle(color: Colors.white),
children: [
TextSpan(
text: "$category\n",
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
TextSpan(text: "$numOfBrands Brands"),
],
),
),
),
],
),
),
),
),
);
}
}

View File

@ -1,10 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:iconsax_flutter/iconsax_flutter.dart';
import 'package:rijig_mobile/core/utils/guide.dart'; import 'package:rijig_mobile/core/utils/guide.dart';
import 'package:rijig_mobile/features/home/components/categories.dart'; import 'package:rijig_mobile/features/home/components/product_card.dart';
import 'package:rijig_mobile/features/home/components/discount_banner.dart'; import 'package:rijig_mobile/features/home/model/product.dart';
import 'package:rijig_mobile/features/home/components/home_header.dart'; import 'package:rijig_mobile/widget/card_withicon.dart';
import 'package:rijig_mobile/features/home/components/popular_product.dart';
import 'package:rijig_mobile/features/home/components/special_offers.dart';
class HomeScreen extends StatefulWidget { class HomeScreen extends StatefulWidget {
const HomeScreen({super.key}); const HomeScreen({super.key});
@ -20,16 +20,199 @@ class _HomeScreenState extends State<HomeScreen> {
backgroundColor: whiteColor, backgroundColor: whiteColor,
body: SafeArea( body: SafeArea(
child: SingleChildScrollView( child: SingleChildScrollView(
padding: EdgeInsets.symmetric(vertical: 16), padding: PaddingCustom().paddingHorizontalVertical(16, 20),
child: Column( child: Column(
children: [ children: [
HomeHeader(), Row(
DiscountBanner(), mainAxisAlignment: MainAxisAlignment.spaceBetween,
Categories(), children: [
SpecialOffers(), Expanded(
SizedBox(height: 20), child: Row(
PopularProducts(), mainAxisAlignment: MainAxisAlignment.spaceBetween,
SizedBox(height: 20), children: [
Text(
"Rijig",
style: Tulisan.heading(color: primaryColor),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Icon(Iconsax.notification),
Gap(10),
Icon(Iconsax.message_2),
],
),
],
),
),
],
),
Gap(20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CardWithIcon(
icon: Icons.account_circle,
text: 'Users',
number: '245',
onTap: () {},
),
CardWithIcon(
icon: Icons.shopping_cart,
text: 'Orders',
number: '178',
onTap: () {},
),
],
),
Gap(20),
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Important!",
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.black,
),
),
],
),
const Gap(15),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
SpecialOfferCard(
image: "assets/image/Image Banner 2.png",
category: "Smartphone",
numOfBrands: 18,
press: () {},
),
Gap(10),
SpecialOfferCard(
image: "assets/image/Image Banner 3.png",
category: "Fashion",
numOfBrands: 24,
press: () {},
),
],
),
),
],
),
Gap(20),
Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Artikel",
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.black,
),
),
],
),
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
...List.generate(demoProducts.length, (index) {
if (demoProducts[index].isPopular) {
return Padding(
padding: const EdgeInsets.only(left: 20),
child: ProductCard(
product: demoProducts[index],
onPress: () {},
),
);
}
return const SizedBox.shrink();
}),
const SizedBox(width: 20),
],
),
),
],
),
],
),
),
),
);
}
}
class SpecialOfferCard extends StatelessWidget {
const SpecialOfferCard({
super.key,
required this.category,
required this.image,
required this.numOfBrands,
required this.press,
});
final String category, image;
final int numOfBrands;
final GestureTapCallback press;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: press,
child: SizedBox(
width: 242,
height: 100,
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Stack(
children: [
Image.asset(image, fit: BoxFit.cover),
Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.black54,
Colors.black38,
Colors.black26,
Colors.transparent,
],
),
),
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 15,
vertical: 10,
),
child: Text.rich(
TextSpan(
style: const TextStyle(color: Colors.white),
children: [
TextSpan(
text: "$category\n",
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
TextSpan(text: "$numOfBrands Brands"),
],
),
),
),
], ],
), ),
), ),

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:rijig_mobile/core/network/network_info.dart'; import 'package:rijig_mobile/core/network/network_info.dart';
import 'package:rijig_mobile/core/router.dart'; import 'package:rijig_mobile/core/router.dart';
import 'package:rijig_mobile/core/storage/expired_token.dart'; import 'package:rijig_mobile/core/storage/expired_token.dart';
import 'package:rijig_mobile/core/utils/guide.dart';
// import 'package:rijig_mobile/core/storage/secure_storage.dart'; // import 'package:rijig_mobile/core/storage/secure_storage.dart';
class SplashScreen extends StatefulWidget { class SplashScreen extends StatefulWidget {
@ -67,7 +68,7 @@ class SplashScreenState extends State<SplashScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Colors.white, backgroundColor: primaryColor,
body: Stack( body: Stack(
children: [ children: [
Positioned( Positioned(
@ -85,7 +86,7 @@ class SplashScreenState extends State<SplashScreen> {
style: TextStyle( style: TextStyle(
fontSize: 36, fontSize: 36,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Colors.blue, color: whiteColor,
fontFamily: 'Roboto', fontFamily: 'Roboto',
), ),
), ),

View File

@ -8,14 +8,7 @@ class RequestPickScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: CustomAppBar(judul: "Pilih Sampah"), appBar: CustomAppBar(judul: "Pilih Sampah"),
body: Center( body: Center(child: Text("pilih sampah anda")),
child: ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: Text("Back to Home"),
),
),
); );
} }
} }

View File

@ -0,0 +1,62 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:rijig_mobile/core/utils/guide.dart';
class CardWithIcon extends StatelessWidget {
final IconData icon;
final String text;
final String number;
final Function() onTap;
const CardWithIcon({
super.key,
required this.icon,
required this.text,
required this.number,
required this.onTap,
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Container(
width: 164,
height: 120,
padding: const EdgeInsets.fromLTRB(14, 8, 13, 9),
decoration: BoxDecoration(
color: Colors.transparent.withValues(alpha: 3.5),
borderRadius: const BorderRadius.all(Radius.circular(13)),
border: Border.all(color: greyColor, width: 1),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(icon, size: 30, color: primaryColor),
const SizedBox(width: 8, height: 20),
Text(
text,
style: GoogleFonts.dmSans(
textStyle: TextStyle(
fontSize: 12,
fontWeight: regular,
color: greyColor,
),
),
),
Text(
number,
style: GoogleFonts.roboto(
textStyle: TextStyle(
fontSize: 16,
fontWeight: bold,
color: greyColor,
),
),
),
],
),
),
);
}
}

View File

@ -1,68 +0,0 @@
import 'package:flutter/material.dart';
class InformationCard extends StatelessWidget {
const InformationCard({super.key});
@override
Widget build(BuildContext context) {
return Container(
height: 120,
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: const Color(0xFF1F1F1F),
borderRadius: BorderRadius.circular(12.0),
),
child: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Membership',
style: TextStyle(
color: Colors.white,
fontSize: 18.0,
fontWeight: FontWeight.w600,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'594',
style: TextStyle(
color: Colors.white,
fontSize: 27.0,
fontWeight: FontWeight.bold,
),
),
Text(
'US\$496',
style: TextStyle(
color: Colors.white,
fontSize: 27.0,
fontWeight: FontWeight.bold,
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Total members',
style: TextStyle(
color: Colors.white70,
fontSize: 16.0,
fontWeight: FontWeight.w600,
),
),
Text(
'Per month',
style: TextStyle(color: Colors.white70, fontSize: 17.0),
),
],
),
],
),
);
}
}