Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
44 changes: 44 additions & 0 deletions lib/add_book_page/addBookPage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:book_store_app/add_book_page/input_book_field.dart';
import 'package:book_store_app/models/myColor.dart';
import 'package:book_store_app/models/myUiComponent.dart';
import 'package:flutter/material.dart';

class AddBookPage extends StatefulWidget {
const AddBookPage({Key? key}) : super(key: key);

@override
State<AddBookPage> createState() => _AddBookPageState();
}

class _AddBookPageState extends State<AddBookPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: MyColor.backgroundColor,
body: Padding(
padding: const EdgeInsets.symmetric(vertical: 55, horizontal: 5),
child: Column(
children: [
const MyAppBar(),
Padding(
padding: const EdgeInsets.only(left: 20,right: 20,top: 30),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const[
Text(
'Add Book',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
InputBookDetails()

],
),
),


],
),
),
);
}
}
59 changes: 59 additions & 0 deletions lib/add_book_page/input_book_field.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import 'package:book_store_app/models/myColor.dart';
import 'package:book_store_app/models/book_data.dart';
import 'package:flutter/material.dart';

import 'inputfields.dart';

TextEditingController nameControl = TextEditingController();
TextEditingController authorControl = TextEditingController();
TextEditingController priceControl = TextEditingController();
TextEditingController linkControl = TextEditingController();
TextEditingController descriptionControl = TextEditingController();

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


@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(top: 60, left: 15, right: 15),
child: Column(
children: [
InputField(myControl: nameControl, hint: 'Book Name', errorOn: true, line: 1,),
InputField(myControl: authorControl, hint: 'Author Name', errorOn: true, line: 1,),
InputField(myControl: priceControl, hint: 'Price', errorOn: true, line: 1,),
InputField(myControl: linkControl, hint: 'Image link', errorOn: false, line: 1,),
InputField(myControl: descriptionControl, hint: 'Description', errorOn: false, line: 7,),
Container(
height: 60,
width: double.maxFinite,
decoration: BoxDecoration(
color: MyColor.primaryColor,
borderRadius: BorderRadius.circular(16),
boxShadow: const [
BoxShadow(
color: Color.fromARGB(10, 7, 8, 14),
spreadRadius: 7,
blurRadius: 32,
offset: Offset(0, 7),
)
]),
child: TextButton(
onPressed: () {
BookData.addBook();
},
child: const Text(
'Add',
style: TextStyle(color: Colors.white, fontSize: 16),
)),
),


],
),
);
}
}
59 changes: 59 additions & 0 deletions lib/add_book_page/inputfields.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

import 'package:flutter/material.dart';
import '../models/myColor.dart';

class InputField extends StatefulWidget {
const InputField({
Key? key, required this.myControl, required this.hint, required this.errorOn, required this.line,
}) : super(key: key);
final String hint;
final TextEditingController myControl;
final bool errorOn;
final int line;
@override
State<InputField> createState() => _InputFieldState();
}

class _InputFieldState extends State<InputField> {
String? error;
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.only(bottom: 22),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: MyColor.shadowTextFieldColor,
spreadRadius: 7,
blurRadius: 32,
offset: const Offset(0, 7),
)
]),
child: TextField(
textInputAction: TextInputAction.next,
maxLines: widget.line,
controller: widget.myControl,
onChanged: (x){
if(widget.errorOn) {
if (x.isEmpty) {
error = 'Required';
}else{
error=null;
}
setState(() {});
}
},
decoration: InputDecoration(
hintText: widget.hint,
hintStyle: TextStyle(color: MyColor.hintTextFieldColor),
filled: true,
fillColor: Colors.white,
disabledBorder: InputBorder.none,
border: InputBorder.none,
errorText: error,
),
),
);
}
}
Binary file added lib/assets/images/profile.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions lib/book_details_page/action_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

import 'package:book_store_app/models/myColor.dart';
import 'package:flutter/material.dart';

