Skip to content

Commit

Permalink
fix chapter screen
Browse files Browse the repository at this point in the history
  • Loading branch information
febryardiansyah committed Jul 25, 2020
1 parent 20c0d63 commit 36b6b5b
Show file tree
Hide file tree
Showing 21 changed files with 614 additions and 243 deletions.
Binary file added assets/images/aqua-chibi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/aqua.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/tenkinokowp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions lib/bloc/manga_list_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ class MangaListBloc extends Bloc<MangaListEvent, MangaListState> {
if(event is InitialFetchMangaEvent){
yield* _initialEventToState(currentState, page);
}
if(event is RefreshMangaEvent){
yield MangaListLoadingState();
try{
final list = await _mangaListRepo.getMangaList(page: page);
yield MangaListStateLoaded(hasReachedMax: false,mangaList: list,page: page);
}catch(e){
yield MangaListStateFailure(msg: e.toString());
}
}
}
Stream<MangaListState> _fetchMangaToState(MangaListState currentState,int page)async*{
try{
Expand Down
3 changes: 2 additions & 1 deletion lib/bloc/manga_list_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ abstract class MangaListEvent extends Equatable{
}

class FetchManga extends MangaListEvent{}
class InitialFetchMangaEvent extends MangaListEvent{}
class InitialFetchMangaEvent extends MangaListEvent{}
class RefreshMangaEvent extends MangaListEvent{}
3 changes: 2 additions & 1 deletion lib/bloc/mangabygenre_bloc/manga_by_genre_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ class MangaByGenreBloc extends Bloc<MangaByGenreEvent, MangaByGenreState> {
yield MangaByGenreLoadingState();
List<MangaByGenreModel> list = await _mangaByGenreRepo.getManga(genre: event.endpoint,page: page+=1);
yield MangaByGenreLoadedState(list: list,page: page+=1,hasReachedMax: false);
return;
}
if(currentState is MangaByGenreLoadedState){
List<MangaByGenreModel> list = await _mangaByGenreRepo.getManga(genre: event.endpoint,page: currentState.page);
yield list.isEmpty ? currentState.copyWith(hasReachedMax: true):
yield list.isEmpty ? currentState.copyWith(hasReachedMax: true,list: currentState.list):
MangaByGenreLoadedState(list: currentState.list+list,hasReachedMax: false,page:
currentState.page+=1);
}
Expand Down
37 changes: 34 additions & 3 deletions lib/components/splash_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:mangamint/repositories/recommended_repo.dart';
import 'package:provider/provider.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:mangamint/constants/base_color.dart';

class SplashScreen extends StatefulWidget {
@override
Expand All @@ -20,9 +23,37 @@ class _SplashScreenState extends State<SplashScreen> {
}
@override
Widget build(BuildContext context) {
ScreenUtil.init();
return Scaffold(
body: Center(
child: Text('splashscreen'),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Stack(
alignment: Alignment.center,
children: [
Container(
width: MediaQuery.of(context).size.width,
height: 120,
),
Positioned(
top: 20,
left: 240.w,
child: Text('MangaKah ?',style: TextStyle(color: BaseColor.grey1),)),
Positioned(
right: 20,
top: 0,
child: Image.asset('assets/images/aqua-chibi.png',fit: BoxFit.fill,height: 100,width: 100)),
Text('MangaMint',style: GoogleFonts.modak(
color: BaseColor.red,fontSize: 45
),),
],
),
Text('Baca Manga & Komik\nBahasa Indonesia',textAlign: TextAlign.center,),
SizedBox(height: 40,),
SpinKitThreeBounce(color: BaseColor.red,size: 30,)
],
)
),
);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hive/hive.dart';
Expand Down Expand Up @@ -37,7 +38,7 @@ void main() async{
Hive.registerAdapter(HiveChapterModelAdapter());
Hive.registerAdapter(HiveMangaModelAdapter());
Hive.registerAdapter(HiveChapterOpenedModelAdapter());
runApp(MyApp());
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]).then((value) => runApp(MyApp()));
}

