Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
joaojsrbr committed May 9, 2022
1 parent 86fd9f8 commit a2af567
Show file tree
Hide file tree
Showing 14 changed files with 1,010 additions and 319 deletions.
9 changes: 8 additions & 1 deletion lib/app/modules/browse/controllers/browse_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BrowseController extends GetxController
int get tabIndex => _tabIndex.value;

final TextEditingController textEditingController = TextEditingController();

late ScrollController scrollController;
final RxBool _isSearching = false.obs;
bool get isSearching => _isSearching.value;
set isSearching(bool value) => _isSearching.value = value;
Expand Down Expand Up @@ -87,7 +87,14 @@ class BrowseController extends GetxController
void onInit() {
tabController = TabController(length: 2, vsync: this, initialIndex: 0);
tabController.addListener(() => _tabIndex.value = tabController.index);
scrollController = ScrollController()..addListener(() => update());

super.onInit();
}

@override
void onClose() {
scrollController.dispose();
super.onClose();
}
}
84 changes: 64 additions & 20 deletions lib/app/modules/browse/views/browse_view.dart
Original file line number Diff line number Diff line change
@@ -1,40 +1,84 @@
import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:tachidesk_sorayomi/app/modules/browse/widgets/browse_appbar_actions.dart';
import 'package:tachidesk_sorayomi/app/modules/home/controllers/home_controller.dart';

import '../../../../generated/locales.g.dart';
import '../../extensions/views/extensions_view.dart';
import '../../home/views/home_view.dart';
import '../../sources/views/sources_view.dart';
import '../controllers/browse_controller.dart';

