239 lines
7.3 KiB
Dart
239 lines
7.3 KiB
Dart
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:testmoduleb_1/DetialHome.dart';
|
|
import 'package:testmoduleb_1/homeType.dart';
|
|
|
|
import 'DisCover.dart';
|
|
|
|
class HomePage extends StatefulWidget {
|
|
const HomePage({super.key});
|
|
|
|
@override
|
|
State<HomePage> createState() => _HomePageState();
|
|
}
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
int pageIndex = 0;
|
|
late PageController pageController;
|
|
List<String> assetString = [
|
|
"lib/image/Bouillabaisse.jpg",
|
|
"lib/image/brioche.jpg",
|
|
"lib/image/Burgundy beef .jpg",
|
|
"lib/image/Burgundy beef_2.jpg"
|
|
];
|
|
List<String> assetString2 = [
|
|
'lib/image/icon_90.png',
|
|
"lib/image/icon_91.png",
|
|
"lib/image/icon_92.png",
|
|
];
|
|
List<String> string1 = [
|
|
"Main dishes",
|
|
"pastries",
|
|
"Soups"
|
|
];
|
|
int currindex = 1;
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
pageController = PageController(initialPage: pageIndex);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
appBar: currindex==0? AppBar(
|
|
backgroundColor: Colors.white,
|
|
elevation: 4,
|
|
centerTitle: true,
|
|
title: Text("Chef",style: TextStyle(fontSize: 18,fontWeight: FontWeight.w500,color: Colors.amber)),
|
|
):null,
|
|
body:currindex==0?DetialCover() :CustomScrollView(
|
|
slivers: [
|
|
SliverToBoxAdapter(
|
|
child: Stack(
|
|
children: [
|
|
myPageView(),
|
|
Positioned(bottom: 16, left: 0, right: 0, child: myPageIndex())
|
|
],
|
|
)),
|
|
SliverToBoxAdapter(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16,vertical: 16),
|
|
child: Text("Main categories",style: TextStyle(fontSize: 18,fontWeight: FontWeight.w500,color: Colors.black87),),
|
|
),
|
|
),
|
|
SliverToBoxAdapter(
|
|
child: myListView1(),
|
|
),
|
|
SliverToBoxAdapter(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16,vertical: 16),
|
|
child: Text("Popular food",style: TextStyle(fontSize: 18,fontWeight: FontWeight.w500,color: Colors.black87),),
|
|
),
|
|
),
|
|
SliverToBoxAdapter(
|
|
child: SizedBox(
|
|
height: 450,
|
|
child: ListView(
|
|
scrollDirection: Axis.horizontal,
|
|
shrinkWrap: true,
|
|
children: [
|
|
myPopularImage(),
|
|
myPopularImage(),
|
|
],
|
|
),
|
|
)
|
|
)
|
|
],
|
|
),
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
currentIndex: currindex,
|
|
onTap: (int newint){
|
|
setState(() {
|
|
currindex= newint;
|
|
});
|
|
},
|
|
selectedItemColor: Colors.grey,
|
|
showUnselectedLabels: false,
|
|
items: [
|
|
BottomNavigationBarItem(icon: Image.asset("lib/image/icon_40.png",height: 30,
|
|
width: 30,),label: "Discover"),
|
|
BottomNavigationBarItem(icon: Icon(Icons.home,color: Colors.grey,),label: "home"),
|
|
],
|
|
|
|
),
|
|
);
|
|
}
|
|
|
|
|
|
|
|
myPopularImage(){
|
|
return GestureDetector(
|
|
onTap: ()=>Navigator.of(context).push(MaterialPageRoute(builder: (c)=>DetailHomePage())),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: PhysicalModel(
|
|
color: Colors.white,
|
|
elevation: 4,
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: Container(
|
|
width: MediaQuery.of(context).size.width-40,
|
|
child: Stack(
|
|
children: [
|
|
Positioned(
|
|
left: 0,
|
|
right: 0,
|
|
top: 0,
|
|
bottom: 120,
|
|
child: Image.asset("lib/image/brioche.jpg",fit: BoxFit.cover)
|
|
),
|
|
Positioned(
|
|
left: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text("Matsutake foie gras",style: TextStyle(fontSize: 18,fontWeight: FontWeight.w500,color: Colors.black87),),
|
|
Column(
|
|
children: [Icon(Icons.star,color: Colors.amber,),Text("5.0")],
|
|
)
|
|
],
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Text("Matsutake goose liver "
|
|
"is a delicious dish that combines matsutake an"
|
|
"d goose liver. Matsutake is a precious wild mushroom wit"
|
|
"h a unique aroma and rich taste. Goose liver, on the other hand"
|
|
", is a luxurious poultry...",style: TextStyle(color: Colors.grey),),
|
|
)
|
|
],
|
|
),
|
|
)
|
|
],
|
|
)
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
|
|
myListView1(){
|
|
return GestureDetector(
|
|
onTap: ()=>Navigator.of(context).push(MaterialPageRoute(builder: (c)=>HomeTypePage())),
|
|
child: Container(
|
|
height: 140,
|
|
child: ListView.builder(
|
|
scrollDirection: Axis.horizontal,
|
|
padding: EdgeInsets.symmetric(horizontal: 16,vertical: 4),
|
|
itemCount: 3,
|
|
itemBuilder: (context,index){
|
|
return Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
|
child: PhysicalModel(
|
|
elevation: 4,
|
|
color: Colors.white,
|
|
shadowColor: Colors.amber.withOpacity(0.8),
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: SizedBox(
|
|
width: 100,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Center(child: Image.asset(assetString2[index],fit: BoxFit.cover,height: 80,)),
|
|
Text(string1[index])
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
)
|
|
),
|
|
);
|
|
}
|
|
|
|
myPageView() {
|
|
return Container(
|
|
height: 250,
|
|
child: PageView(
|
|
scrollDirection: Axis.horizontal,
|
|
controller: pageController,
|
|
onPageChanged: (int newIndex) {
|
|
setState(() {
|
|
pageIndex = newIndex;
|
|
});
|
|
},
|
|
children: assetString
|
|
.map((e) => Image.asset(
|
|
e,
|
|
fit: BoxFit.cover,
|
|
))
|
|
.toList()),
|
|
);
|
|
}
|
|
|
|
myPageIndex() {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: List.generate(
|
|
4,
|
|
(index) => Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 8),
|
|
child: Icon(Icons.circle,
|
|
size: 16,
|
|
color:
|
|
index == pageIndex ? Colors.black54 : Colors.white))),
|
|
|
|
);
|
|
}
|
|
}
|