Skip to content

Commit 1dcc04c

Browse files
committed
update homepage
1 parent 2017830 commit 1dcc04c

File tree

36 files changed

+1566
-299
lines changed

36 files changed

+1566
-299
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A Flutter movie app build with Fish-Redux and TMDB api.
44
## ToDos
5-
- [ ] Redesign UI
5+
- [ ] redesign UI
66
- [ ] customize theme
77
- [ ] account detail
88
- [x] localization
@@ -23,4 +23,7 @@ A Flutter movie app build with Fish-Redux and TMDB api.
2323
<img src="https://github.com/o1298098/Flutter-Movie/blob/master/srceenshot/ios15.png" width="150"><img src="https://github.com/o1298098/Flutter-Movie/blob/master/srceenshot/ios16.png" width="150">
2424
### other page
2525
<img src="https://github.com/o1298098/Flutter-Movie/blob/master/srceenshot/ios7.png" width="150"><img src="https://github.com/o1298098/Flutter-Movie/blob/master/srceenshot/ios8.png" width="150"><img src="https://github.com/o1298098/Flutter-Movie/blob/master/srceenshot/ios12.png" width="150"><img src="https://github.com/o1298098/Flutter-Movie/blob/master/srceenshot/ios13.png" width="150">
26-
<img src="https://github.com/o1298098/Flutter-Movie/blob/master/srceenshot/ios17.png" width="150">
26+
<img src="https://github.com/o1298098/Flutter-Movie/blob/master/srceenshot/ios17.png" width="150">
27+
28+
## Other
29+
homepage based on https://dribbble.com/shots/6070474--Movie
2.88 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

android/local.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sdk.dir=/Users/hezhibin/Library/Android/sdk
22
flutter.sdk=/Users/hezhibin/flutter
3-
flutter.buildMode=release
3+
flutter.buildMode=debug
44
flutter.versionName=1.0.0
55
flutter.versionCode=1

lib/actions/apihelper.dart

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:movie/models/certification.dart';
99
import 'package:movie/models/combinedcredits.dart';
1010
import 'package:movie/models/creditsmodel.dart';
1111
import 'package:movie/models/enums/media_type.dart';
12+
import 'package:movie/models/enums/time_window.dart';
1213
import 'package:movie/models/episodemodel.dart';
1314
import 'package:movie/models/imagemodel.dart';
1415
import 'package:movie/models/keyword.dart';
@@ -442,6 +443,22 @@ class ApiHelper {
442443
return certificationModel;
443444
}
444445

