Skip to content

Commit

Permalink
added season later
Browse files Browse the repository at this point in the history
  • Loading branch information
febryardiansyah committed May 5, 2020
1 parent ba8bae4 commit 7408b3b
Show file tree
Hide file tree
Showing 14 changed files with 367 additions and 72 deletions.
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.
61 changes: 61 additions & 0 deletions lib/bloc/seasonLaterBloc/season_later_bloc.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import 'package:animku/models/current_season_model.dart';
import 'package:animku/repository/season_later_repo.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

abstract class SeasonLaterEvent extends Equatable{}

class FetchSeasonLaterEvent extends SeasonLaterEvent{
@override
// TODO: implement props
List<Object> get props => null;
}

abstract class SeasonLaterState extends Equatable{}

class SeasonLaterInitialState extends SeasonLaterState{
@override
// TODO: implement props
List<Object> get props => [];
}
class SeasonLaterLoadedState extends SeasonLaterState{
List<AnimeList>animeList;

SeasonLaterLoadedState({this.animeList});

@override
// TODO: implement props
List<Object> get props => [animeList];
}
class SeasonLaterErrorState extends SeasonLaterState{
String message;

SeasonLaterErrorState({this.message});

@override
// TODO: implement props
List<Object> get props => [message];
}

class SeasonLaterBloc extends Bloc<SeasonLaterEvent,SeasonLaterState>{
SeasonLaterRepository seasonLaterRepository;

SeasonLaterBloc({this.seasonLaterRepository});

@override
// TODO: implement initialState
SeasonLaterState get initialState => SeasonLaterInitialState();

@override
Stream<SeasonLaterState> mapEventToState(SeasonLaterEvent event) async*{
if(event is FetchSeasonLaterEvent){
yield SeasonLaterInitialState();
try{
List<AnimeList> animeList = await seasonLaterRepository.fetchSeasonLater();
yield SeasonLaterLoadedState(animeList: animeList);
}catch(e){
yield SeasonLaterErrorState(message: e.toString());
}
}
}
}
22 changes: 10 additions & 12 deletions lib/components/bottom_navbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ class _BottomNavBarState extends State<BottomNavBar> {

_bottomScrollListener(){
if(MyVariable.bottomBarCtrl.position.userScrollDirection == ScrollDirection.reverse){
setState(() {
bottomBarVisible = false;
});
if(mounted){
setState(() {
bottomBarVisible = false;
});
}
}
if(MyVariable.bottomBarCtrl.position.userScrollDirection == ScrollDirection.forward){
setState(() {
bottomBarVisible = true;
});
if(mounted){
setState(() {
bottomBarVisible = true;
});
}
}
}
@override
Expand All @@ -54,12 +58,6 @@ class _BottomNavBarState extends State<BottomNavBar> {
MyVariable.bottomBarCtrl.addListener(_bottomScrollListener);
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
MyVariable.bottomBarCtrl.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: _children[currentIndex],
Expand Down
54 changes: 33 additions & 21 deletions lib/components/my_app_bar.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import 'package:animku/components/bottom_navbar.dart';
import 'package:animku/components/my_drawer.dart';
import 'package:animku/environments/colors.dart';
import 'package:animku/environments/dictionary.dart';
import 'package:animku/environments/my_fonts.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

class MyAppbar extends StatefulWidget {
final Widget body;
final Widget myList;
final Widget myGrid;
final onRefresh;
bool isList;

MyAppbar(
{@required this.body, @required this.isList, this.myList, this.myGrid,this.onRefresh});
MyAppbar({@required this.isList, this.myList, this.myGrid, this.onRefresh});

@override
_MyAppbarState createState() => _MyAppbarState();
Expand Down Expand Up @@ -55,30 +54,43 @@ class _MyAppbarState extends State<MyAppbar> {
centerTitle: true,
elevation: 0,
),
drawer: CustomDrawer(),
drawer: MyDrawer(),
body: widget.isList ? widget.myList : widget.myGrid,
);
}
}

Widget CustomDrawer() {
return Drawer(
child: ListView(
children: <Widget>[
DrawerHeader(
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
child: Stack(children: <Widget>[
Positioned(
bottom: 12.0,
left: 16.0,
child: Text("ANIMKU - Discover Your Favourite Anime",
style: TextStyle(
color: Colors.black12,
fontSize: 20.0,
fontWeight: FontWeight.w500))),
]))
class MySecondAppBar extends StatefulWidget {
final Widget body;
final onRefresh;

const MySecondAppBar({Key key, this.body,this.onRefresh,}) : super(key: key);

@override
_MySecondAppBarState createState() => _MySecondAppBarState();
}

class _MySecondAppBarState extends State<MySecondAppBar> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: BaseColor.baseColor,
elevation: 0,
centerTitle: true,
actions: <Widget>[
IconButton(
icon: Icon(Icons.refresh),
onPressed: widget.onRefresh,
),
],
title: Text(
Dictionary.appName,
style: TextStyle(fontFamily: MyFonts.horizon, fontSize: 30),
),
),
drawer: MyDrawer(),
body:widget.body ,
);
}
}
88 changes: 88 additions & 0 deletions lib/components/my_drawer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import 'package:animku/environments/dictionary.dart';
import 'package:animku/environments/my_fonts.dart';
import 'package:animku/ui/drawerList/current_season_screen.dart';
import 'package:animku/ui/drawerList/season_later_screen.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