class MyApp extends StatelessWidget {
Expand Down
109 changes: 72 additions & 37 deletions lib/screens/chapter_screen/chapter_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:equatable/equatable.dart';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
Expand Down Expand Up @@ -76,47 +77,81 @@ class _ChapterScreenState extends State<ChapterScreen> {
builder:(context,chapter) => Scrollbar(
child: Stack(
children: [
PhotoViewGallery.builder(
pageController: PageController(
// PhotoViewGallery.builder(
// pageController: PageController(
// initialPage: widget.currentIndex,
// ),
// itemCount: widget.data.chapterImage.length,
// scrollPhysics: BouncingScrollPhysics(),
// builder: (context, i) {
// return PhotoViewGalleryPageOptions(
// imageProvider: NetworkImage(
// widget.data.chapterImage[i].chapter_image_link),
// minScale: PhotoViewComputedScale.contained * 1,
// maxScale: PhotoViewComputedScale.covered * 2.0,
// initialScale: PhotoViewComputedScale.contained * 1.0,
// heroAttributes: PhotoViewHeroAttributes(
// tag: widget.data.chapterImage[i].number));
// },
// scrollDirection:_isHorizontal? Axis.horizontal:Axis.vertical,
// onPageChanged: (int value){
// final data = HiveChapterModel(
// index: value,
// endpoint: widget.data.chapter_endpoint
// );
// chapter.add(data);
// setState(() {
// widget.currentIndex = value;
// });
// },
// loadFailedChild: Text('Failed Load image'),
// loadingBuilder: (context, event) => Center(
// child: Container(
// width: 20.0,
// height: 20.0,
// child: CircularProgressIndicator(
// value: event == null
// ? 0
// : event.cumulativeBytesLoaded /
// event.expectedTotalBytes,
// ),
// ),
// ),
// ),
ExtendedImageGesturePageView.builder(
itemCount: widget.data.chapterImage.length,
scrollDirection:_isHorizontal? Axis.horizontal:Axis.vertical,
controller: PageController(
initialPage: widget.currentIndex,
),
itemCount: widget.data.chapterImage.length,
scrollPhysics: BouncingScrollPhysics(),
builder: (context, i) {
return PhotoViewGalleryPageOptions(
imageProvider: NetworkImage(
widget.data.chapterImage[i].chapter_image_link),
minScale: PhotoViewComputedScale.contained * 1,
maxScale: PhotoViewComputedScale.covered * 2.0,
initialScale: PhotoViewComputedScale.contained * 1.0,
heroAttributes: PhotoViewHeroAttributes(
tag: widget.data.chapterImage[i].number));
},
scrollDirection:_isHorizontal? Axis.horizontal:Axis.vertical,
onPageChanged: (int value){
final data = HiveChapterModel(
itemBuilder: (context,i){
return ExtendedImage.network(widget.data.chapterImage[i].chapter_image_link,
mode: ExtendedImageMode.gesture,
initGestureConfigHandler: (state)=>GestureConfig(
minScale: 0.9,
animationMinScale: 0.7,
maxScale: 3.0,
animationMaxScale: 3.5,
speed: 1.0,
inertialSpeed: 100.0,
initialScale: 1.0,
inPageView: true,
cacheGesture: false
),
);
},
onPageChanged: (value){
final data = HiveChapterModel(
index: value,
endpoint: widget.data.chapter_endpoint
);
chapter.add(data);
setState(() {
widget.currentIndex = value;
});
},
loadFailedChild: Text('Failed Load image'),
loadingBuilder: (context, event) => Center(
child: Container(
width: 20.0,
height: 20.0,
child: CircularProgressIndicator(
value: event == null
? 0
: event.cumulativeBytesLoaded /
event.expectedTotalBytes,
),
),
),
),
);
chapter.add(data);
setState(() {
widget.currentIndex = value;
});
},
physics: BouncingScrollPhysics(),
),
Positioned(
bottom: 0,
left: 10,
Expand Down
Loading

0 comments on commit 36b6b5b

Please sign in to comment.