Skip to content

Commit

Permalink
add a new features (tap bar ui only)
Browse files Browse the repository at this point in the history
  • Loading branch information
He9sham committed Jul 26, 2024
1 parent 13f8b23 commit 660f83f
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 31 deletions.
15 changes: 9 additions & 6 deletions lib/book_app.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import 'package:bookly_app/const.dart';
import 'package:bookly_app/core/utils/app_routers.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';

class BooklyApp extends StatelessWidget {
const BooklyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routerConfig: AppRouter.router,
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: kprimarycolor,
textTheme: GoogleFonts.montserratTextTheme(ThemeData.dark().textTheme),
return ScreenUtilInit(
child: MaterialApp.router(
routerConfig: AppRouter.router,
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: kprimarycolor,
textTheme: GoogleFonts.montserratTextTheme(ThemeData.dark().textTheme),
),
debugShowCheckedModeBanner: false,
),
debugShowCheckedModeBanner: false,
);
}
}
6 changes: 4 additions & 2 deletions lib/features/home/data/repo/home_repo_impl.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import 'package:bookly_app/core/errors/failure.dart';
import 'package:bookly_app/core/Services/api_service.dart';
import 'package:bookly_app/core/errors/failure.dart';
import 'package:bookly_app/features/home/data/Models/bookmodels/bookmodels.dart';
import 'package:bookly_app/features/home/data/repo/home_repo.dart';
import 'package:dartz/dartz.dart';
import 'package:dio/dio.dart';

String categoryType = 'programming';

class HomeRepoImpl implements HomeRepo {
ApiService apiService;
HomeRepoImpl(this.apiService);
@override
Future<Either<Failure, List<Bookmodels>>> fetchFeatureBooks() async {
try {
var data = await apiService.get(
endpoints: 'volumes?Filtering=free-ebooks&q=subject:programming');
endpoints: 'volumes?Filtering=free-ebooks&q=subject:$categoryType');
List<Bookmodels> books = [];
for (var item in data['items']) {
books.add(Bookmodels.fromJson(item));
Expand Down
2 changes: 1 addition & 1 deletion lib/features/home/views/widgets/best_seller_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BestSellerListView extends StatelessWidget {
itemCount: state.books.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
padding: const EdgeInsets.symmetric(vertical: 7),
child: BestSellerViewItem(
bookmodels: state.books[index],
),
Expand Down
37 changes: 37 additions & 0 deletions lib/features/home/views/widgets/custom_tapbar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class CustomTapBar extends StatelessWidget {
const CustomTapBar({super.key});

@override
Widget build(BuildContext context) {
return SizedBox(
height: 45.h,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 6,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 6),
child: Container(
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius: BorderRadius.circular(12),
),
height: 20.h,
width: 95.w,
child: const Center(
child: Text(
'programing',
style: TextStyle(
color: Colors.white, fontWeight: FontWeight.w600),
),
),
),
);
},
),
);
}
}
38 changes: 24 additions & 14 deletions lib/features/home/views/widgets/home_view_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import 'package:bookly_app/const.dart';
import 'package:bookly_app/core/utils/styles.dart';
import 'package:bookly_app/features/home/logic/feature_books_list/feature_books_list_cubit.dart';
import 'package:bookly_app/features/home/logic/newset_books_list/newset_books_list_cubit.dart';
import 'package:bookly_app/features/home/views/widgets/auth_router.dart';
import 'package:bookly_app/features/home/views/widgets/best_seller_list_view.dart';
import 'package:bookly_app/features/home/views/widgets/custom_appbar.dart';
import 'package:bookly_app/features/home/views/widgets/custom_drawer.dart';
import 'package:bookly_app/features/home/views/widgets/custom_tapbar.dart';
import 'package:bookly_app/features/home/views/widgets/feature_books_list_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:go_router/go_router.dart';

Expand All @@ -24,9 +25,7 @@ class HomeViewBody extends StatelessWidget {
),
body: RefreshIndicator(
onRefresh: () async {
context.read<FeatureBooksListCubit>().fetchFeatureBooks();
context.read<NewsetBooksListCubit>().fetchNewsetBooks();
await Future.delayed(const Duration(seconds: 2));
await refrashMethod(context);
},
child: CustomScrollView(
slivers: [
Expand All @@ -39,25 +38,22 @@ class HomeViewBody extends StatelessWidget {
horizontal: 30, vertical: 30),
child: CustomAppBar(
onPressed2: () {
context
.read<FeatureBooksListCubit>()
.scaffoldstate
.currentState!
.openDrawer();
openDrawerMethod(context);
},
icon: FontAwesomeIcons.magnifyingGlass,
onPressed: () {
GoRouter.of(context).push('/SearchView');
},
),
),
const AuthRouter(),
const SizedBox(
height: 20,
const CustomTapBar(),
// const AuthRouter(),
SizedBox(
height: 20.h,
),
const FeatureBooksListView(),
const SizedBox(
height: 30,
SizedBox(
height: 25.h,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 30),
Expand All @@ -80,4 +76,18 @@ class HomeViewBody extends StatelessWidget {
),
);
}

void openDrawerMethod(BuildContext context) {
context
.read<FeatureBooksListCubit>()
.scaffoldstate
.currentState!
.openDrawer();
}

Future<void> refrashMethod(BuildContext context) async {
context.read<FeatureBooksListCubit>().fetchFeatureBooks();
context.read<NewsetBooksListCubit>().fetchNewsetBooks();
await Future.delayed(const Duration(seconds: 2));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:bookly_app/core/utils/styles.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

class BookRate extends StatelessWidget {
const BookRate({super.key, required this.pagecount, required this.languch});
Expand All @@ -11,13 +10,8 @@ class BookRate extends StatelessWidget {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
FontAwesomeIcons.solidStar,
color: Color(0xffFFDD4F),
size: 16,
),
Text(
' $pagecount',
'Page count ($pagecount) ||',
style: Styles.textmid.copyWith(
fontSize: 16,
),
Expand Down
4 changes: 3 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import 'package:bookly_app/book_app.dart';
import 'package:bookly_app/core/Services/server_locator.dart';
import 'package:bookly_app/core/errors/error_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

void main() {
void main() async {
await ScreenUtil.ensureScreenSize();
errorWidget();
setupServerLocator();
runApp(const BooklyApp());
Expand Down

0 comments on commit 660f83f

Please sign in to comment.