Skip to content

Commit

Permalink
Manga_descreption (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
DattatreyaReddy committed Mar 28, 2023
1 parent 1799443 commit 7ffecbc
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 26 deletions.
7 changes: 5 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
// 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:hive_flutter/hive_flutter.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'src/features/about/presentation/about/controllers/about_controller.dart';
Expand All @@ -18,12 +19,14 @@ Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
final packageInfo = await PackageInfo.fromPlatform();
final sharedPreferences = await SharedPreferences.getInstance();
await Hive.initFlutter();
var appDirectory = (kIsWeb) ? null : await getApplicationDocumentsDirectory();

runApp(
ProviderScope(
overrides: [
packageInfoProvider.overrideWithValue(packageInfo),
sharedPreferencesProvider.overrideWithValue(sharedPreferences),
appDirectoryProvider.overrideWithValue(appDirectory),
],
child: const Sorayomi(),
),
Expand Down
13 changes: 13 additions & 0 deletions lib/src/features/settings/presentation/general/general_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../../../constants/language_list.dart';
import '../../../../global_providers/global_providers.dart';
import '../../../../utils/extensions/custom_extensions.dart';
import '../../../../utils/misc/toast/toast.dart';
import '../../../../widgets/radio_list_popup.dart';

class GeneralScreen extends ConsumerWidget {
Expand Down Expand Up @@ -41,6 +42,18 @@ class GeneralScreen extends ConsumerWidget {
),
),
),
ListTile(
leading: const Icon(Icons.cached_rounded),
title: Text(context.l10n!.clearCache),
onTap: () async {
await ref.watch(hiveCacheStoreProvider).clean();
if (context.mounted) {
ref
.read(toastProvider(context))
.show(context.l10n!.cacheCleared);
}
},
),
],
),
);
Expand Down
13 changes: 12 additions & 1 deletion lib/src/global_providers/global_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// 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 'dart:io';

import 'package:dio_cache_interceptor_hive_store/dio_cache_interceptor_hive_store.dart';
import 'package:flutter/material.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:shared_preferences/shared_preferences.dart';
Expand All @@ -20,11 +23,12 @@ import '../utils/storage/dio/network_module.dart';
part 'global_providers.g.dart';

@riverpod
DioClient dioClientKey(ref) => DioClient(
DioClient dioClientKey(DioClientKeyRef ref) => DioClient(
dio: ref.watch(networkModuleProvider).provideDio(
baseUrl: ref.watch(serverUrlProvider) ?? DBKeys.serverUrl.initial,
authType: ref.watch(authTypeKeyProvider) ?? DBKeys.authType.initial,
credentials: ref.watch(credentialsProvider),
hiveCacheStore: ref.watch(hiveCacheStoreProvider),
),
);

Expand Down Expand Up @@ -67,3 +71,10 @@ class L10n extends _$L10n with SharedPreferenceClientMixin<Locale> {

@riverpod
SharedPreferences sharedPreferences(ref) => throw UnimplementedError();

@riverpod
Directory? appDirectory(ref) => throw UnimplementedError();

@riverpod
HiveCacheStore hiveCacheStore(HiveCacheStoreRef ref) =>
HiveCacheStore(ref.watch(appDirectoryProvider)?.path);
31 changes: 30 additions & 1 deletion lib/src/global_providers/global_providers.g.dart

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

8 changes: 8 additions & 0 deletions lib/src/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
"@buildTime": {
"description": "Text title to show build time of Server in About Screen"
},
"@cacheCleared": {
"description": "Toast Text to show after clearing cache"
},
"@cancel": {
"description": "Text for Cancel button in a Popup"
},
Expand Down Expand Up @@ -81,6 +84,9 @@
"@checkForUpdates": {
"description": "Button text to check for App Updates"
},
"@clearCache": {
"description": "Button text for clear cache in General Settings screen"
},
"@client": {
"description": "Text title for the name of the client in About screen"
},
Expand Down Expand Up @@ -611,6 +617,7 @@
"bookmarked": "Bookmarked",
"browse": "Browse",
"buildTime": "Build time",
"cacheCleared": "Cache Cleared",
"cancel": "Cancel",
"categories": "Categories",
"categoryUpdate": "Category Update",
Expand All @@ -621,6 +628,7 @@
"chapterSortUploadDate": "By Upload Date",
"checkForServerUpdates": "Check for Server updates",
"checkForUpdates": "Check for updates",
"clearCache": "Clear Cache",
"client": "Client",
"clientVersion": "Client version",
"close": "Close",
Expand Down
3 changes: 2 additions & 1 deletion lib/src/utils/storage/dio/network_module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ class DioNetworkModule {
Dio provideDio({
required String baseUrl,
required AuthType authType,
HiveCacheStore? hiveCacheStore,
String? credentials,
}) {
final cacheOptions = CacheOptions(
store: HiveCacheStore('dio_cache'),
store: hiveCacheStore,
policy: CachePolicy.refreshForceCache,
hitCacheOnErrorExcept: [401, 403],
priority: CachePriority.normal,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/async_buttons/async_text_button_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AsyncTextButtonIcon extends HookWidget {
icon: (secondaryIcon != null && !isLocalPrimary.value)
? secondaryIcon!
: primaryIcon,
label: (secondaryLabel != null && isLocalPrimary.value)
label: (secondaryLabel != null && !isLocalPrimary.value)
? secondaryLabel!
: primaryLabel,
);
Expand Down
18 changes: 1 addition & 17 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -502,29 +502,13 @@ packages:
source: hosted
version: "2.2.0"
hive:
dependency: "direct main"
dependency: transitive
description:
name: hive
sha256: "8dcf6db979d7933da8217edcec84e9df1bdb4e4edc7fc77dbd5aa74356d6d941"
url: "https://pub.dev"
source: hosted
version: "2.2.3"
hive_flutter:
dependency: "direct main"
description:
name: hive_flutter
sha256: dca1da446b1d808a51689fb5d0c6c9510c0a2ba01e22805d492c73b68e33eecc
url: "https://pub.dev"
source: hosted
version: "1.1.0"
hive_generator:
dependency: "direct dev"
description:
name: hive_generator
sha256: "65998cc4d2cd9680a3d9709d893d2f6bb15e6c1f92626c3f1fa650b4b3281521"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
hooks_riverpod:
dependency: "direct main"
description:
Expand Down
3 changes: 0 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ dependencies:
font_awesome_flutter: ^10.2.1
freezed_annotation: ^2.2.0
go_router: 6.4.1
hive: ^2.2.3
hive_flutter: ^1.1.0
hooks_riverpod: ^2.1.1
infinite_scroll_pagination: ^3.2.0
intl: any
Expand All @@ -51,7 +49,6 @@ dev_dependencies:
flutter_test:
sdk: flutter
freezed: ^2.2.1
hive_generator: ^2.0.0
json_serializable: ^6.5.4
lints: ^2.0.1
riverpod_generator: ^2.0.0
Expand Down

0 comments on commit 7ffecbc

Please sign in to comment.