class BrowseView extends GetView<BrowseController> {
@override
Widget build(BuildContext context) {
final _ = Get.find<HomeController>();
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
appBar: TabBar(
physics: BouncingScrollPhysics(),
controller: controller.tabController,
padding: EdgeInsets.all(8),
isScrollable: context.width > 700 ? true : false,
labelColor: context.theme.indicatorColor,
unselectedLabelColor: context.textTheme.bodyText1!.color,
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(16),
color: context.theme.indicatorColor.withOpacity(.3),
body: NestedScrollView(
headerSliverBuilder: (context, innerBoxIsScrolled) => [
SliverAppBar(
toolbarHeight: 70,
pinned: true,
floating: true,
snap: true,
// stretch: true,
actions: [
Obx(() =>
_.selectedIndex == 2 ? BrowseAppBarActions() : SizedBox())
],
title: Text(navigationBarTitles[2].tr),
bottom: TabBar(
physics: BouncingScrollPhysics(),
controller: controller.tabController,
isScrollable: context.width > 700 ? true : false,
labelColor: context.theme.indicatorColor,
unselectedLabelColor: context.textTheme.bodyText1!.color,
indicatorSize: TabBarIndicatorSize.label,
indicatorColor: Theme.of(context).colorScheme.primary,
tabs: [
Tab(text: LocaleKeys.screenTitle_sources.tr),
Tab(text: LocaleKeys.screenTitle_extensions.tr),
],
),
),
tabs: [
Tab(text: LocaleKeys.screenTitle_sources.tr),
Tab(text: LocaleKeys.screenTitle_extensions.tr),
]),
body: TabBarView(
controller: controller.tabController,
physics: BouncingScrollPhysics(),
children: [
SourcesView(),
ExtensionsView(),
],
body: TabBarView(
controller: controller.tabController,
physics: BouncingScrollPhysics(),
children: [
SourcesView(),
ExtensionsView(),
],
),
),
);
// return Scaffold(
// backgroundColor: Theme.of(context).colorScheme.background,
// appBar: TabBar(
// physics: BouncingScrollPhysics(),
// controller: controller.tabController,
// padding: EdgeInsets.all(8),
// isScrollable: context.width > 700 ? true : false,
// labelColor: context.theme.indicatorColor,
// unselectedLabelColor: context.textTheme.bodyText1!.color,
// indicator: BoxDecoration(
// borderRadius: BorderRadius.circular(16),
// color: context.theme.indicatorColor.withOpacity(.3),
// ),
// tabs: [
// Tab(text: LocaleKeys.screenTitle_sources.tr),
// Tab(text: LocaleKeys.screenTitle_extensions.tr),
// ]),
// body: TabBarView(
// controller: controller.tabController,
// physics: BouncingScrollPhysics(),
// children: [
// SourcesView(),
// ExtensionsView(),
// ],
// ),
// );
}
}
4 changes: 4 additions & 0 deletions lib/app/modules/extensions/views/extensions_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:get/get.dart';
import 'package:tachidesk_sorayomi/app/modules/browse/controllers/browse_controller.dart';

import '../../../../generated/locales.g.dart';
import '../../../core/utils/language.dart';
Expand All @@ -14,6 +15,7 @@ import '../controllers/extensions_controller.dart';
class ExtensionsView extends GetView<ExtensionsController> {
@override
Widget build(BuildContext context) {
final _ = Get.find<BrowseController>();
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
body: Obx(
Expand All @@ -23,6 +25,8 @@ class ExtensionsView extends GetView<ExtensionsController> {
)
: controller.groupByMap.keys.isNotEmpty
? ListView.builder(
controller: _.scrollController,
shrinkWrap: true,
physics: BouncingScrollPhysics(),
itemCount: controller.groupByMap.keys.length,
itemBuilder: (context, index) {
Expand Down
90 changes: 46 additions & 44 deletions lib/app/modules/global_search/widgets/source_search_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,53 +41,55 @@ class SourceSearchGrid extends StatelessWidget {
@override
Widget build(BuildContext context) {
searchQuery();
return Obx(() => Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: Text(source.displayName ?? source.name!),
trailing: Icon(Icons.arrow_forward_rounded),
onTap: () => Get.toNamed(
"${Routes.sourceManga}/${source.id}/search?query=$query",
),
return Obx(
() => Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: Text(source.displayName ?? source.name!),
trailing: Icon(Icons.arrow_forward_rounded),
onTap: () => Get.toNamed(
"${Routes.sourceManga}/${source.id}/search?query=$query",
),
isLoading
? SizedBox(
height: 205,
child: Center(child: CircularProgressIndicator()),
)
: sourceMangaListModel.mangaList?.isNotEmpty ?? false
? SizedBox(
height: 205,
child: Scrollbar(
thumbVisibility: true,
),
isLoading
? SizedBox(
height: 205,
child: Center(child: CircularProgressIndicator()),
)
: sourceMangaListModel.mangaList?.isNotEmpty ?? false
? SizedBox(
height: 205,
child: Scrollbar(
thumbVisibility: true,
controller: controller,
child: GridView.builder(
controller: controller,
child: GridView.builder(
controller: controller,
scrollDirection: Axis.horizontal,
gridDelegate:
const SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 205,
crossAxisSpacing: 2.0,
mainAxisSpacing: 2.0,
childAspectRatio: 1.43,
),
itemCount: (sourceMangaListModel.mangaList!.length),
itemBuilder: (BuildContext context, int index) {
return MangaGridDesign(
manga: sourceMangaListModel.mangaList![index],
onTap: () => Get.toNamed(
"${Routes.manga}/"
"${sourceMangaListModel.mangaList?[index].id}",
),
isLibraryScreen: true,
);
},
scrollDirection: Axis.horizontal,
gridDelegate:
const SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 205,
crossAxisSpacing: 2.0,
mainAxisSpacing: 2.0,
childAspectRatio: 1.43,
),
itemCount: (sourceMangaListModel.mangaList!.length),
itemBuilder: (BuildContext context, int index) {
return MangaGridDesign(
isLibraryScreen: true,
manga: sourceMangaListModel.mangaList![index],
onTap: () => Get.toNamed(
"${Routes.manga}/"
"${sourceMangaListModel.mangaList?[index].id}",
),
);
},
),
)
: Text("No Results found"),
],
));
),
)
: Text("No Results found"),
],
),
);
}
}
3 changes: 3 additions & 0 deletions lib/app/modules/home/bindings/home_binding.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:get/get.dart';
import 'package:tachidesk_sorayomi/app/modules/home/widgets/small_screen_navigation_bar.dart';

import '../../browse/controllers/browse_controller.dart';
import '../../downloads/controllers/downloads_controller.dart';
Expand All @@ -20,5 +21,7 @@ class HomeBinding extends Bindings {
Get.lazyPut<ExtensionsController>(() => ExtensionsController());
Get.lazyPut<SourcesController>(() => SourcesController());
Get.lazyPut<LibraryController>(() => LibraryController());
Get.lazyPut<ScrollToHideWidgetStateController>(
() => ScrollToHideWidgetStateController());
}
}
43 changes: 30 additions & 13 deletions lib/app/modules/home/widgets/small_screen_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

