Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
joaojsrbr committed May 7, 2022
1 parent 084929b commit d019cf9
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 98 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'com.android.tools.build:gradle:7.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
15 changes: 15 additions & 0 deletions lib/app/modules/library/controllers/library_controller.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:math';

import 'package:flutter/material.dart';

import 'package:get/get.dart';
Expand Down Expand Up @@ -104,6 +106,19 @@ class LibraryController extends GetxController
super.onInit();
}

String randomName() {
final rand = Random();
return [
\\_(ツ)_/¯',
'(・o・;)',
'Σ(ಠ_ಠ)',
'ಥ_ಥ',
'(˘・_・˘)',
'(; ̄Д ̄)',
'(・Д・。',
].elementAt(rand.nextInt(7));
}

@override
void onReady() async {
_categoryList.listen((cat) {
Expand Down
173 changes: 85 additions & 88 deletions lib/app/modules/library/views/library_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,27 @@ import '../controllers/library_controller.dart';
class LibraryView extends GetView<LibraryController> {
@override
Widget build(BuildContext context) {
return GetBuilder<HomeController>(
builder: (c) => Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
body: NestedScrollView(
controller: c.scrollController,
body: Obx(
() => controller.categoryListLength >= 1
? TabBarView(
controller: controller.tabController,
physics: const BouncingScrollPhysics(),
children: controller.categoryList.map<Widget>(
(e) {
int index = controller.categoryList.indexOf(e);
List<Manga>? mangaList =
controller.categoryMangaMap[index];
return mangaList != null && mangaList.isNotEmpty
? GridView.builder(
final _ = Get.find<HomeController>();
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
body: NestedScrollView(
controller: _.scrollController,
body: Obx(
() => controller.categoryListLength >= 1
? TabBarView(
controller: controller.tabController,
physics: const BouncingScrollPhysics(),
children: controller.categoryList.map<Widget>(
(e) {
int index = controller.categoryList.indexOf(e);
List<Manga>? mangaList =
controller.categoryMangaMap[index];
return mangaList != null && mangaList.isNotEmpty
? GetBuilder<HomeController>(
builder: (controller) => GridView.builder(
// controller: c.scrollController,
shrinkWrap: true,

padding: EdgeInsets.only(
right: 4, left: 4, top: 2, bottom: 2),
gridDelegate:
Expand All @@ -54,78 +56,73 @@ class LibraryView extends GetView<LibraryController> {
),
isLibraryScreen: true,
),
)
: (controller.isLoading
? Center(
child: CircularProgressIndicator(),
)
: EmoticonsView(
text: "${LocaleKeys.no.tr} "
"${LocaleKeys.libraryScreen_manga.tr}",
button: TextButton.icon(
onPressed: () => controller
.loadMangaListWithCategoryId(),
style: TextButton.styleFrom(),
icon: Icon(Icons.refresh),
label: Text(
LocaleKeys.libraryScreen_refresh.tr,
),
),
));
},
).toList(),
)
: (controller.isCategoryLoading
? Center(
child: CircularProgressIndicator(),
)
: EmoticonsView(
text: "${LocaleKeys.no.tr} "
"${LocaleKeys.libraryScreen_manga.tr}",
button: TextButton.icon(
onPressed: () => controller.refreshLibraryScreen(),
style: TextButton.styleFrom(),
icon: Icon(Icons.refresh),
label: Text(
LocaleKeys.libraryScreen_refresh.tr,
),
),
)),
),
physics: BouncingScrollPhysics(),
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return [
SliverAppBar(
toolbarHeight: 70,

pinned: true,
floating: true,
actions: [
Obx(() => c.selectedIndex == 0
? LibraryAppBarActions()
: SizedBox()),
Obx(() =>
c.selectedIndex == 2 ? BrowseAppBarActions() : SizedBox())
],
// pinned: true,
// floating: true,
title: Text(navigationBarTitles[0].tr),
bottom: controller.categoryListLength <= 1
? null
: TabBar(
controller: controller.tabController,
isScrollable: true,
indicatorSize: TabBarIndicatorSize.label,
indicatorColor: Theme.of(context).colorScheme.primary,
// padding: EdgeInsets.all(8),
tabs: controller.categoryList
.map<Tab>((e) => Tab(text: e?.name ?? ""))
.toList(),
),
),
];
},
),
)
: (controller.isLoading
? Center(
child: CircularProgressIndicator(),
)
: EmoticonsView(
text: "${LocaleKeys.no.tr} "
"${LocaleKeys.libraryScreen_manga.tr}",
));
},
).toList(),
)
: (controller.isCategoryLoading
? Center(
child: CircularProgressIndicator(),
)
: EmoticonsView(
text: "${LocaleKeys.no.tr} "
"${LocaleKeys.libraryScreen_manga.tr}",
)),
),
// button: TextButton.icon(
// onPressed: () => controller.refreshLibraryScreen(),
// style: TextButton.styleFrom(),
// icon: Icon(Icons.refresh),
// label: Text(
// LocaleKeys.libraryScreen_refresh.tr,
// ),
// ),
// )),
physics: BouncingScrollPhysics(),
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return [
SliverAppBar(
toolbarHeight: 70,
elevation: 0,
pinned: true,
floating: true,
actions: [
IconButton(
enableFeedback: false,
onPressed: () => controller.refreshLibraryScreen(),
icon: Icon(Icons.refresh)),
Obx(() =>
_.selectedIndex == 0 ? LibraryAppBarActions() : SizedBox()),
Obx(() =>
_.selectedIndex == 2 ? BrowseAppBarActions() : SizedBox())
],
// pinned: true,
// floating: true,
title: Text(navigationBarTitles[0].tr),
bottom: controller.categoryListLength <= 1
? null
: TabBar(
controller: controller.tabController,
isScrollable: true,
indicatorSize: TabBarIndicatorSize.label,
indicatorColor: Theme.of(context).colorScheme.primary,
// padding: EdgeInsets.all(8),
tabs: controller.categoryList
.map<Tab>((e) => Tab(text: e?.name ?? ""))
.toList(),
),
),
];
},
),
);
// Scaffold(
Expand Down
22 changes: 13 additions & 9 deletions lib/app/widgets/emoticons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import 'package:flutter/material.dart';

import 'package:get/get.dart';

const errorFaces = [
'(・o・;)',
'Σ(ಠ_ಠ)',
'ಥ_ಥ',
'(˘・_・˘)',
'(; ̄Д ̄)',
'(・Д・。',
];
String randomName() {
final rand = Random();
return [
\\_(ツ)_/¯',
'(・o・;)',
'Σ(ಠ_ಠ)',
'ಥ_ಥ',
'(˘・_・˘)',
'(; ̄Д ̄)',
'(・Д・。',
].elementAt(rand.nextInt(7));
}

class EmoticonsView extends StatelessWidget {
const EmoticonsView({
Expand All @@ -29,7 +33,7 @@ class EmoticonsView extends StatelessWidget {
children: [
ListTile(
title: Text(
errorFaces[Random().nextInt(6)],
randomName(),
textAlign: TextAlign.center,
style: Get.textTheme.headlineLarge,
),
Expand Down

0 comments on commit d019cf9

Please sign in to comment.