Skip to content

Commit

Permalink
Merge movies and tv series' widgets.
Browse files Browse the repository at this point in the history
  • Loading branch information
hazarbelge committed Sep 5, 2021
1 parent 383beef commit 622d46d
Show file tree
Hide file tree
Showing 20 changed files with 408 additions and 1,442 deletions.
6 changes: 3 additions & 3 deletions lib/routes/app_pages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ class AppPages {
GetPage<HomeMovieScreen>(
name: AppRoutes.HOME_MOVIE,
page: () => const HomeMovieScreen(),
transition: Transition.cupertino,
transition: Transition.fadeIn,
binding: HomeMovieBinding(),
),
GetPage<HomeTvScreen>(
name: AppRoutes.HOME_TV,
page: () => const HomeTvScreen(),
transition: Transition.cupertino,
transition: Transition.fadeIn,
binding: HomeTvBinding(),
),
GetPage<DetailPage>(
name: AppRoutes.DETAIL,
page: () => const DetailPage(),
transition: Transition.cupertino,
transition: Transition.fadeIn,
binding: DetailPageBinding(),
),
];
Expand Down
152 changes: 10 additions & 142 deletions lib/ui/tabs/home_movie/now_playing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:get/get.dart';

import '../../../controllers/index.dart';
import '../../../models/index.dart';
import '../../../routes/index.dart';
import '../../../ui/widgets/index.dart';

class NowPlayingMoviesTab extends GetView<NowPlayingMoviesController> {
Expand All @@ -16,155 +15,24 @@ class NowPlayingMoviesTab extends GetView<NowPlayingMoviesController> {
return RefreshIndicator(
onRefresh: () => refreshPage(),
child: SizedBox(
height: Get.context?.height ?? Get.height,
height: double.infinity,
width: double.infinity,
child: Center(
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
controller.obx(
(MovieWrapper? movieWrapper) {
return movieWrapper != null
? LayoutBuilder(
builder: (BuildContext context, BoxConstraints boxConstraints) {
if (boxConstraints.maxWidth >= 1300) {
return GridView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 60,
childAspectRatio: 1.75,
),
itemCount: movieWrapper.results?.length ?? 0,
itemBuilder: (BuildContext context, int index) {
return CardListMovies(
image: 'https://image.tmdb.org/t/p/w185${movieWrapper.results?[index].posterPath}',
title: movieWrapper.results?[index].title ?? "",
vote: movieWrapper.results?[index].voteAverage ?? "",
releaseDate: movieWrapper.results?[index].releaseDate ?? "",
overview: movieWrapper.results?[index].overview ?? "",
genre: movieWrapper.results?[index].genreIds != null ? movieWrapper.results![index].genreIds!.take(3).map(createGenreContainer).toList() : <Widget>[],
onTap: () {
Get.toNamed(
AppRoutes.DETAIL,
arguments: <String, dynamic>{
'movie': movieWrapper.results?[index],
'isMovie': true,
},
);
},
);
},
);
} else if (boxConstraints.maxWidth >= 800) {
return GridView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
childAspectRatio: 1.75,
),
itemCount: movieWrapper.results?.length ?? 0,
itemBuilder: (BuildContext context, int index) {
return CardListMovies(
image: 'https://image.tmdb.org/t/p/w185${movieWrapper.results?[index].posterPath}',
title: movieWrapper.results?[index].title ?? "",
vote: movieWrapper.results?[index].voteAverage ?? "",
releaseDate: movieWrapper.results?[index].releaseDate ?? "",
overview: movieWrapper.results?[index].overview ?? "",
genre: movieWrapper.results?[index].genreIds != null ? movieWrapper.results![index].genreIds!.take(3).map(createGenreContainer).toList() : <Widget>[],
onTap: () {
Get.toNamed(
AppRoutes.DETAIL,
arguments: <String, dynamic>{
'movie': movieWrapper.results?[index],
'isMovie': true,
},
);
},
);
},
);
} else if (boxConstraints.maxWidth <= 350) {
return GridView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
crossAxisSpacing: 10,
childAspectRatio: 2,
),
itemCount: movieWrapper.results?.length ?? 0,
itemBuilder: (BuildContext context, int index) {
return InkWell(
child: SizedBox(
child: Row(
children: <Widget>[
Image.network(
'https://image.tmdb.org/t/p/w185${movieWrapper.results?[index].posterPath}',
),
const SizedBox(width: 10),
Center(
child: SizedBox(
width: boxConstraints.maxWidth / 2,
child: Text(
movieWrapper.results?[index].title ?? "",
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 11,
fontWeight: FontWeight.w300,
),
),
),
),
],
),
),
onTap: () {
Get.toNamed(
AppRoutes.DETAIL,
arguments: <String, dynamic>{
'movie': movieWrapper.results?[index],
'isMovie': true,
},
);
},
);
},
);
} else {
return ListView.builder(
physics: const NeverScrollableScrollPhysics(),
padding: EdgeInsets.zero,
shrinkWrap: true,
primary: false,
itemCount: movieWrapper.results?.length,
itemBuilder: (BuildContext context, int index) => CardListMovies(
image: 'https://image.tmdb.org/t/p/w185${movieWrapper.results?[index].posterPath}',
title: movieWrapper.results?[index].title ?? "",
vote: movieWrapper.results?[index].voteAverage ?? "",
releaseDate: movieWrapper.results?[index].releaseDate ?? "",
overview: movieWrapper.results?[index].overview ?? "",
genre: movieWrapper.results?[index].genreIds != null ? movieWrapper.results![index].genreIds!.take(3).map(createGenreContainer).toList() : <Widget>[],
onTap: () {
Get.toNamed(
AppRoutes.DETAIL,
arguments: <String, dynamic>{
'movie': movieWrapper.results?[index],
'isMovie': true,
},
);
},
),
);
}
},
)
: const CircularProgressIndicator();
if (movieWrapper != null) {
return ProductList(
productList: movieWrapper.results,
isMovie: true,
);
} else {
return const CircularProgressIndicator();
}
},
),
],
Expand Down
Loading

0 comments on commit 622d46d

Please sign in to comment.