class MyDrawer extends StatelessWidget {
final bool selected;

const MyDrawer({Key key, this.selected}) : super(key: key);

@override
Widget build(BuildContext context) {
return SafeArea(
child: Drawer(
child: ListView(
children: <Widget>[
_header(),
_drawerItems(
leading: Icon(FontAwesomeIcons.calendarCheck),
text: Text('This Season'),
trailing: Icon(Icons.arrow_forward_ios),
onTapTabbed: (){
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context) => CurrentSeasonScreen()),
(Route<dynamic> route) => false);
}
),
_drawerItems(
leading: Icon(FontAwesomeIcons.calendarAlt),
text: Text('Season Later'),
trailing: Icon(Icons.arrow_forward_ios),
onTapTabbed: (){
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context) => SeasonLaterScreen()),
(Route<dynamic> route) => false);
}
),
_drawerItems(
leading: Icon(Icons.date_range),
text: Text('Schedule'),
trailing: Icon(Icons.arrow_forward_ios),
onTapTabbed: (){}
),
_drawerItems(
leading: Icon(FontAwesomeIcons.search),
text: Text('Search Anime'),
trailing: Icon(Icons.arrow_forward_ios),
onTapTabbed: (){}
),
],
),
),
);
}

Widget _header() {
return DrawerHeader(
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(Dictionary.tenkinokowp),
fit: BoxFit.cover
)
),
child: Stack(
children: <Widget>[
Positioned(
bottom: 12.0,
left: 16.0,
child: Text("ANIMKU",
style: TextStyle(
fontFamily: MyFonts.horizon,
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.w500))),
]));
}
Widget _drawerItems({leading,trailing,text,onTapTabbed}){
return ListTile(
leading: leading,
title: text,
trailing: trailing,
onTap: onTapTabbed,
);
}
}
20 changes: 13 additions & 7 deletions lib/components/my_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
class MyGrid extends StatefulWidget {
final List<AnimeList> animeList;
final String judul;
final Widget searchBar;

const MyGrid({Key key, this.animeList,this.judul}) : super(key: key);
const MyGrid({Key key, this.animeList,this.judul,this.searchBar}) : super(key: key);

@override
_MyGridState createState() => _MyGridState();
Expand All @@ -27,14 +28,18 @@ class _MyGridState extends State<MyGrid> {
super.initState();
MyVariable.bottomBarCtrl.addListener((){
if(MyVariable.bottomBarCtrl.offset >= MyVariable.bottomBarCtrl.position.maxScrollExtent && !MyVariable.bottomBarCtrl.position.outOfRange){
setState(() {
MyVariable.showFAB = true;
});
if(mounted){
setState(() {
MyVariable.showFAB = true;
});
}
}
if(MyVariable.bottomBarCtrl.offset <= MyVariable.bottomBarCtrl.position.minScrollExtent && !MyVariable.bottomBarCtrl.position.outOfRange){
setState(() {
MyVariable.showFAB = false;
});
if (mounted) {
setState(() {
MyVariable.showFAB = false;
});
}
}
});
}
Expand All @@ -61,6 +66,7 @@ class _MyGridState extends State<MyGrid> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SeasonTitle(judul: widget.judul,),
Container(child: widget.searchBar),
Padding(
padding: EdgeInsets.symmetric(horizontal: 15,vertical: 15),
child: GridView.builder(
Expand Down
16 changes: 10 additions & 6 deletions lib/components/my_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ class _MyListState extends State<MyList> {
super.initState();
MyVariable.bottomBarCtrl.addListener((){
if(MyVariable.bottomBarCtrl.offset >= MyVariable.bottomBarCtrl.position.maxScrollExtent && !MyVariable.bottomBarCtrl.position.outOfRange){
setState(() {
MyVariable.showFAB = true;
});
if(mounted){
setState(() {
MyVariable.showFAB = true;
});
}
}
if(MyVariable.bottomBarCtrl.offset <= MyVariable.bottomBarCtrl.position.minScrollExtent && !MyVariable.bottomBarCtrl.position.outOfRange){
setState(() {
MyVariable.showFAB = false;
});
if (mounted) {
setState(() {
MyVariable.showFAB = false;
});
}
}
});
}
Expand Down
2 changes: 2 additions & 0 deletions lib/environments/dictionary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ class Dictionary{
static String thursday = 'Thursday';
static String friday = 'Friday';
static String saturday = 'Saturday';

static String tenkinokowp = 'assets/images/tenkinokowp.png';
}
2 changes: 2 additions & 0 deletions lib/environments/end_point_path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ class EndPointPath{
static String saturday = '/schedule/saturday';
static String sunday = '/schedule/sunday';

static String seasonLater = '/season/later';

}
6 changes: 6 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import 'package:animku/bloc/current_season_bloc/winter_bloc.dart';
import 'package:animku/bloc/simple_bloc_delegate.dart';
import 'package:animku/components/bottom_navbar.dart';
import 'package:animku/repository/current_season_repo.dart';
import 'package:animku/repository/season_later_repo.dart';
import 'package:animku/ui/drawerList/current_season_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart';

import 'bloc/seasonLaterBloc/season_later_bloc.dart';

void main() {
BlocSupervisor.delegate = SimpleBlocDelegate();
runApp(MyApp());
Expand All @@ -33,6 +36,9 @@ class MyApp extends StatelessWidget {
),
BlocProvider(
create: (context) => FallBloc(CurrSeasonImp()),
),
BlocProvider(
create: (context) => SeasonLaterBloc(seasonLaterRepository: SeasonLaterImplements()),
)
],
child: MaterialApp(
Expand Down
Loading

0 comments on commit 7408b3b

Please sign in to comment.