Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:food_app/api/place_api.dart';
- import 'package:food_app/model/place.dart';
- import 'package:food_app/notifier/place_notifier.dart';
- import 'package:food_app/screens/place_form.dart';
- import 'package:flutter/material.dart';
- import 'package:provider/provider.dart';
- class FoodDetail extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- FoodNotifier foodNotifier = Provider.of<FoodNotifier>(context);
- _onFoodDeleted(Food food) {
- Navigator.pop(context);
- foodNotifier.deleteFood(food);
- }
- List allImgs = [
- Image.network(foodNotifier.currentFood.image != null
- ? foodNotifier.currentFood.image
- : 'https://www.testingxperts.com/wp-content/uploads/2019/02/placeholder-img.jpg')
- ];
- return Scaffold(
- appBar: AppBar(title: Text(foodNotifier.currentFood.name)),
- body: Stack(
- children: <Widget>[
- Align(
- alignment: Alignment.topCenter,
- child: Container(
- height: 300.0,
- child: PageView.builder(
- itemCount: allImgs.length,
- pageSnapping: true,
- itemBuilder: (BuildContext context, int i) {
- return Container(
- child: Image.network(allImgs[i], fit: BoxFit.cover),
- );
- }),
- ),
- ),
- Align(
- alignment: Alignment.topCenter,
- child: Container(
- height: 75.0,
- child: AppBar(
- actions: <Widget>[
- IconButton(
- icon: Icon(
- Icons.share,
- color: Colors.white,
- size: 16.0,
- ),
- onPressed: () {
- Navigator.of(context).pop();
- },
- )
- ],
- leading: IconButton(
- icon: Icon(
- Icons.arrow_back_ios,
- color: Colors.white,
- size: 20.0,
- ),
- onPressed: () {
- Navigator.of(context).pop();
- },
- ),
- backgroundColor: Colors.transparent,
- elevation: 0.0,
- ),
- ),
- ),
- Align(
- alignment: Alignment.bottomCenter,
- child: Container(
- height: MediaQuery.of(context).size.height - 280,
- decoration: BoxDecoration(
- color: Colors.white, borderRadius: BorderRadius.circular(20)),
- child: Stack(
- children: <Widget>[
- Container(
- width: double.infinity,
- margin: EdgeInsets.only(bottom: 60),
- child: SingleChildScrollView(
- padding: EdgeInsets.all(30),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.start,
- children: <Widget>[
- Text(
- foodNotifier.currentFood.name,
- style: TextStyle(
- fontSize: 19.0, fontWeight: FontWeight.bold),
- ),
- SizedBox(height: 10),
- Row(
- children: <Widget>[
- Icon(Icons.star,
- color: Colors.orange, size: 20),
- Icon(Icons.star,
- color: Colors.orange, size: 20),
- Icon(Icons.star,
- color: Colors.orange, size: 20),
- Icon(Icons.star,
- color: Colors.orange, size: 20),
- Icon(Icons.star,
- color: Colors.orange, size: 20),
- SizedBox(width: 10),
- Text(
- "4.9",
- style: TextStyle(
- fontSize: 14.0,
- color: Colors.orange,
- fontWeight: FontWeight.bold),
- ),
- ],
- ),
- SizedBox(height: 20),
- Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Row(
- children: <Widget>[
- Text("\$ ",
- style: TextStyle(
- fontSize: 15.0,
- color: Colors.orange,
- fontWeight: FontWeight.bold)),
- Text(foodNotifier.currentFood.price,
- style: TextStyle(
- fontSize: 20.0,
- color: Colors.orange,
- fontWeight: FontWeight.bold)),
- ],
- ),
- Text("Price",
- style: TextStyle(
- fontSize: 15.0,
- color: Colors.grey,
- fontWeight: FontWeight.bold)),
- ],
- ),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Row(
- children: <Widget>[
- Text("1",
- style: TextStyle(
- fontSize: 20.0,
- color: Colors.orange,
- fontWeight: FontWeight.bold)),
- Text(" room ",
- style: TextStyle(
- fontSize: 15.0,
- color: Colors.orange,
- fontWeight: FontWeight.bold)),
- Text("2",
- style: TextStyle(
- fontSize: 20.0,
- color: Colors.orange,
- fontWeight: FontWeight.bold)),
- Text(" hall",
- style: TextStyle(
- fontSize: 15.0,
- color: Colors.orange,
- fontWeight: FontWeight.bold)),
- ],
- ),
- Text("Room",
- style: TextStyle(
- fontSize: 15.0,
- color: Colors.grey,
- fontWeight: FontWeight.bold)),
- ],
- ),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Row(
- children: <Widget>[
- Text(foodNotifier.currentFood.size,
- style: TextStyle(
- fontSize: 20.0,
- color: Colors.orange,
- fontWeight: FontWeight.bold)),
- Text(" m²",
- style: TextStyle(
- fontSize: 14.0,
- color: Colors.orange,
- fontWeight: FontWeight.bold)),
- ],
- ),
- Text("Area",
- style: TextStyle(
- fontSize: 15.0,
- color: Colors.grey,
- fontWeight: FontWeight.bold)),
- ],
- ),
- ],
- ),
- SizedBox(height: 30),
- Column(
- children: <Widget>[
- GridView.count(
- shrinkWrap: true,
- scrollDirection: Axis.vertical,
- padding: EdgeInsets.all(8),
- crossAxisCount: 5,
- crossAxisSpacing: 4,
- mainAxisSpacing: 4,
- children: foodNotifier.currentFood.features
- .map(
- (features) => Card(
- color: Colors.black54,
- child: Center(
- child: Text(
- features,
- style: TextStyle(
- color: Colors.white,
- fontSize: 16),
- ),
- ),
- ),
- )
- .toList(),
- ),
- ],
- ),
- SizedBox(height: 30),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "Description",
- style: TextStyle(
- fontSize: 18.0,
- fontWeight: FontWeight.bold),
- ),
- ],
- ),
- SizedBox(height: 10),
- Text(foodNotifier.currentFood.description,
- textAlign: TextAlign.justify,
- style: TextStyle(fontSize: 14.0)),
- ],
- )),
- ),
- Align(
- alignment: Alignment.bottomCenter,
- child: Container(
- decoration: BoxDecoration(boxShadow: [
- BoxShadow(
- blurRadius: 3.0,
- color: Colors.grey.withOpacity(0.1),
- spreadRadius: 2.0)
- ]),
- height: 60,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Container(
- height: 60,
- width: MediaQuery.of(context).size.width / 2 - 30,
- alignment: Alignment(0, 0),
- child: Icon(Icons.chat, color: Colors.deepOrange),
- ),
- Container(
- height: 60,
- width: MediaQuery.of(context).size.width / 2 + 30,
- alignment: Alignment(0, 0),
- color: Colors.blue[600],
- child: Text(
- "Contact",
- style: TextStyle(
- fontSize: 17.0, color: Colors.white),
- ),
- )
- ],
- ),
- ),
- ),
- Align(
- alignment: Alignment(0.7, -1.25),
- child: ClipRRect(
- borderRadius: BorderRadius.circular(20),
- child: SizedBox(
- height: 80,
- width: 80,
- child: Image.network(
- 'https://www.testingxperts.com/wp-content/uploads/2019/02/placeholder-img.jpg',
- fit: BoxFit.cover)),
- ),
- ),
- ],
- ),
- ),
- ),
- ],
- ),
- floatingActionButton: Column(
- mainAxisAlignment: MainAxisAlignment.end,
- children: <Widget>[
- FloatingActionButton(
- heroTag: 'button1',
- onPressed: () {
- Navigator.of(context).push(
- MaterialPageRoute(builder: (BuildContext context) {
- return FoodForm(
- isUpdating: true,
- );
- }),
- );
- },
- child: Icon(Icons.edit),
- foregroundColor: Colors.white,
- ),
- SizedBox(height: 20),
- FloatingActionButton(
- heroTag: 'button2',
- onPressed: () =>
- deleteFood(foodNotifier.currentFood, _onFoodDeleted),
- child: Icon(Icons.delete),
- backgroundColor: Colors.red,
- foregroundColor: Colors.white,
- ),
- ],
- ),
- );
- }
- }
Add Comment
Please, Sign In to add comment