Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ali haider #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
sol
sagrw committed Sep 2, 2022
commit b4b2fd6834ca0c94c05274a3d536cde30780f249
76 changes: 37 additions & 39 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -70,10 +70,17 @@ class Home extends StatelessWidget {
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class Add extends StatelessWidget {
const Add({Key? key}) : super(key: key);
Add({Key? key}) : super(key: key);

static TextEditingController imageController = TextEditingController();
static TextEditingController descriptionController = TextEditingController();
static TextEditingController nameController = TextEditingController();
static TextEditingController authController = TextEditingController();
static TextEditingController priceController = TextEditingController();

@override
Widget build(BuildContext context) {

return MaterialApp(
home:Scaffold(
appBar: AppBar(
@@ -90,16 +97,16 @@ class Add extends StatelessWidget {
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const [
BackBar(),
AddBook(),
MyTextField(myWidth: 320, myHeight: 50, lines: 1, hint: 'Book Name', suffixIcon: null),
MyTextField(myWidth: 320, myHeight: 50, lines: 1, hint: 'Author Name', suffixIcon: null),
MyTextField(myWidth: 320, myHeight: 50, lines: 1, hint: 'Price', suffixIcon: null),
MyTextField(myWidth: 320, myHeight: 50, lines: 1, hint: 'Image Link', suffixIcon: null),
MyTextField(myWidth: 320, myHeight: 140, lines: 5, hint: 'Description', suffixIcon: null),
AddButton(),
SizedBox(height: 50,)
children: [
const BackBar(),
const AddBook(),
MyTextField(myWidth: 320, myHeight: 50, lines: 1, hint: 'Book Name', suffixIcon: null, myController: nameController),
MyTextField(myWidth: 320, myHeight: 50, lines: 1, hint: 'Author Name', suffixIcon: null, myController: authController),
MyTextField(myWidth: 320, myHeight: 50, lines: 1, hint: 'Price', suffixIcon: null, myController: priceController),
MyTextField(myWidth: 320, myHeight: 50, lines: 1, hint: 'Image Link', suffixIcon: null, myController: imageController),
MyTextField(myWidth: 320, myHeight: 140, lines: 5, hint: 'Description', suffixIcon: null, myController: descriptionController),
const AddButton(),
const SizedBox(height: 50,)
],
),
)
@@ -149,34 +156,25 @@ class Cart extends StatelessWidget {
height: 622,
child: Expanded(
child: ListView(
children: MyBooks.book.map((e) => TextButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => BookDetails(myBook: e,)));
},

style: TextButton.styleFrom(
padding: EdgeInsets.zero
),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 35),
child: Image.network(e.imageLink,
width: 80, height: 130,),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(e.bookName, style: const TextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold),),
Text(e.bookAuth, style: const TextStyle(color: Colors.black87, fontSize: 12,height: 2),),
Text(e.price, style: const TextStyle(color: Colors.black, fontSize: 20,height: 2),),
const Stars(),
],
)
],
),
children: MyBooks.book.where((element) => element.condition.value == true).map((e) => Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 35),
child: Image.network(e.imageLink,
width: 80, height: 130,),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(e.bookName, style: const TextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold),),
Text(e.bookAuth, style: const TextStyle(color: Colors.black87, fontSize: 12,height: 2),),
Text(e.price, style: const TextStyle(color: Colors.black, fontSize: 20,height: 2),),
const Stars(),
],
)
],
),
),).toList()
),
4 changes: 4 additions & 0 deletions lib/modules.dart
Original file line number Diff line number Diff line change
@@ -25,6 +25,10 @@ class MyBooks {
MyBooks(imageLink: 'https://i.harperapps.com/hcanz/covers/9780008563790/x293.jpg', bookName: 'fire and blood8', bookAuth: 'George RR Martin', price: r'$49.99', description: 'good book\ngood book\ngood book\n'),
];

buy(){
condition.value = true;
}

}

class Navigation {
6 changes: 3 additions & 3 deletions lib/my_text_field.dart
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ import 'package:get/get.dart';

class MyTextField extends StatelessWidget {

static TextEditingController myController = TextEditingController();///
final TextEditingController? myController;///
final double? myWidth;
final double? myHeight;
final int lines ;
final int lines;
final String hint;
final IconData? suffixIcon;
const MyTextField({
Key? key,required this.myWidth, required this.myHeight, required this.lines, required this.hint, required this.suffixIcon,
Key? key,required this.myWidth, required this.myHeight, required this.lines, required this.hint, required this.suffixIcon, required this.myController,
}) : super(key: key);

@override
2 changes: 1 addition & 1 deletion lib/page_1/card_2.dart
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ class Card2 extends StatelessWidget {
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(vertical: 20),
child: MyTextField(myWidth: double.maxFinite, myHeight: 50, lines: 1, hint: 'Search...', suffixIcon: Icons.search_rounded, ),
child: MyTextField(myWidth: double.maxFinite, myHeight: 50, lines: 1, hint: 'Search...', suffixIcon: Icons.search_rounded, myController: null, ),
);
}
}
5 changes: 2 additions & 3 deletions lib/page_1/card_4.dart
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import 'package:get/get.dart';

class Card4 extends StatelessWidget {

static RxString search = MyTextField.myController.text.obs;///
const Card4({
Key? key,
}) : super(key: key);
@@ -22,10 +21,10 @@ class Card4 extends StatelessWidget {
child: Expanded(
child: ListView(
children: MyBooks.book.map((e) => TextButton(
onPressed: () {
onPressed: (){
e.buy();
Navigator.push(context, MaterialPageRoute(builder: (context) => BookDetails(myBook: e,)));
},

style: TextButton.styleFrom(
padding: EdgeInsets.zero
),
2 changes: 1 addition & 1 deletion lib/page_1/card_5.dart
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ class Card5 extends StatelessWidget {
onPressed: (){
if(e.icon == Icons.add){
MyBooks.selectedIcon.value = Icons.add;
Navigator.push(context, MaterialPageRoute(builder: (context) => const Add()));
Navigator.push(context, MaterialPageRoute(builder: (context) => Add()));
}else if(e.icon == Icons.shopping_cart){
MyBooks.selectedIcon.value = Icons.shopping_cart;
Navigator.push(context, MaterialPageRoute(builder: (context) => const Cart()));
7 changes: 6 additions & 1 deletion lib/page_3/card_3.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

import 'package:book_store_app/main.dart';
import 'package:book_store_app/modules.dart';
import 'package:flutter/material.dart';

class AddButton extends StatelessWidget {
@@ -9,7 +11,10 @@ class AddButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return TextButton(
onPressed: (){},
onPressed: (){
MyBooks.book.add(MyBooks(imageLink: Add.imageController.text, bookName: Add.nameController.text,
bookAuth: Add.authController.text, price: Add.priceController.text, description: Add.descriptionController.text));
},
style: TextButton.styleFrom(
padding: EdgeInsets.zero
),