class ActionOnBook extends StatelessWidget {
const ActionOnBook({
Key? key, required this.text, required this.icon,
}) : super(key: key);

final String text;
final IconData icon;

@override
Widget build(BuildContext context) {
return Container(
height: 40,
width: 150,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow:const [
BoxShadow(
color: Color.fromARGB(50, 7, 8, 14),
spreadRadius: 7,
blurRadius: 32,
offset: Offset(0, 7),
)
]),
child: TextButton(
onPressed: () {},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(icon,
color: MyColor.primaryColor),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
text,
style: TextStyle(
color: MyColor.primaryColor,
fontSize: 14,
fontWeight: FontWeight.bold),
),
)
],
),
),
);
}
}

71 changes: 71 additions & 0 deletions lib/book_details_page/bookDetalisPage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import 'package:book_store_app/book_details_page/action_card.dart';
import 'package:book_store_app/book_details_page/book_card.dart';
import 'package:book_store_app/models/book_data.dart';
import 'package:book_store_app/models/myUiComponent.dart';
import 'package:book_store_app/models/myColor.dart';
import 'package:flutter/material.dart';

class BookDetailsPage extends StatelessWidget {
const BookDetailsPage({Key? key, required this.myBook}) : super(key: key);

final BookData myBook;

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: MyColor.backgroundColor,
body: Padding(
padding: const EdgeInsets.symmetric(vertical: 55, horizontal: 20),
child: Stack(children: [
Column(
children: [const MyAppBar(), BookDetails(data: myBook)],
),
Align(
alignment: Alignment.bottomCenter,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: const [
ActionOnBook(
text: 'Preview', icon: Icons.format_align_left),
ActionOnBook(text: 'Reviews', icon: Icons.reviews),
],
),
Padding(
padding: const EdgeInsets.only(top: 30),
child: Container(
height: 60,
width: double.maxFinite,
decoration: BoxDecoration(
color: MyColor.primaryColor,
borderRadius: BorderRadius.circular(16),
boxShadow: const [
BoxShadow(
color: Color.fromARGB(10, 7, 8, 14),
spreadRadius: 7,
blurRadius: 32,
offset: Offset(0, 7),
)
]),
child: TextButton(
onPressed: () {
myBook.addBuyList();
},
child: Text(
'Buy Now for \$${myBook.bookPrice}',
style: const TextStyle(
color: Colors.white, fontSize: 16),
)),
)),
],
),
)
]),
),
),
);
}
}
109 changes: 109 additions & 0 deletions lib/book_details_page/book_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import 'package:book_store_app/models/book_data.dart';
import 'package:book_store_app/models/myColor.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';

class BookDetails extends StatelessWidget {
const BookDetails({
Key? key,
required this.data,
}) : super(key: key);

//'https://api.lorem.space/image/book?w=216&h=320'
final BookData data;

@override
Widget build(BuildContext context) {
return Column(
children: [
SizedBox(
width: 216,
height: 320,
child: Image.network(
data.bookLink,
fit: BoxFit.fitWidth,
width: 216,
height: 320,
errorBuilder: (context, url, error) => const Icon(Icons.error),
)),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Text(data.bookName,
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: MyColor.primaryColor)),
),
Text(data.authorName,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: MyColor.secondColor,
)),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.star,
size: 14,
color: MyColor.yellowStarColor,
),
Icon(
Icons.star,
size: 14,
color: MyColor.yellowStarColor,
),
Icon(
Icons.star,
size: 14,
color: MyColor.yellowStarColor,
),
Icon(
Icons.star,
size: 14,
color: MyColor.yellowStarColor,
),
Icon(
Icons.star_half_outlined,
size: 14,
color: MyColor.yellowStarColor,
),
Padding(
padding: const EdgeInsets.only(left: 12),
child: Text(
'4.5',
style: TextStyle(
color: MyColor.primaryColor,
fontSize: 12,
fontWeight: FontWeight.bold),
),
),
Text('/5.0',
style:
TextStyle(color: MyColor.fullRateTextColor, fontSize: 12))
],
),
),
Text(data.bookDescription,maxLines: 3,overflow:TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: MyColor.secondColor,
)),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: GestureDetector(
onTap: (){
Get.defaultDialog(title: 'Book Description',middleText:data.bookDescription ,middleTextStyle: TextStyle(fontSize: 14,
fontWeight: FontWeight.bold,
color: MyColor.secondColor,) );
},
child: Text('more details click here' ,style: TextStyle(fontSize: 12,color: MyColor.secondColor))),
)
],
);
}
}
Loading