Skip to content

Commit

Permalink
added padding slider (Suwayomi#132)
Browse files Browse the repository at this point in the history
* added padding slider

* bugs fixed
  • Loading branch information
DattatreyaReddy authored Feb 20, 2023
1 parent b6e1682 commit 5366e52
Show file tree
Hide file tree
Showing 23 changed files with 458 additions and 113 deletions.
3 changes: 0 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'src/features/about/presentation/about/controllers/about_controller.dart';
import 'src/sorayomi.dart';
import 'src/utils/logger/provider_state_logger.dart';
import 'src/utils/storage/local/shared_preferences_client.dart';

Future<void> main() async {
Expand All @@ -21,7 +19,6 @@ Future<void> main() async {
final sharedPreferences = await SharedPreferences.getInstance();
runApp(
ProviderScope(
observers: const [if (kDebugMode) ProviderStateLogger()],
overrides: [
packageInfoProvider.overrideWithValue(packageInfo),
sharedPreferencesProvider.overrideWithValue(sharedPreferences),
Expand Down
1 change: 1 addition & 0 deletions lib/src/constants/db_keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum DBKeys {
authType(AuthType.none),
basicCredentials(null),
readerMode(ReaderMode.webtoon),
readerPadding(0.0),
readerNavigationLayout(ReaderNavigationLayout.disabled),
invertTap(false),
showNSFW(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CategoryTile extends HookConsumerWidget {
category: category,
editCategory: (newCategory) => ref
.read(categoryControllerProvider.notifier)
.editCategory(category),
.editCategory(newCategory),
),
),
icon: const Icon(Icons.edit_rounded),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ class EditCategoryDialog extends HookConsumerWidget {
String categoryName,
bool defaultCategory,
) async {
return editCategory((category ?? Category())
.copyWith(name: categoryName, defaultCategory: defaultCategory));
return editCategory((category ?? Category()).copyWith(
name: categoryName,
defaultCategory: defaultCategory,
));
}

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/src/features/manga_book/data/manga_book_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ class MangaBookRepository {
Future<void> patchMangaMeta({
required String mangaId,
required String key,
required String value,
required dynamic value,
CancelToken? cancelToken,
}) async =>
(await dioClient.patch<Chapter, Chapter?>(
MangaUrl.meta(mangaId),
data: FormData.fromMap({"key": key, "value": value}),
data: FormData.fromMap({"key": key, "value": value.toString()}),
cancelToken: cancelToken,
));

Expand Down
24 changes: 21 additions & 3 deletions lib/src/features/manga_book/domain/manga/manga_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,38 @@ class Manga with _$Manga {
@freezed
class MangaMeta with _$MangaMeta {
factory MangaMeta({
@JsonKey(name: "flutter_readerNavigationLayoutInvert") bool? invertTap,
@JsonKey(
name: "flutter_readerNavigationLayoutInvert",
fromJson: MangaMeta.fromJsonToBool,
)
bool? invertTap,
@JsonKey(name: "flutter_readerNavigationLayout")
ReaderNavigationLayout? readerNavigationLayout,
@JsonKey(name: "flutter_readerMode") ReaderMode? readerMode,
@JsonKey(name: "flutter_readerMode")
ReaderMode? readerMode,
@JsonKey(
name: "flutter_readerPadding",
fromJson: MangaMeta.fromJsonToDouble,
)
double? readerPadding,
}) = _MangaMeta;

static bool? fromJsonToBool(dynamic val) => val != null && val is String
? val.toLowerCase().compareTo(true.toString()) == 0
: null;

static double? fromJsonToDouble(dynamic val) =>
val != null && val is String ? double.parse(val) : null;
factory MangaMeta.fromJson(Map<String, dynamic> json) =>
_$MangaMetaFromJson(json);
}

enum MangaMetaKeys {
invertTap("flutter_readerNavigationLayoutInvert"),
readerNavigationLayout("flutter_readerNavigationLayout"),
readerMode("flutter_readerMode");
readerMode("flutter_readerMode"),
readerPadding("flutter_readerPadding"),
;

const MangaMetaKeys(this.key);
final String key;
Expand Down
64 changes: 49 additions & 15 deletions lib/src/features/manga_book/domain/manga/manga_model.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -694,13 +694,17 @@ MangaMeta _$MangaMetaFromJson(Map<String, dynamic> json) {

/// @nodoc
mixin _$MangaMeta {
@JsonKey(name: "flutter_readerNavigationLayoutInvert")
@JsonKey(
name: "flutter_readerNavigationLayoutInvert",
fromJson: MangaMeta.fromJsonToBool)
bool? get invertTap => throw _privateConstructorUsedError;
@JsonKey(name: "flutter_readerNavigationLayout")
ReaderNavigationLayout? get readerNavigationLayout =>
throw _privateConstructorUsedError;
@JsonKey(name: "flutter_readerMode")
ReaderMode? get readerMode => throw _privateConstructorUsedError;
@JsonKey(name: "flutter_readerPadding", fromJson: MangaMeta.fromJsonToDouble)
double? get readerPadding => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
Expand All @@ -714,12 +718,14 @@ abstract class $MangaMetaCopyWith<$Res> {
_$MangaMetaCopyWithImpl<$Res, MangaMeta>;
@useResult
$Res call(
{@JsonKey(name: "flutter_readerNavigationLayoutInvert")
{@JsonKey(name: "flutter_readerNavigationLayoutInvert", fromJson: MangaMeta.fromJsonToBool)
bool? invertTap,
@JsonKey(name: "flutter_readerNavigationLayout")
ReaderNavigationLayout? readerNavigationLayout,
@JsonKey(name: "flutter_readerMode")
ReaderMode? readerMode});
ReaderMode? readerMode,
@JsonKey(name: "flutter_readerPadding", fromJson: MangaMeta.fromJsonToDouble)
double? readerPadding});
}

/// @nodoc
Expand All @@ -738,6 +744,7 @@ class _$MangaMetaCopyWithImpl<$Res, $Val extends MangaMeta>
Object? invertTap = freezed,
Object? readerNavigationLayout = freezed,
Object? readerMode = freezed,
Object? readerPadding = freezed,
}) {
return _then(_value.copyWith(
invertTap: freezed == invertTap
Expand All @@ -752,6 +759,10 @@ class _$MangaMetaCopyWithImpl<$Res, $Val extends MangaMeta>
? _value.readerMode
: readerMode // ignore: cast_nullable_to_non_nullable
as ReaderMode?,
readerPadding: freezed == readerPadding
? _value.readerPadding
: readerPadding // ignore: cast_nullable_to_non_nullable
as double?,
) as $Val);
}
}
Expand All @@ -764,12 +775,14 @@ abstract class _$$_MangaMetaCopyWith<$Res> implements $MangaMetaCopyWith<$Res> {
@override
@useResult
$Res call(
{@JsonKey(name: "flutter_readerNavigationLayoutInvert")
{@JsonKey(name: "flutter_readerNavigationLayoutInvert", fromJson: MangaMeta.fromJsonToBool)
bool? invertTap,
@JsonKey(name: "flutter_readerNavigationLayout")
ReaderNavigationLayout? readerNavigationLayout,
@JsonKey(name: "flutter_readerMode")
ReaderMode? readerMode});
ReaderMode? readerMode,
@JsonKey(name: "flutter_readerPadding", fromJson: MangaMeta.fromJsonToDouble)
double? readerPadding});
}

/// @nodoc
Expand All @@ -786,6 +799,7 @@ class __$$_MangaMetaCopyWithImpl<$Res>
Object? invertTap = freezed,
Object? readerNavigationLayout = freezed,
Object? readerMode = freezed,
Object? readerPadding = freezed,
}) {
return _then(_$_MangaMeta(
invertTap: freezed == invertTap
Expand All @@ -800,6 +814,10 @@ class __$$_MangaMetaCopyWithImpl<$Res>
? _value.readerMode
: readerMode // ignore: cast_nullable_to_non_nullable
as ReaderMode?,
readerPadding: freezed == readerPadding
? _value.readerPadding
: readerPadding // ignore: cast_nullable_to_non_nullable
as double?,
));
}
}
Expand All @@ -808,29 +826,36 @@ class __$$_MangaMetaCopyWithImpl<$Res>
@JsonSerializable()
class _$_MangaMeta implements _MangaMeta {
_$_MangaMeta(
{@JsonKey(name: "flutter_readerNavigationLayoutInvert")
{@JsonKey(name: "flutter_readerNavigationLayoutInvert", fromJson: MangaMeta.fromJsonToBool)
this.invertTap,
@JsonKey(name: "flutter_readerNavigationLayout")
this.readerNavigationLayout,
@JsonKey(name: "flutter_readerMode")
this.readerMode});
this.readerMode,
@JsonKey(name: "flutter_readerPadding", fromJson: MangaMeta.fromJsonToDouble)
this.readerPadding});

factory _$_MangaMeta.fromJson(Map<String, dynamic> json) =>
_$$_MangaMetaFromJson(json);

@override
@JsonKey(name: "flutter_readerNavigationLayoutInvert")
@JsonKey(
name: "flutter_readerNavigationLayoutInvert",
fromJson: MangaMeta.fromJsonToBool)
final bool? invertTap;
@override
@JsonKey(name: "flutter_readerNavigationLayout")
final ReaderNavigationLayout? readerNavigationLayout;
@override
@JsonKey(name: "flutter_readerMode")
final ReaderMode? readerMode;
@override
@JsonKey(name: "flutter_readerPadding", fromJson: MangaMeta.fromJsonToDouble)
final double? readerPadding;

@override
String toString() {
return 'MangaMeta(invertTap: $invertTap, readerNavigationLayout: $readerNavigationLayout, readerMode: $readerMode)';
return 'MangaMeta(invertTap: $invertTap, readerNavigationLayout: $readerNavigationLayout, readerMode: $readerMode, readerPadding: $readerPadding)';
}

@override
Expand All @@ -843,13 +868,15 @@ class _$_MangaMeta implements _MangaMeta {
(identical(other.readerNavigationLayout, readerNavigationLayout) ||
other.readerNavigationLayout == readerNavigationLayout) &&
(identical(other.readerMode, readerMode) ||
other.readerMode == readerMode));
other.readerMode == readerMode) &&
(identical(other.readerPadding, readerPadding) ||
other.readerPadding == readerPadding));
}

@JsonKey(ignore: true)
@override
int get hashCode =>
Object.hash(runtimeType, invertTap, readerNavigationLayout, readerMode);
int get hashCode => Object.hash(runtimeType, invertTap,
readerNavigationLayout, readerMode, readerPadding);

@JsonKey(ignore: true)
@override
Expand All @@ -867,18 +894,22 @@ class _$_MangaMeta implements _MangaMeta {

abstract class _MangaMeta implements MangaMeta {
factory _MangaMeta(
{@JsonKey(name: "flutter_readerNavigationLayoutInvert")
{@JsonKey(name: "flutter_readerNavigationLayoutInvert", fromJson: MangaMeta.fromJsonToBool)
final bool? invertTap,
@JsonKey(name: "flutter_readerNavigationLayout")
final ReaderNavigationLayout? readerNavigationLayout,
@JsonKey(name: "flutter_readerMode")
final ReaderMode? readerMode}) = _$_MangaMeta;
final ReaderMode? readerMode,
@JsonKey(name: "flutter_readerPadding", fromJson: MangaMeta.fromJsonToDouble)
final double? readerPadding}) = _$_MangaMeta;

factory _MangaMeta.fromJson(Map<String, dynamic> json) =
_$_MangaMeta.fromJson;

@override
@JsonKey(name: "flutter_readerNavigationLayoutInvert")
@JsonKey(
name: "flutter_readerNavigationLayoutInvert",
fromJson: MangaMeta.fromJsonToBool)
bool? get invertTap;
@override
@JsonKey(name: "flutter_readerNavigationLayout")
Expand All @@ -887,6 +918,9 @@ abstract class _MangaMeta implements MangaMeta {
@JsonKey(name: "flutter_readerMode")
ReaderMode? get readerMode;
@override
@JsonKey(name: "flutter_readerPadding", fromJson: MangaMeta.fromJsonToDouble)
double? get readerPadding;
@override
@JsonKey(ignore: true)
_$$_MangaMetaCopyWith<_$_MangaMeta> get copyWith =>
throw _privateConstructorUsedError;
Expand Down
5 changes: 4 additions & 1 deletion lib/src/features/manga_book/domain/manga/manga_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class MangaDetailsScreen extends HookConsumerWidget {
...?ref
.read(
mangaChapterListWithFilterProvider(
mangaId: mangaId),
mangaId: mangaId,
),
)
.valueOrNull
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../../../../constants/app_sizes.dart';

import '../../../../../utils/extensions/custom_extensions.dart';
import '../../../../../widgets/async_buttons/async_checkbox_list_tile.dart';
import '../../../../../widgets/pop_button.dart';
import '../../../../library/presentation/category/controller/edit_category_controller.dart';
import '../../../data/manga_book_repository.dart';
Expand All @@ -32,9 +33,7 @@ class EditMangaCategoryDialog extends HookConsumerWidget {
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.l10n!.editCategory,
),
Text(context.l10n!.editCategory),
if (title.isNotBlank)
Text(
title!,
Expand All @@ -59,8 +58,8 @@ class EditMangaCategoryDialog extends HookConsumerWidget {
context,
(selectedCategoryList) => Column(
children: [
for (int index = 0; index < data!.length; index++)
CheckboxListTile(
for (int index = 1; index < data!.length; index++)
AsyncCheckboxListTile(
onChanged: (value) async {
await AsyncValue.guard(
() => value.ifNull()
Expand Down
Loading

0 comments on commit 5366e52

Please sign in to comment.