import 'package:get/get.dart';
import 'package:tachidesk_sorayomi/app/modules/browse/controllers/browse_controller.dart';
import 'package:tachidesk_sorayomi/app/modules/updates/controllers/updates_controller.dart';

import '../../library/controllers/library_controller.dart';
import '../controllers/home_controller.dart';

class SmallScreenNavigationBar extends StatelessWidget {
Expand All @@ -19,7 +22,6 @@ class SmallScreenNavigationBar extends StatelessWidget {
Widget build(BuildContext context) {
return GetBuilder<HomeController>(
builder: (controller) => ScrollToHideWidgetState(
scrollcontroller: controller.scrollController,
child: NavigationBarTheme(
data: NavigationBarThemeData(
labelTextStyle: MaterialStateProperty.all(
Expand Down Expand Up @@ -131,23 +133,19 @@ class SmallScreenNavigationBar extends StatelessWidget {
class ScrollToHideWidgetState
extends GetView<ScrollToHideWidgetStateController> {
final Widget child;
final ScrollController scrollcontroller;

final Duration duration;
final double height;

const ScrollToHideWidgetState(
{Key? key,
required this.child,
required this.scrollcontroller,
this.duration = const Duration(milliseconds: 200),
this.height = kBottomNavigationBarHeight})
: super(key: key);

@override
Widget build(BuildContext context) {
Get.put(ScrollToHideWidgetStateController(
scrollcontroller: scrollcontroller,
));
return Obx(
() => AnimatedContainer(
duration: duration,
Expand All @@ -161,27 +159,46 @@ class ScrollToHideWidgetState
}

class ScrollToHideWidgetStateController extends GetxController {
final ScrollController scrollcontroller;

ScrollToHideWidgetStateController({required this.scrollcontroller});
final libraryControllerscroll = Get.find<LibraryController>();
final updatesControllerscroll = Get.find<UpdatesController>();
final browseControllerscroll = Get.find<BrowseController>();

RxBool isVisible = true.obs;
@override
void onInit() {
scrollcontroller.addListener(listen);

browseControllerscroll.scrollController.addListener(listen);
libraryControllerscroll.scrollController.addListener(listen2);
updatesControllerscroll.scrollController.addListener(listen3);
super.onInit();
}

@override
void dispose() {
scrollcontroller.removeListener(listen);
browseControllerscroll.scrollController.removeListener(listen);
libraryControllerscroll.scrollController.removeListener(listen2);
updatesControllerscroll.scrollController.removeListener(listen3);

super.dispose();
}

void listen() {
if (scrollcontroller.position.pixels >= 68) {
if (browseControllerscroll.scrollController.position.pixels >= 68) {
hide();
} else {
show();
}
}

void listen2() {
if (libraryControllerscroll.scrollController.position.pixels >= 68) {
hide();
} else {
show();
}
}

void listen3() {
if (updatesControllerscroll.scrollController.position.pixels >= 68) {
hide();
} else {
show();
Expand Down
Loading

0 comments on commit a2af567

Please sign in to comment.