446+
static Future<VideoListResult> getLastMovies() async {
447+
VideoListResult model;
448+
String param = "/movie/latest?api_key=$_apikey&language=$language";
449+
var r = await httpGet(param);
450+
if (r != null) model = VideoListResult.fromJson(r);
451+
return model;
452+
}
453+
454+
static Future<VideoListResult> getLastTVShows() async {
455+
VideoListResult model;
456+
String param = "/tv/latest?api_key=$_apikey&language=$language";
457+
var r = await httpGet(param);
458+
if (r != null) model = VideoListResult.fromJson(r);
459+
return model;
460+
}
461+
445462
static Future<VideoListModel> getPopularMovies({int page = 1}) async {
446463
VideoListModel model;
447464
String param =
@@ -524,7 +541,7 @@ class ApiHelper {
524541
}
525542

526543
///Get a list of upcoming movies in theatres. This is a release type query that looks for all movies that have a release type of 2 or 3 within the specified date range.You can optionally specify a region prameter which will narrow the search to only look for theatrical release dates within the specified country.
527-
static Future<VideoListModel> getMoviceUpComing({int page = 1}) async {
544+
static Future<VideoListModel> getMovieUpComing({int page = 1}) async {
528545
VideoListModel model;
529546
String param =
530547
'/movie/upcoming?api_key=$_apikey&language=$language&page=$page&region=$region';
@@ -533,6 +550,17 @@ class ApiHelper {
533550
return model;
534551
}
535552

553+
///Get the daily or weekly trending items. The daily trending list tracks items over the period of a day while items have a 24 hour half life. The weekly list tracks items over a 7 day period, with a 7 day half life.
554+
static Future<SearchResultModel> getTrending(MediaType type, TimeWindow time,
555+
{int page = 1}) async {
556+
SearchResultModel model;
557+
String param =
558+
'/trending/${type.toString().split('.').last}/${time.toString().split('.').last}?api_key=$_apikey&language=$language&page=$page';
559+
var r = await httpGet(param);
560+
if (r != null) model = SearchResultModel(r);
561+
return model;
562+
}
563+
536564
///Get a list of movies in theatres. This is a release type query that looks for all movies that have a release type of 2 or 3 within the specified date range.You can optionally specify a region prameter which will narrow the search to only look for theatrical release dates within the specified country.
537565
static Future<VideoListModel> getNowPlayingMovie({int page = 1}) async {
538566
VideoListModel model;

lib/customwidgets/backdrop.dart

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:movie/actions/Adapt.dart';
3+
4+
class BackDrop extends StatefulWidget {
5+
final Widget backChild;
6+
final Widget frontChild;
7+
final double height;
8+
BackDrop({this.backChild, this.frontChild, this.height});
9+
@override
10+
BackDropState createState() => BackDropState();
11+
}
12+
13+
class BackDropState extends State<BackDrop> with TickerProviderStateMixin {
14+
double dropHeight;
15+
double _startHeight = 0;
16+
double _stratY;
17+
double _positionY;
18+
double _lastDeffY = 0;
19+
double _top = 0;
20+
bool isrun;
21+
AnimationController _animationController;
22+
23+
Tween<double> topTween;
24+
GlobalKey key;
25+
@override
26+
void initState() {
27+
key = GlobalKey();
28+
isrun = false;
29+
topTween = Tween<double>(begin: widget.height, end: 0.0);
30+
_animationController =
31+
AnimationController(vsync: this, duration: Duration(milliseconds: 300));
32+
dropHeight = widget.height ?? 0.0;
33+
_startHeight = widget.height ?? 0.0;
34+
super.initState();
35+
}
36+
37+
@override
38+
void dispose() {
39+
_animationController.dispose();
40+
super.dispose();
41+
}
42+
43+
@override
44+
Widget build(BuildContext context) {
45+
return Stack(
46+
children: <Widget>[
47+
Container(
48+
key: key,
49+
child: widget.backChild,
50+
),
51+
AnimatedBuilder(
52+
animation: _animationController,
53+
builder: (ctx, child) {
54+
return Positioned(
55+
left: 0.0,
56+
right: 0.0,
57+
bottom: 0.0,
58+
top: topTween
59+
.animate(CurvedAnimation(
60+
parent: _animationController, curve: Curves.ease))
61+
.value,
62+
child: Column(children: <Widget>[
63+
GestureDetector(
64+
/*onVerticalDragUpdate: (dragUpdateDetails) {
65+
if (_positionY == null) {
66+
RenderBox box = key.currentContext.findRenderObject();
67+
Offset position = box.localToGlobal(Offset.zero);
68+
_positionY = position.dy;
69+
}
70+
_lastDeffY =
71+
_stratY - dragUpdateDetails.globalPosition.dy;
72+
print(dragUpdateDetails.globalPosition);
73+
var _movie =
74+
dragUpdateDetails.globalPosition.dy - _positionY;
75+
if (_movie > 0.0 && _movie <= _startHeight) {
76+
_top = _movie;
77+
} else if (_top < 0)
78+
_top = 0.0;
79+
else if (_top > _startHeight) _top = _startHeight;
80+
setState(() {
81+
dropHeight = _top;
82+
});
83+
},
84+
onVerticalDragStart: (d) {
85+
_lastDeffY = 0;
86+
_stratY = d.globalPosition.dy;
87+
},
88+
onVerticalDragEnd: (d) async {
89+
if (_lastDeffY == 0) return;
90+
if (_lastDeffY > 0) {
91+
setState(() {
92+
_animationController.value =
93+
(_startHeight - dropHeight) / _startHeight;
94+
isrun = true;
95+
});
96+
97+
await _animationController.forward().then((f) {
98+
setState(() {
99+
dropHeight = 0.0;
100+
isrun = false;
101+
});
102+
});
103+
} else if (_lastDeffY < 0) {
104+
setState(() {
105+
_animationController.value =
106+
(_startHeight - dropHeight) / _startHeight;
107+
isrun = true;
108+
});
109+
110+
await _animationController.reverse().then((f) {
111+
setState(() {
112+
dropHeight = _startHeight;
113+
isrun = false;
114+
});
115+
});
116+
}
117+
},*/
118+
onTap: () {
119+
if (_animationController.value == 0.0)
120+
_animationController.forward();
121+
else
122+
_animationController.reverse();
123+
},
124+
child: Container(
125+
alignment: Alignment.center,
126+
decoration: BoxDecoration(
127+
color: Colors.white,
128+
border: Border.all(width: 0.0, color: Colors.white),
129+
borderRadius: BorderRadius.only(
130+
topLeft: Radius.circular(Adapt.px(40)),
131+
topRight: Radius.circular(Adapt.px(40)))),
132+
width: Adapt.screenW(),
133+
height: Adapt.px(80),
134+
child: Container(
135+
width: Adapt.px(80),
136+
height: Adapt.px(6),
137+
color: Colors.grey[300])),
138+
),
139+
Expanded(
140+
child: widget.frontChild,
141+
)
142+
]));
143+
},
144+
)
145+
],
146+
);
147+
}
148+
}

lib/customwidgets/searchbar_delegate.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class SearchBarDelegate extends SearchDelegate<SearchResult> {
3838
}
3939

4040
Future<SearchResultModel> _getData() {
41-
if (query != '')
41+
if (query != '' && query != null)
4242
return ApiHelper.searchMulit(query);
4343
else
4444
return null;
@@ -83,7 +83,7 @@ class SearchBarDelegate extends SearchDelegate<SearchResult> {
8383
if (snapshot.hasError) return Text('Error: ${snapshot.error}');
8484
return _ResultList(
8585
query: query,
86-
results: snapshot.data?.results??[],
86+
results: snapshot.data?.results ?? [],
8787
);
8888
}
8989
return null;
@@ -336,7 +336,8 @@ Widget _buildResultCell(SearchResult s, BuildContext ctx) {
336336
s.overview ?? 'no description',
337337
overflow: TextOverflow.ellipsis,
338338
maxLines: 7,
339-
style: TextStyle(fontSize: Adapt.px(26),wordSpacing: 1.2),
339+
style: TextStyle(
340+
fontSize: Adapt.px(26), wordSpacing: 1.2),
340341
),
341342
)
342343
: Container(

lib/models/enums/media_type.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
enum MediaType{
1+
enum MediaType {
22
movie,
33
tv,
4-
}
4+
all,
5+
person,
6+
}

lib/models/enums/time_window.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enum TimeWindow { day, week }

lib/views/account_page/view.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Widget buildView(
1414
AccountPageState state, Dispatch dispatch, ViewService viewService) {
1515
SystemChrome.setSystemUIOverlayStyle(
1616
SystemUiOverlayStyle.dark.copyWith(statusBarBrightness: Brightness.dark));
17-
17+
final double _cellwidth = (Adapt.screenW() - Adapt.px(90)) / 2;
1818
Widget _buildTapCell(String name, double begin, double end, void ontap()) {
1919
return SlideTransition(
2020
position: Tween<Offset>(begin: Offset(-1, 0), end: Offset.zero)
@@ -63,6 +63,7 @@ Widget buildView(
6363
'https://en.gravatar.com/userimage/159547793/1e81c1798f922e37511065a9c301fed9.jpg?size=200',
6464
errorListener: () {}),
6565
fit: BoxFit.cover),
66+
border: Border.all(width: Adapt.px(8), color: Colors.white),
6667
color: Colors.grey,
6768
borderRadius: BorderRadius.circular(Adapt.px(90))),
6869
),
@@ -79,6 +80,7 @@ Widget buildView(
7980

8081
return Container(
8182
child: Column(
83+
mainAxisAlignment: MainAxisAlignment.start,
8284
children: <Widget>[
8385
ClipPath(
8486
clipper: CustomCliperPath(
@@ -88,24 +90,22 @@ Widget buildView(
8890
child: Stack(
8991
children: <Widget>[
9092
Container(
91-
width: Adapt.screenW(),
92-
decoration: BoxDecoration(
93-
color: Colors.black,
94-
image: DecorationImage(
95-
colorFilter:
96-
ColorFilter.mode(Colors.black, BlendMode.color),
97-
image: CachedNetworkImageProvider(
98-
'https://image.tmdb.org/t/p/w500_and_h282_face/9xzZBZ5VhIIhyKDKK3t89ggx7cS.jpg'),
99-
fit: BoxFit.cover,
93+
width: Adapt.screenW(),
94+
decoration: BoxDecoration(
95+
color: Colors.black,
96+
image: DecorationImage(
97+
colorFilter:
98+
ColorFilter.mode(Colors.black, BlendMode.color),
99+
image: CachedNetworkImageProvider(
100+
'https://image.tmdb.org/t/p/w500_and_h282_face/9xzZBZ5VhIIhyKDKK3t89ggx7cS.jpg'),
101+
fit: BoxFit.cover,
102+
),
100103
),
101-
),
102-
height: Adapt.px(450),
103-
),
104-
Container(
105-
height: Adapt.px(450),
106-
color: Color.fromRGBO(43, 58, 66, 0.9),
107-
),
108-
_buildHeader(),
104+
height: Adapt.px(450),
105+
child: Container(
106+
color: Color.fromRGBO(43, 58, 66, 0.9),
107+
child: _buildHeader(),
108+
)),
109109
SafeArea(
110110
child: Container(
111111
margin: EdgeInsets.only(right: Adapt.px(20)),

lib/views/coming_page/effect.dart

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Effect<ComingPageState> buildEffect() {
99
return combineEffects(<Object, Effect<ComingPageState>>{
1010
ComingPageAction.action: _onAction,
1111
Lifecycle.initState: _onInit,
12-
Lifecycle.dispose:_onDispose
12+
Lifecycle.dispose: _onDispose
1313
});
1414
}
1515

@@ -24,17 +24,17 @@ Future _onInit(Action action, Context<ComingPageState> ctx) async {
2424
await _onLoadMore(action, ctx);
2525
}
2626
});
27-
ctx.state.tvController = new ScrollController()
27+
ctx.state.tvController = new ScrollController()
2828
..addListener(() async {
2929
bool isBottom = ctx.state.tvController.position.pixels ==
3030
ctx.state.tvController.position.maxScrollExtent;
3131
if (isBottom) {
3232
await _onLoadMore(action, ctx);
3333
}
3434
});
35-
var q = await ApiHelper.getMoviceUpComing();
35+
var q = await ApiHelper.getMovieUpComing();
3636
if (q != null) ctx.dispatch(ComingPageActionCreator.onInitMoviesComing(q));
37-
var t=await ApiHelper.getTVOnTheAir();
37+
var t = await ApiHelper.getTVOnTheAir();
3838
if (t != null) ctx.dispatch(ComingPageActionCreator.onInitTVComing(t));
3939
}
4040

@@ -43,15 +43,14 @@ void _onDispose(Action action, Context<ComingPageState> ctx) {
4343
ctx.state.movieController.dispose();
4444
}
4545

46-
Future _onLoadMore(Action action, Context<ComingPageState> ctx) async{
46+
Future _onLoadMore(Action action, Context<ComingPageState> ctx) async {
4747
VideoListModel q;
48-
if(ctx.state.showmovie){
49-
if(ctx.state.moviecoming.page==ctx.state.moviecoming.total_pages)return;
50-
q = await ApiHelper.getMoviceUpComing(page:ctx.state.moviecoming.page+1);
51-
}
52-
else{
53-
if(ctx.state.tvcoming.page==ctx.state.tvcoming.total_pages)return;
54-
q = await ApiHelper.getTVOnTheAir(page:ctx.state.tvcoming.page+1);
48+
if (ctx.state.showmovie) {
49+
if (ctx.state.moviecoming.page == ctx.state.moviecoming.total_pages) return;
50+
q = await ApiHelper.getMovieUpComing(page: ctx.state.moviecoming.page + 1);
51+
} else {
52+
if (ctx.state.tvcoming.page == ctx.state.tvcoming.total_pages) return;
53+
q = await ApiHelper.getTVOnTheAir(page: ctx.state.tvcoming.page + 1);
5554
}
5655
if (q != null) ctx.dispatch(ComingPageActionCreator.onLoadMore(q));
5756
}

0 commit comments

Comments
 (0)