Skip to content

Commit

Permalink
Fix windows issue and adjust product list row count
Browse files Browse the repository at this point in the history
  • Loading branch information
hazarbelge committed Jul 29, 2022
1 parent c25b4d4 commit ddbb346
Show file tree
Hide file tree
Showing 29 changed files with 348 additions and 421 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
- name: Install dependencies
run: flutter pub get

#- name: Analyze project source
#run: dart analyze
- name: Analyze project source
run: dart analyze

- name: Check formatting
run: dart format --output=none .
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Flutter TheMovieDB Application example with GetX State, Route & Dependency Managements

Register and get Api Key from [The Movie DB Website](https://www.themoviedb.org)
Register and get an "API KEY" from [The Movie DB Website](https://www.themoviedb.org)

After that in url.dart, change `'YOUR.API_KEY'` with your key.

Available in all your devices.
Available for all platforms and devices.

**Mobile:**

Expand Down
2 changes: 2 additions & 0 deletions lib/core/utils/global_variables.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class _App {

class _Images {
String get appIconPath => "assets/icons/app_icon.svg";

String get appIconPngPath => "assets/icons/app_icon.png";

String get appLogoPath => "assets/icons/app_logo.png";
}
1 change: 1 addition & 0 deletions lib/core/utils/storage_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class StorageUtil {
final GetStorage _storage;

static StorageUtil? _instance;

static Future<void> init() async {
await GetStorage.init();

Expand Down
2 changes: 2 additions & 0 deletions lib/features/detail/repository/detail_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:get/get.dart';

abstract class IDetailProvider {
Future<Response<dynamic>> rateMovie(String path, Map<String, dynamic> body);

Future<Response<dynamic>> rateTvSeries(String path, Map<String, dynamic> body);
}

Expand All @@ -18,6 +19,7 @@ class DetailProvider extends BaseProvider implements IDetailProvider {

abstract class IDetailRepository {
Future<dynamic> rateMovie(int movieId, Map<String, dynamic> body);

Future<dynamic> rateTvSeries(int tvSeriesId, Map<String, dynamic> body);
}

Expand Down
6 changes: 4 additions & 2 deletions lib/features/home_movie/controller/now_playing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class NowPlayingMoviesController extends BaseRepositoryController<HomeMovieRepos
final HomeMovieRepository homeMovieRepository;
final ScrollController scrollController = ScrollController();
final RxBool isLoading = false.obs;
final RxInt page = 1.obs;

void pagination() {
if (scrollController.position.extentAfter < 500 && state != null && state!.totalPages != 0 && state!.totalPages != state!.page && !isLoading.value) {
Expand All @@ -26,11 +27,11 @@ class NowPlayingMoviesController extends BaseRepositoryController<HomeMovieRepos

final MovieWrapper? movieWrapper = await repository.getNowPlayingMovie(
query: <String, dynamic>{
"page": state!.page! + 1,
"page": page.value + 1,
},
);
state!.results!.addAll(movieWrapper!.results!);
state!.page = movieWrapper.page;
page.value = movieWrapper.page!;
update();

await CustomProgressIndicator.closeLoadingOverlay();
Expand All @@ -44,6 +45,7 @@ class NowPlayingMoviesController extends BaseRepositoryController<HomeMovieRepos
"page": 1,
},
);
page.value = movieWrapper!.page!;
await CustomProgressIndicator.closeLoadingOverlay();
return movieWrapper;
}
Expand Down
6 changes: 4 additions & 2 deletions lib/features/home_movie/controller/popular.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class PopularMoviesController extends BaseRepositoryController<HomeMovieReposito
final HomeMovieRepository homeMovieRepository;
final ScrollController scrollController = ScrollController();
final RxBool isLoading = false.obs;
final RxInt page = 1.obs;

void pagination() {
if (scrollController.position.extentAfter < 500 && state != null && state!.totalPages != 0 && state!.totalPages != state!.page && !isLoading.value) {
Expand All @@ -26,11 +27,11 @@ class PopularMoviesController extends BaseRepositoryController<HomeMovieReposito

final MovieWrapper? movieWrapper = await repository.getPopularMovie(
query: <String, dynamic>{
"page": state!.page! + 1,
"page": page.value + 1,
},
);
state!.results!.addAll(movieWrapper!.results!);
state!.page = movieWrapper.page;
page.value = movieWrapper.page!;
update();

await CustomProgressIndicator.closeLoadingOverlay();
Expand All @@ -44,6 +45,7 @@ class PopularMoviesController extends BaseRepositoryController<HomeMovieReposito
"page": 1,
},
);
page.value = movieWrapper!.page!;
await CustomProgressIndicator.closeLoadingOverlay();
return movieWrapper;
}
Expand Down
8 changes: 5 additions & 3 deletions lib/features/home_movie/controller/top_rated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TopRatedMoviesController extends BaseRepositoryController<HomeMovieReposit
final HomeMovieRepository homeMovieRepository;
final ScrollController scrollController = ScrollController();
final RxBool isLoading = false.obs;
final RxInt page = 1.obs;

void pagination() {
if (scrollController.position.extentAfter < 500 && state != null && state!.totalPages != 0 && state!.totalPages != state!.page && !isLoading.value) {
Expand All @@ -26,11 +27,11 @@ class TopRatedMoviesController extends BaseRepositoryController<HomeMovieReposit

final MovieWrapper? movieWrapper = await repository.getTopRatedMovie(
query: <String, dynamic>{
"page": state!.page! + 1,
"page": page.value + 1,
},
);
state!.results!.addAll(movieWrapper!.results!);
state!.page = movieWrapper.page;
page.value = movieWrapper.page!;
update();

await CustomProgressIndicator.closeLoadingOverlay();
Expand All @@ -39,11 +40,12 @@ class TopRatedMoviesController extends BaseRepositoryController<HomeMovieReposit

Future<MovieWrapper?> _getInitialMovies() async {
CustomProgressIndicator.openLoadingDialog();
final MovieWrapper? movieWrapper = await repository.getTopRatedMovie(
final MovieWrapper? movieWrapper = await repository.getNowPlayingMovie(
query: <String, dynamic>{
"page": 1,
},
);
page.value = movieWrapper!.page!;
await CustomProgressIndicator.closeLoadingOverlay();
return movieWrapper;
}
Expand Down
6 changes: 4 additions & 2 deletions lib/features/home_movie/controller/upcoming.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class UpcomingMoviesController extends BaseRepositoryController<HomeMovieReposit
final HomeMovieRepository homeMovieRepository;
final ScrollController scrollController = ScrollController();
final RxBool isLoading = false.obs;
final RxInt page = 1.obs;

void pagination() {
if (scrollController.position.extentAfter < 500 && state != null && state!.totalPages != 0 && state!.totalPages != state!.page && !isLoading.value) {
Expand All @@ -26,11 +27,11 @@ class UpcomingMoviesController extends BaseRepositoryController<HomeMovieReposit

final MovieWrapper? movieWrapper = await repository.getUpcomingMovie(
query: <String, dynamic>{
"page": state!.page! + 1,
"page": page.value + 1,
},
);
state!.results!.addAll(movieWrapper!.results!);
state!.page = movieWrapper.page;
page.value = movieWrapper.page!;
update();

await CustomProgressIndicator.closeLoadingOverlay();
Expand All @@ -44,6 +45,7 @@ class UpcomingMoviesController extends BaseRepositoryController<HomeMovieReposit
"page": 1,
},
);
page.value = movieWrapper!.page!;
await CustomProgressIndicator.closeLoadingOverlay();
return movieWrapper;
}
Expand Down
9 changes: 9 additions & 0 deletions lib/features/home_movie/repository/home_movie_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import 'package:get/get.dart';

abstract class IHomeMovieProvider {
Future<Response<MovieWrapper>> getNowPlayingMovie({required String path, Map<String, dynamic>? query});

Future<Response<MovieWrapper>> getPopularMovie({required String path, Map<String, dynamic>? query});

Future<Response<MovieWrapper>> getTopRatedMovie({required String path, Map<String, dynamic>? query});

Future<Response<MovieWrapper>> getUpcomingMovie({required String path, Map<String, dynamic>? query});
}

Expand All @@ -20,18 +23,24 @@ class HomeMovieProvider extends BaseProvider implements IHomeMovieProvider {

@override
Future<Response<MovieWrapper>> getNowPlayingMovie({required String path, Map<String, dynamic>? query}) => get(path, query: query);

@override
Future<Response<MovieWrapper>> getPopularMovie({required String path, Map<String, dynamic>? query}) => get(path, query: query);

@override
Future<Response<MovieWrapper>> getTopRatedMovie({required String path, Map<String, dynamic>? query}) => get(path, query: query);

@override
Future<Response<MovieWrapper>> getUpcomingMovie({required String path, Map<String, dynamic>? query}) => get(path, query: query);
}

abstract class IHomeMovieRepository {
Future<MovieWrapper?> getNowPlayingMovie({Map<String, dynamic>? query});

Future<MovieWrapper?> getPopularMovie({Map<String, dynamic>? query});

Future<MovieWrapper?> getTopRatedMovie({Map<String, dynamic>? query});

Future<MovieWrapper?> getUpcomingMovie({Map<String, dynamic>? query});
}

Expand Down
148 changes: 76 additions & 72 deletions lib/features/home_movie/screen/home_movie_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,50 +112,52 @@ class NavigationRow extends GetView<HomeMovieScreenController> {

@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
InkWell(
child: Text(
'movies.now_playing.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 0 ? Colors.white : Colors.orange,
return Obx(
() => Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
InkWell(
child: Text(
'movies.now_playing.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 0 ? Colors.white : Colors.orange,
),
),
onTap: () => controller.currentIndex.value != 0 ? controller.currentIndex.value = 0 : null,
),
onTap: () => controller.currentIndex.value != 0 ? controller.currentIndex.value = 0 : null,
),
InkWell(
child: Text(
'movies.popular.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 1 ? Colors.white : Colors.orange,
InkWell(
child: Text(
'movies.popular.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 1 ? Colors.white : Colors.orange,
),
),
onTap: () => controller.currentIndex.value != 1 ? controller.currentIndex.value = 1 : null,
),
onTap: () => controller.currentIndex.value != 1 ? controller.currentIndex.value = 1 : null,
),
InkWell(
child: Text(
'movies.top_rated.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 2 ? Colors.white : Colors.orange,
InkWell(
child: Text(
'movies.top_rated.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 2 ? Colors.white : Colors.orange,
),
),
onTap: () => controller.currentIndex.value != 2 ? controller.currentIndex.value = 2 : null,
),
onTap: () => controller.currentIndex.value != 2 ? controller.currentIndex.value = 2 : null,
),
InkWell(
child: Text(
'movies.upcoming.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 3 ? Colors.white : Colors.orange,
InkWell(
child: Text(
'movies.upcoming.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 3 ? Colors.white : Colors.orange,
),
),
onTap: () => controller.currentIndex.value != 3 ? controller.currentIndex.value = 3 : null,
),
onTap: () => controller.currentIndex.value != 3 ? controller.currentIndex.value = 3 : null,
),
],
],
),
);
}
}
Expand All @@ -165,50 +167,52 @@ class NavigationColumn extends GetView<HomeMovieScreenController> {

@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
InkWell(
child: Text(
'movies.now_playing.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 0 ? Colors.white : Colors.orange,
return Obx(
() => Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
InkWell(
child: Text(
'movies.now_playing.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 0 ? Colors.white : Colors.orange,
),
),
onTap: () => controller.currentIndex.value != 0 ? controller.currentIndex.value = 0 : null,
),
onTap: () => controller.currentIndex.value != 0 ? controller.currentIndex.value = 0 : null,
),
InkWell(
child: Text(
'movies.popular.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 1 ? Colors.white : Colors.orange,
InkWell(
child: Text(
'movies.popular.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 1 ? Colors.white : Colors.orange,
),
),
onTap: () => controller.currentIndex.value != 1 ? controller.currentIndex.value = 1 : null,
),
onTap: () => controller.currentIndex.value != 1 ? controller.currentIndex.value = 1 : null,
),
InkWell(
child: Text(
'movies.top_rated.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 2 ? Colors.white : Colors.orange,
InkWell(
child: Text(
'movies.top_rated.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 2 ? Colors.white : Colors.orange,
),
),
onTap: () => controller.currentIndex.value != 2 ? controller.currentIndex.value = 2 : null,
),
onTap: () => controller.currentIndex.value != 2 ? controller.currentIndex.value = 2 : null,
),
InkWell(
child: Text(
'movies.upcoming.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 3 ? Colors.white : Colors.orange,
InkWell(
child: Text(
'movies.upcoming.icon'.tr,
style: TextStyle(
fontSize: 16,
color: controller.currentIndex.value != 3 ? Colors.white : Colors.orange,
),
),
onTap: () => controller.currentIndex.value != 3 ? controller.currentIndex.value = 3 : null,
),
onTap: () => controller.currentIndex.value != 3 ? controller.currentIndex.value = 3 : null,
),
],
],
),
);
}
}
Loading

0 comments on commit ddbb346

Please sign in to comment.