add project
This commit is contained in:
32
lib/ui/drawer_sidbar/sidbar_profile.dart
Normal file
32
lib/ui/drawer_sidbar/sidbar_profile.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SidBarProfile extends StatelessWidget {
|
||||
const SidBarProfile({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
children: [
|
||||
DrawerHeader(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.pinkAccent,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: const [
|
||||
CircleAvatar(
|
||||
radius: 50,
|
||||
backgroundImage: NetworkImage('https://i2-prod.manchestereveningnews.co.uk/incoming/article17511268.ece/ALTERNATES/s615/0_GettyImages-1141569167.jpg'),
|
||||
),
|
||||
SizedBox(height: 10.0,),
|
||||
Text("Mr Brahim Man")
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
57
lib/ui/favorite_screen.dart
Normal file
57
lib/ui/favorite_screen.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:provider_state/model/products.dart';
|
||||
|
||||
import '../provider/card.dart';
|
||||
|
||||
class FavoriteScreen extends StatelessWidget {
|
||||
List<ProductModel> favoriteList;
|
||||
|
||||
FavoriteScreen({Key? key, required this.favoriteList}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var obj = Provider.of<CardProvider>(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.pinkAccent,
|
||||
),
|
||||
body: ListView.separated(
|
||||
itemCount: favoriteList.length,
|
||||
separatorBuilder: (context, index) =>
|
||||
const Divider(color: Colors.red, thickness: 1.0),
|
||||
itemBuilder: (context, index) {
|
||||
final data = favoriteList[index];
|
||||
return InkWell(
|
||||
onTap: () => obj.addCard(data),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(data.id.toString()),
|
||||
const SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Text(data.name.toString()),
|
||||
],
|
||||
),
|
||||
data.select
|
||||
? const Icon(
|
||||
Icons.done,
|
||||
color: Colors.blue,
|
||||
)
|
||||
: const SizedBox.shrink()
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
93
lib/ui/myapp.dart
Normal file
93
lib/ui/myapp.dart
Normal file
@@ -0,0 +1,93 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:provider_state/model/products.dart';
|
||||
import 'package:provider_state/provider/card.dart';
|
||||
import 'package:provider_state/ui/drawer_sidbar/sidbar_profile.dart';
|
||||
import 'package:provider_state/ui/favorite_screen.dart';
|
||||
|
||||
class HomeScreen extends StatelessWidget {
|
||||
const HomeScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var obj = Provider.of<CardProvider>(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.lightBlue,
|
||||
title: const Text("Provider"),
|
||||
actions: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
FavoriteScreen(favoriteList: obj.localStorage),
|
||||
));
|
||||
},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
textDirection: TextDirection.rtl,
|
||||
children: [
|
||||
const Icon(Icons.favorite, size: 30, color: Colors.pink),
|
||||
obj.isLocal
|
||||
? Positioned(
|
||||
left: 0,
|
||||
top: 10,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.white.withOpacity(0.4)),
|
||||
child: Text("${obj.localStorage.length}",
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14)),
|
||||
))
|
||||
: const SizedBox.shrink(),
|
||||
],
|
||||
))
|
||||
],
|
||||
),
|
||||
drawer: const SidBarProfile(),
|
||||
body: ListView.separated(
|
||||
itemCount: ProductModel.person.length,
|
||||
separatorBuilder: (context, index) =>
|
||||
const Divider(color: Colors.red, thickness: 1.0),
|
||||
itemBuilder: (context, index) {
|
||||
final data = ProductModel.person[index];
|
||||
return InkWell(
|
||||
onTap: () => obj.addCard(data),
|
||||
child: Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(data.id.toString()),
|
||||
const SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Text(data.name.toString()),
|
||||
],
|
||||
),
|
||||
data.select
|
||||
? const Icon(
|
||||
Icons.done,
|
||||
color: Colors.blue,
|
||||
)
|
||||
: const SizedBox.shrink()
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user