From ce3a95c25625133bf57dff69bfc395cfd17b2e89 Mon Sep 17 00:00:00 2001 From: up2up Date: Wed, 13 Jan 2021 13:54:48 +0700 Subject: [PATCH] Cleanup code --- lib/main.dart | 2 +- .../controllers/album_detail_controller.dart | 5 +- .../controllers/artist_detail_controller.dart | 5 +- lib/src/pages/album_detail_page.dart | 5 +- lib/src/pages/artist_detail_page.dart | 5 +- lib/src/pages/entry_search_page.dart | 3 ++ lib/src/pages/home_page.dart | 1 - lib/src/pages/ranking_page.dart | 6 --- lib/src/pages/release_event_detail_page.dart | 52 +------------------ lib/src/services/http_service.dart | 3 +- lib/src/utils/app_directory.dart | 1 - lib/src/widgets/album_card.dart | 2 +- 12 files changed, 24 insertions(+), 66 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index a9201b22..00a8e130 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,7 +14,7 @@ Future main() async { runApp(VocaDBApp()); } -void initServices() async { +Future initServices() async { print('starting services ...'); final appDirectory = AppDirectory(); final httpService = HttpService(appDirectory: appDirectory); diff --git a/lib/src/controllers/album_detail_controller.dart b/lib/src/controllers/album_detail_controller.dart index fc49cf3c..5b21abf8 100644 --- a/lib/src/controllers/album_detail_controller.dart +++ b/lib/src/controllers/album_detail_controller.dart @@ -13,9 +13,12 @@ class AlbumDetailController extends GetxController { final AlbumRepository albumRepository; + final UserRepository userRepository; + final AuthService authService; - AlbumDetailController({this.albumRepository, this.authService}); + AlbumDetailController( + {this.albumRepository, this.authService, this.userRepository}); @override void onInit() { diff --git a/lib/src/controllers/artist_detail_controller.dart b/lib/src/controllers/artist_detail_controller.dart index 1fe3c6cb..8d6d96c5 100644 --- a/lib/src/controllers/artist_detail_controller.dart +++ b/lib/src/controllers/artist_detail_controller.dart @@ -13,9 +13,12 @@ class ArtistDetailController extends GetxController { final ArtistRepository artistRepository; + final UserRepository userRepository; + final AuthService authService; - ArtistDetailController({this.artistRepository, this.authService}); + ArtistDetailController( + {this.artistRepository, this.authService, this.userRepository}); @override void onInit() { diff --git a/lib/src/pages/album_detail_page.dart b/lib/src/pages/album_detail_page.dart index c7d87599..58d626b5 100644 --- a/lib/src/pages/album_detail_page.dart +++ b/lib/src/pages/album_detail_page.dart @@ -14,8 +14,11 @@ import 'package:vocadb_app/widgets.dart'; class AlbumDetailPage extends StatelessWidget { initController() { final httpService = Get.find(); + final authService = Get.find(); return AlbumDetailController( - albumRepository: AlbumRepository(httpService: httpService)); + albumRepository: AlbumRepository(httpService: httpService), + userRepository: UserRepository(httpService: httpService), + authService: authService); } @override diff --git a/lib/src/pages/artist_detail_page.dart b/lib/src/pages/artist_detail_page.dart index 475e82cd..dd307921 100644 --- a/lib/src/pages/artist_detail_page.dart +++ b/lib/src/pages/artist_detail_page.dart @@ -14,8 +14,11 @@ import 'package:vocadb_app/widgets.dart'; class ArtistDetailPage extends StatelessWidget { initController() { final httpService = Get.find(); + final authService = Get.find(); return ArtistDetailController( - artistRepository: ArtistRepository(httpService: httpService)); + artistRepository: ArtistRepository(httpService: httpService), + userRepository: UserRepository(httpService: httpService), + authService: authService); } @override diff --git a/lib/src/pages/entry_search_page.dart b/lib/src/pages/entry_search_page.dart index b1370d85..e51ec82f 100644 --- a/lib/src/pages/entry_search_page.dart +++ b/lib/src/pages/entry_search_page.dart @@ -35,6 +35,9 @@ class EntrySearchPage extends GetView { AppPages.toReleaseEventDetailPage( ReleaseEventModel.fromEntry(entryModel)); break; + + default: + print('Unsupported entry $entryModel'); } } diff --git a/lib/src/pages/home_page.dart b/lib/src/pages/home_page.dart index 98f5da33..a7dde998 100644 --- a/lib/src/pages/home_page.dart +++ b/lib/src/pages/home_page.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:vocadb_app/controllers.dart'; import 'package:vocadb_app/models.dart'; -import 'package:vocadb_app/pages.dart'; import 'package:vocadb_app/routes.dart'; import 'package:vocadb_app/widgets.dart'; diff --git a/lib/src/pages/ranking_page.dart b/lib/src/pages/ranking_page.dart index 26266c9d..8d8386e1 100644 --- a/lib/src/pages/ranking_page.dart +++ b/lib/src/pages/ranking_page.dart @@ -22,16 +22,10 @@ class _RankingPageState extends State _rankingController = Get.find(); _tabController = TabController( vsync: this, length: constRankings.length, initialIndex: 1); - _tabController.addListener(onTabChanged); } void _onTabSong(SongModel song) => AppPages.toSongDetailPage(song); - void onTabChanged() { - int currentIndex = _tabController.index; - // Provider.of(context).updateIndex(currentIndex); - } - @override void dispose() { _tabController.dispose(); diff --git a/lib/src/pages/release_event_detail_page.dart b/lib/src/pages/release_event_detail_page.dart index c82b2590..f9cd9e32 100644 --- a/lib/src/pages/release_event_detail_page.dart +++ b/lib/src/pages/release_event_detail_page.dart @@ -42,8 +42,6 @@ class ReleaseEventDetailPageView extends StatelessWidget { void _onSelectTag(TagModel tag) => AppPages.toTagDetailPage(tag); - void _onTapLikeButton() {} - void _onTapShareButton() => Share.share(controller.event().originUrl); void _onTapInfoButton() => launch(controller.event().originUrl); @@ -204,7 +202,7 @@ class ReleaseEventDetailPageView extends StatelessWidget { visible: controller.songs().length > 0, child: SongListView( scrollDirection: Axis.horizontal, - onSelect: (s) => {}, + onSelect: this._onTapSong, songs: controller.songs(), ), divider: Divider(), @@ -215,6 +213,7 @@ class ReleaseEventDetailPageView extends StatelessWidget { child: AlbumListView( scrollDirection: Axis.horizontal, albums: controller.albums(), + onSelect: this._onTapAlbum, ), divider: Divider(), ), @@ -235,50 +234,3 @@ class ReleaseEventDetailPageView extends StatelessWidget { )); } } - -class _ReleaseEventDetailButtonBar extends StatelessWidget { - final VoidCallback onTapShareButton; - - final VoidCallback onTapMapButton; - - final VoidCallback onTapInfoButton; - - const _ReleaseEventDetailButtonBar( - {this.onTapShareButton, this.onTapMapButton, this.onTapInfoButton}); - - @override - Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - child: FlatButton( - onPressed: this.onTapShareButton, - child: Column( - children: [Icon(Icons.share), Text('share'.tr)], - ), - ), - ), - Expanded( - child: FlatButton( - onPressed: this.onTapMapButton, - child: Column( - children: [Icon(Icons.place), Text('map'.tr)], - ), - ), - ), - Expanded( - child: FlatButton( - onPressed: this.onTapInfoButton, - child: Column( - children: [Icon(Icons.info), Text('info'.tr)], - ), - ), - ), - ], - ), - ); - } -} diff --git a/lib/src/services/http_service.dart b/lib/src/services/http_service.dart index 0a995a77..117d1afc 100644 --- a/lib/src/services/http_service.dart +++ b/lib/src/services/http_service.dart @@ -3,7 +3,6 @@ import 'package:dio/dio.dart'; import 'package:dio_cookie_manager/dio_cookie_manager.dart'; import 'package:dio_http_cache/dio_http_cache.dart'; import 'package:get/get.dart'; -import 'package:path_provider/path_provider.dart'; import 'package:vocadb_app/constants.dart'; import 'package:vocadb_app/exceptions.dart'; import 'package:vocadb_app/models.dart'; @@ -70,7 +69,7 @@ class HttpService extends GetxService { if (e is DioError && e.response.statusCode == 302) { List cookies = e.response.headers.map['set-cookie']; - if (cookies != null && !cookies.isEmpty) { + if (cookies != null) { return UserCookie(cookies: cookies); } } diff --git a/lib/src/utils/app_directory.dart b/lib/src/utils/app_directory.dart index 00ddc63c..0aa354f9 100644 --- a/lib/src/utils/app_directory.dart +++ b/lib/src/utils/app_directory.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:get/get.dart'; -import 'package:meta/meta.dart'; import 'package:path_provider/path_provider.dart'; class AppDirectory extends GetxService { diff --git a/lib/src/widgets/album_card.dart b/lib/src/widgets/album_card.dart index f44f914d..ff880e77 100644 --- a/lib/src/widgets/album_card.dart +++ b/lib/src/widgets/album_card.dart @@ -56,7 +56,7 @@ class AlbumCard extends StatelessWidget { Container( alignment: Alignment.centerLeft, child: Text(this.name, - style: Theme.of(context).textTheme.body1, + style: Theme.of(context).textTheme.bodyText2, maxLines: 1, overflow: TextOverflow.ellipsis)), SpaceDivider.micro(),