adding pagination
This commit is contained in:
parent
b1f9e7a533
commit
1af0ad52da
|
|
@ -0,0 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class AboutUsScreen extends StatelessWidget {
|
||||
const AboutUsScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: const Center(child: Text('About Us Screen')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class ContactsScreen extends StatelessWidget {
|
||||
const ContactsScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: const Center(child: Text('Contacts Screen')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class NewArrivalScreen extends StatelessWidget {
|
||||
const NewArrivalScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: const Center(child: Text('New Arrival Screen')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class SalesScreen extends StatelessWidget {
|
||||
const SalesScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: const Center(child: Text('Sales Screen')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,10 +3,15 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:sapaly_shop/screens/category/category_screen.dart';
|
||||
import 'package:sapaly_shop/screens/drawer/contacts.dart';
|
||||
import 'package:sapaly_shop/screens/drawer/new_arrival.dart';
|
||||
import 'package:sapaly_shop/screens/drawer/sales.dart';
|
||||
import 'package:sapaly_shop/screens/drawer/shops.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import '../../services/app_constants.dart';
|
||||
import '../../themes/app_theme.dart';
|
||||
import 'about_us.dart';
|
||||
|
||||
class SapalyDrawer extends StatelessWidget {
|
||||
SapalyDrawer({super.key});
|
||||
|
|
@ -31,11 +36,11 @@ class SapalyDrawer extends StatelessWidget {
|
|||
|
||||
List<Widget> routes = [
|
||||
const CategoryScreen(),
|
||||
Container(),
|
||||
Container(),
|
||||
Container(),
|
||||
Container(),
|
||||
Container(),
|
||||
const AboutUsScreen(),
|
||||
const SalesScreen(),
|
||||
const NewArrivalScreen(),
|
||||
const ShopsScreen(),
|
||||
const ContactsScreen(),
|
||||
];
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class ShopsScreen extends StatelessWidget {
|
||||
const ShopsScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: const Center(child: Text('Shops Screen')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -91,166 +91,180 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
|||
},
|
||||
actionOnTap: () {},
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: AppConstants.verticalPadding(context),
|
||||
vertical: AppConstants.verticalPadding(context) / 2,
|
||||
horizontal: AppConstants.horizontalPadding(context),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 50.adaptedPx(),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.whiteColor,
|
||||
borderRadius: BorderRadius.circular(30.adaptedPx()),
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const SearchScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30.adaptedPx()),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 15.adaptedPx()),
|
||||
child: SvgPicture.asset('assets/icons/search.svg'),
|
||||
),
|
||||
Text(
|
||||
'searchHint'.translation,
|
||||
style: GoogleFonts.poppins(
|
||||
textStyle: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.bodyMedium
|
||||
?.copyWith(
|
||||
fontSize: 16.adaptedPx(),
|
||||
color: AppTheme.lightTextColor,
|
||||
child: NestedScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
||||
SliverToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 50.adaptedPx(),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.whiteColor,
|
||||
borderRadius: BorderRadius.circular(30.adaptedPx()),
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const SearchScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(30.adaptedPx()),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 15.adaptedPx()),
|
||||
child: SvgPicture.asset(
|
||||
'assets/icons/search.svg'),
|
||||
),
|
||||
Text(
|
||||
'searchHint'.translation,
|
||||
style: GoogleFonts.poppins(
|
||||
textStyle: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.bodyMedium
|
||||
?.copyWith(
|
||||
fontSize: 16.adaptedPx(),
|
||||
color: AppTheme.lightTextColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
CarouselSlider(
|
||||
items: (sliders != null)
|
||||
? [
|
||||
for (int i = 0; i < sliders.length; i++)
|
||||
CachedNetworkImage(
|
||||
imageUrl: sliders[i].img,
|
||||
width: AppConstants.deviceWidth(context),
|
||||
fit: BoxFit.contain,
|
||||
progressIndicatorBuilder: (context, url, progress) =>
|
||||
const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
]
|
||||
: [
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
],
|
||||
options: CarouselOptions(
|
||||
initialPage: 0,
|
||||
padEnds: true,
|
||||
scrollPhysics: const BouncingScrollPhysics(),
|
||||
viewportFraction: 1,
|
||||
autoPlay: true,
|
||||
onPageChanged: (index, reason) {
|
||||
setState(() {
|
||||
currentPage = index;
|
||||
});
|
||||
},
|
||||
autoPlayAnimationDuration: const Duration(seconds: 2),
|
||||
autoPlayInterval: const Duration(seconds: 5),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(
|
||||
sliders.length,
|
||||
(index) => buildDot(
|
||||
index: index,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsets.only(top: 20.adaptedPx(), bottom: 10.adaptedPx()),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
'categories'.translation,
|
||||
style:
|
||||
Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
|
||||
color: AppTheme.blackColor,
|
||||
fontSize: 18.adaptedPx(),
|
||||
fontWeight: FontWeight.w600,
|
||||
CarouselSlider(
|
||||
items: (sliders != null)
|
||||
? [
|
||||
for (int i = 0; i < sliders.length; i++)
|
||||
CachedNetworkImage(
|
||||
imageUrl: sliders[i].img,
|
||||
width: AppConstants.deviceWidth(context),
|
||||
fit: BoxFit.contain,
|
||||
progressIndicatorBuilder:
|
||||
(context, url, progress) =>
|
||||
const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
]
|
||||
: [
|
||||
const Center(
|
||||
child: CircularProgressIndicator()),
|
||||
],
|
||||
options: CarouselOptions(
|
||||
initialPage: 0,
|
||||
padEnds: true,
|
||||
scrollPhysics: const BouncingScrollPhysics(),
|
||||
viewportFraction: 1,
|
||||
autoPlay: true,
|
||||
onPageChanged: (index, reason) {
|
||||
setState(() {
|
||||
currentPage = index;
|
||||
});
|
||||
},
|
||||
autoPlayAnimationDuration:
|
||||
const Duration(seconds: 2),
|
||||
autoPlayInterval: const Duration(seconds: 5),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
categories.isEmpty
|
||||
? Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10.adaptedPx()),
|
||||
child: const Center(child: CircularProgressIndicator()),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10.adaptedPx()),
|
||||
child: ButtonsTabBar(
|
||||
controller: tabController,
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(horizontal: 20.adaptedPx()),
|
||||
splashColor: AppTheme.lightPrimaryColor,
|
||||
radius: 10.adaptedPx(),
|
||||
backgroundColor: AppTheme.lightPrimaryColor,
|
||||
buttonMargin: EdgeInsets.only(
|
||||
left: 0,
|
||||
right: 15.adaptedPx(),
|
||||
),
|
||||
onTap: (value) {
|
||||
setState(() {
|
||||
categoryId = categories[value].id;
|
||||
debugPrint(categoryId.toString());
|
||||
});
|
||||
},
|
||||
unselectedBackgroundColor: AppTheme.whiteColor,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
tabs: [
|
||||
for (var category in categories)
|
||||
Tab(text: category.name)
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(
|
||||
sliders.length,
|
||||
(index) => buildDot(
|
||||
index: index,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20.adaptedPx(), bottom: 10.adaptedPx()),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
'categories'.translation,
|
||||
style: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.bodyMedium
|
||||
?.copyWith(
|
||||
color: AppTheme.blackColor,
|
||||
fontSize: 18.adaptedPx(),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
categories.isEmpty
|
||||
? Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 10.adaptedPx()),
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 10.adaptedPx()),
|
||||
child: ButtonsTabBar(
|
||||
controller: tabController,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
horizontal: 20.adaptedPx()),
|
||||
splashColor: AppTheme.lightPrimaryColor,
|
||||
radius: 10.adaptedPx(),
|
||||
backgroundColor: AppTheme.lightPrimaryColor,
|
||||
buttonMargin: EdgeInsets.only(
|
||||
left: 0,
|
||||
right: 15.adaptedPx(),
|
||||
),
|
||||
onTap: (value) {
|
||||
setState(() {
|
||||
categoryId = categories[value].id;
|
||||
debugPrint(categoryId.toString());
|
||||
});
|
||||
},
|
||||
unselectedBackgroundColor:
|
||||
AppTheme.whiteColor,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
tabs: [
|
||||
for (var category in categories)
|
||||
Tab(text: category.name)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15.adaptedPx()),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15.adaptedPx()),
|
||||
SizedBox(
|
||||
height: AppConstants.deviceHeight(context),
|
||||
child: tabController != null
|
||||
? TabBarView(
|
||||
controller: tabController,
|
||||
children: categories.isNotEmpty
|
||||
? categories
|
||||
.map(
|
||||
(category) => Products(
|
||||
id: category.id,
|
||||
),
|
||||
)
|
||||
.toList()
|
||||
: [],
|
||||
)
|
||||
: Container(),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
body: tabController != null
|
||||
? TabBarView(
|
||||
controller: tabController,
|
||||
children: categories.isNotEmpty
|
||||
? categories
|
||||
.map(
|
||||
(category) => Products(
|
||||
id: category.id,
|
||||
),
|
||||
)
|
||||
.toList()
|
||||
: [],
|
||||
)
|
||||
: Container()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
abstract class LoginService {}
|
||||
|
|
@ -83,7 +83,7 @@ class API {
|
|||
.map((item) => CategoryModel.fromJson(item, currentLanguage))
|
||||
.toList();
|
||||
} catch (e) {
|
||||
debugPrint('Category ' + e.toString());
|
||||
debugPrint('Category ' + e.toString());
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue