mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-05-05 23:19:11 +00:00
add incognito mode & global color for ListTile icon
This commit is contained in:
parent
edf9958b8f
commit
e71a28f21e
18 changed files with 268 additions and 103 deletions
|
|
@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:mangayomi/constant.dart';
|
||||
import 'package:mangayomi/utils/constant.dart';
|
||||
import 'package:mangayomi/models/manga_history.dart';
|
||||
import 'package:mangayomi/models/model_manga.dart';
|
||||
import 'package:mangayomi/router/router.dart';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:mangayomi/constant.dart';
|
||||
import 'package:mangayomi/utils/constant.dart';
|
||||
import 'package:mangayomi/models/manga_history.dart';
|
||||
import 'package:mangayomi/models/model_manga.dart';
|
||||
import 'package:mangayomi/source/source_model.dart';
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import 'package:mangayomi/providers/hive_provider.dart';
|
|||
import 'package:mangayomi/services/get_popular_manga.dart';
|
||||
import 'package:mangayomi/services/http_res_to_dom_html.dart';
|
||||
import 'package:mangayomi/source/source_model.dart';
|
||||
import 'package:mangayomi/views/more/settings/providers/incognito_mode_state_provider.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:flutter_js/flutter_js.dart';
|
||||
|
|
@ -34,7 +35,7 @@ Future<GetMangaChapterUrlModel> getMangaChapterUrl(
|
|||
List hiveUrl = ref.watch(hiveBoxMangaInfo).get(
|
||||
"${modelManga.source}/${modelManga.name}/${modelManga.chapterTitle![index]}-pageurl",
|
||||
defaultValue: []);
|
||||
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
Directory? pathh;
|
||||
if (Platform.isWindows) {
|
||||
pathh = await getApplicationDocumentsDirectory();
|
||||
|
|
@ -44,9 +45,13 @@ Future<GetMangaChapterUrlModel> getMangaChapterUrl(
|
|||
|
||||
path = Directory(
|
||||
"${pathh!.path}/${modelManga.source}/${modelManga.name}/${modelManga.chapterTitle![index]}/");
|
||||
if (hiveUrl.isNotEmpty) {
|
||||
urll = hiveUrl;
|
||||
|
||||
if (!incognitoMode) {
|
||||
if (hiveUrl.isNotEmpty) {
|
||||
urll = hiveUrl;
|
||||
}
|
||||
}
|
||||
|
||||
/*********/
|
||||
/*comick*/
|
||||
/********/
|
||||
|
|
@ -73,9 +78,11 @@ Future<GetMangaChapterUrlModel> getMangaChapterUrl(
|
|||
urll.add(url.url);
|
||||
}
|
||||
}
|
||||
ref.watch(hiveBoxMangaInfo).put(
|
||||
"${modelManga.source}/${modelManga.name}/${modelManga.chapterTitle![index]}-pageurl",
|
||||
urll);
|
||||
if (!incognitoMode) {
|
||||
ref.watch(hiveBoxMangaInfo).put(
|
||||
"${modelManga.source}/${modelManga.name}/${modelManga.chapterTitle![index]}-pageurl",
|
||||
urll);
|
||||
}
|
||||
}
|
||||
/*************/
|
||||
/*mangathemesia*/
|
||||
|
|
@ -123,9 +130,11 @@ Future<GetMangaChapterUrlModel> getMangaChapterUrl(
|
|||
urll.add(tt);
|
||||
}
|
||||
}
|
||||
ref.watch(hiveBoxMangaInfo).put(
|
||||
"${modelManga.source}/${modelManga.name}/${modelManga.chapterTitle![index]}-pageurl",
|
||||
urll);
|
||||
if (!incognitoMode) {
|
||||
ref.watch(hiveBoxMangaInfo).put(
|
||||
"${modelManga.source}/${modelManga.name}/${modelManga.chapterTitle![index]}-pageurl",
|
||||
urll);
|
||||
}
|
||||
}
|
||||
}
|
||||
/***********/
|
||||
|
|
@ -238,11 +247,13 @@ Future<GetMangaChapterUrlModel> getMangaChapterUrl(
|
|||
deobfuscatedScript.substring(imageLinkStartPos, imageLinkEndPos);
|
||||
urll.add("https:$baseLink$imageLink");
|
||||
}
|
||||
log(urll.toString());
|
||||
|
||||
flutterJs.dispose();
|
||||
ref.watch(hiveBoxMangaInfo).put(
|
||||
"${modelManga.source}/${modelManga.name}/${modelManga.chapterTitle![index]}-pageurl",
|
||||
urll);
|
||||
if (!incognitoMode) {
|
||||
ref.watch(hiveBoxMangaInfo).put(
|
||||
"${modelManga.source}/${modelManga.name}/${modelManga.chapterTitle![index]}-pageurl",
|
||||
urll);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
5
lib/utils/colors.dart
Normal file
5
lib/utils/colors.dart
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
generalColor(BuildContext context) {
|
||||
return Theme.of(context).toggleButtonsTheme.color;
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mangayomi/models/model_manga.dart';
|
||||
import 'package:mangayomi/utils/cached_network.dart';
|
||||
import 'package:mangayomi/utils/colors.dart';
|
||||
import 'package:mangayomi/views/widgets/bottom_text_widget.dart';
|
||||
import 'package:mangayomi/views/widgets/cover_view_widget.dart';
|
||||
import 'package:mangayomi/views/widgets/gridview_widget.dart';
|
||||
|
|
@ -51,7 +52,7 @@ class LibraryGridViewWidget extends StatelessWidget {
|
|||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
color: Theme.of(context).cardColor),
|
||||
color: generalColor(context),),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(1),
|
||||
child: Text(entriesManga[index]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mangayomi/models/model_manga.dart';
|
||||
import 'package:mangayomi/utils/cached_network.dart';
|
||||
import 'package:mangayomi/utils/colors.dart';
|
||||
import 'package:mangayomi/utils/media_query.dart';
|
||||
import 'package:mangayomi/views/widgets/listview_widget.dart';
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ class LibraryListViewWidget extends StatelessWidget {
|
|||
child: Container(
|
||||
height: 45,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).canvasColor,
|
||||
color: generalColor(context),
|
||||
borderRadius: BorderRadius.circular(5)),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:mangayomi/models/model_manga.dart';
|
|||
import 'package:mangayomi/providers/hive_provider.dart';
|
||||
import 'package:mangayomi/utils/media_query.dart';
|
||||
import 'package:mangayomi/views/manga/detail/manga_detail_view.dart';
|
||||
import 'package:mangayomi/views/more/settings/providers/incognito_mode_state_provider.dart';
|
||||
|
||||
final isExtended = StateProvider.autoDispose<bool>((ref) {
|
||||
return true;
|
||||
|
|
@ -62,7 +63,9 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
final entries = value.get(
|
||||
"${widget.modelManga.source}/${widget.modelManga.name}-chapter_index",
|
||||
defaultValue: '');
|
||||
if (entries.isNotEmpty) {
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
|
||||
if (entries.isNotEmpty && !incognitoMode) {
|
||||
return Consumer(builder: (context, ref, child) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
|
|
@ -118,7 +121,7 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
height: 50,
|
||||
width: !ref.watch(isExtended)
|
||||
? 60
|
||||
: mediaWidth(context, 0.25),
|
||||
: mediaWidth(context, 0.3),
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeIn,
|
||||
child: ElevatedButton(
|
||||
|
|
@ -137,7 +140,7 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
children: [
|
||||
AnimatedContainer(
|
||||
curve: Curves.easeIn,
|
||||
width: !ref.watch(isExtended) ? 0 : 30,
|
||||
width: !ref.watch(isExtended) ? 0 : 40,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: const Text(
|
||||
"Read",
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ class _MangaChapterPageGalleryState
|
|||
_itemScrollController.scrollTo(
|
||||
curve: Curves.ease,
|
||||
index: ok,
|
||||
duration: Duration(milliseconds: isSlide ? 2 : 150));
|
||||
duration: Duration(milliseconds: isSlide ? 2 : 150));
|
||||
}
|
||||
} else {
|
||||
if (ok != -1) {
|
||||
|
|
@ -191,14 +191,14 @@ class _MangaChapterPageGalleryState
|
|||
} else {
|
||||
if (_selectedValue == ReaderMode.verticalContinuous ||
|
||||
_selectedValue == ReaderMode.webtoon) {
|
||||
if (widget.readerController.getPageLength() != ok) {
|
||||
if (widget.readerController.getPageLength(widget.url) != ok) {
|
||||
_itemScrollController.scrollTo(
|
||||
curve: Curves.ease,
|
||||
index: ok,
|
||||
duration: Duration(milliseconds: isSlide ? 2 : 150));
|
||||
}
|
||||
} else {
|
||||
if (widget.readerController.getPageLength() != ok) {
|
||||
if (widget.readerController.getPageLength(widget.url) != ok) {
|
||||
if (_extendedController.hasClients) {
|
||||
_extendedController.animateToPage(ok.toInt(),
|
||||
duration: Duration(milliseconds: isSlide ? 2 : 150),
|
||||
|
|
@ -471,7 +471,7 @@ class _MangaChapterPageGalleryState
|
|||
Padding(
|
||||
padding: const EdgeInsets.only(left: 12),
|
||||
child: Text(
|
||||
"${widget.readerController.getPageLength()}",
|
||||
"${widget.readerController.getPageLength(widget.url)}",
|
||||
style: const TextStyle(
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
|
@ -489,7 +489,7 @@ class _MangaChapterPageGalleryState
|
|||
},
|
||||
divisions: max(
|
||||
widget.readerController
|
||||
.getPageLength() -
|
||||
.getPageLength(widget.url) -
|
||||
1,
|
||||
1),
|
||||
value: ref
|
||||
|
|
@ -499,7 +499,7 @@ class _MangaChapterPageGalleryState
|
|||
.toDouble(),
|
||||
min: 0,
|
||||
max: (widget.readerController
|
||||
.getPageLength() -
|
||||
.getPageLength(widget.url) -
|
||||
1)
|
||||
.toDouble(),
|
||||
),
|
||||
|
|
@ -520,7 +520,7 @@ class _MangaChapterPageGalleryState
|
|||
Padding(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: Text(
|
||||
"${widget.readerController.getPageLength()}",
|
||||
"${widget.readerController.getPageLength(widget.url)}",
|
||||
style: const TextStyle(
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
|
@ -647,7 +647,7 @@ class _MangaChapterPageGalleryState
|
|||
? Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Text(
|
||||
'${ref.watch(currentIndexProvider(widget.readerController.mangaReaderModel)) + 1} / ${widget.readerController.getPageLength()}',
|
||||
'${ref.watch(currentIndexProvider(widget.readerController.mangaReaderModel)) + 1} / ${widget.readerController.getPageLength(widget.url)}',
|
||||
style: const TextStyle(
|
||||
fontSize: 12.0,
|
||||
color: Colors.white,
|
||||
|
|
@ -887,7 +887,8 @@ class _MangaChapterPageGalleryState
|
|||
minCacheExtent: 8 * (MediaQuery.of(context).size.height),
|
||||
initialScrollIndex:
|
||||
widget.readerController.getPageIndex(),
|
||||
itemCount: widget.readerController.getPageLength(),
|
||||
itemCount:
|
||||
widget.readerController.getPageLength(widget.url),
|
||||
itemScrollController: _itemScrollController,
|
||||
itemPositionsListener: _itemPositionsListener,
|
||||
itemBuilder: (context, index) => GestureDetector(
|
||||
|
|
@ -903,7 +904,8 @@ class _MangaChapterPageGalleryState
|
|||
url: widget.url[index],
|
||||
path: widget.path,
|
||||
chapter: widget.readerController.getChapterTitle(),
|
||||
length: widget.readerController.getPageLength(),
|
||||
length:
|
||||
widget.readerController.getPageLength(widget.url),
|
||||
),
|
||||
),
|
||||
separatorBuilder: (_, __) => Divider(
|
||||
|
|
@ -931,7 +933,8 @@ class _MangaChapterPageGalleryState
|
|||
url: widget.url[index],
|
||||
path: widget.path,
|
||||
chapter: widget.readerController.getChapterTitle(),
|
||||
length: widget.readerController.getPageLength(),
|
||||
length:
|
||||
widget.readerController.getPageLength(widget.url),
|
||||
loadStateChanged: (ExtendedImageState state) {
|
||||
if (state.extendedImageLoadState ==
|
||||
LoadState.loading) {
|
||||
|
|
@ -1055,7 +1058,8 @@ class _MangaChapterPageGalleryState
|
|||
},
|
||||
);
|
||||
},
|
||||
itemCount: widget.readerController.getPageLength(),
|
||||
itemCount:
|
||||
widget.readerController.getPageLength(widget.url),
|
||||
onPageChanged: _onPageChanged)),
|
||||
_gestureRightLeft(),
|
||||
_gestureTopBottom(),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:mangayomi/models/manga_history.dart';
|
|||
import 'package:mangayomi/models/manga_reader.dart';
|
||||
import 'package:mangayomi/models/model_manga.dart';
|
||||
import 'package:mangayomi/providers/hive_provider.dart';
|
||||
import 'package:mangayomi/views/more/settings/providers/incognito_mode_state_provider.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
part 'reader_controller_provider.g.dart';
|
||||
|
|
@ -24,9 +25,13 @@ enum ReaderMode {
|
|||
class CurrentIndex extends _$CurrentIndex {
|
||||
@override
|
||||
int build(MangaReaderModel mangaReaderModel) {
|
||||
return ref.watch(hiveBoxMangaInfo).get(
|
||||
"${mangaReaderModel.modelManga.source}/${mangaReaderModel.modelManga.name}/${mangaReaderModel.modelManga.chapterTitle![mangaReaderModel.index]}-page_index",
|
||||
defaultValue: 0);
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
return ref.watch(hiveBoxMangaInfo).get(
|
||||
"${mangaReaderModel.modelManga.source}/${mangaReaderModel.modelManga.name}/${mangaReaderModel.modelManga.chapterTitle![mangaReaderModel.index]}-page_index",
|
||||
defaultValue: 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
setCurrentIndex(int currentIndex) {
|
||||
|
|
@ -44,16 +49,20 @@ class ReaderController extends _$ReaderController {
|
|||
}
|
||||
|
||||
ReaderMode getReaderMode() {
|
||||
return ref.watch(hiveBoxReaderMode).get(
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
return ref.watch(hiveBoxReaderMode).get(
|
||||
"${getSourceName()}/${getMangaName()}-singleMangaReaderModeValue",
|
||||
defaultValue: null) !=
|
||||
null
|
||||
? ref.watch(hiveBoxReaderMode).get(
|
||||
"${getSourceName()}/${getMangaName()}-singleMangaReaderModeValue",
|
||||
defaultValue: null) !=
|
||||
null
|
||||
? ref.watch(hiveBoxReaderMode).get(
|
||||
"${getSourceName()}/${getMangaName()}-singleMangaReaderModeValue",
|
||||
)!
|
||||
: ref
|
||||
.watch(hiveBoxReaderMode)
|
||||
.get("globalMangaReaderModeValue", defaultValue: ReaderMode.ltr)!;
|
||||
)!
|
||||
: ref
|
||||
.watch(hiveBoxReaderMode)
|
||||
.get("globalMangaReaderModeValue", defaultValue: ReaderMode.ltr)!;
|
||||
}
|
||||
return ReaderMode.vertical;
|
||||
}
|
||||
|
||||
String getReaderModeValue(ReaderMode readerMode) {
|
||||
|
|
@ -69,29 +78,42 @@ class ReaderController extends _$ReaderController {
|
|||
}
|
||||
|
||||
void setReaderMode(ReaderMode newReaderMode) {
|
||||
ref.watch(hiveBoxReaderMode).put(
|
||||
"${getSourceName()}/${getMangaName()}-singleMangaReaderModeValue",
|
||||
newReaderMode);
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
ref.watch(hiveBoxReaderMode).put(
|
||||
"${getSourceName()}/${getMangaName()}-singleMangaReaderModeValue",
|
||||
newReaderMode);
|
||||
}
|
||||
}
|
||||
|
||||
void setShowPageNumber(bool value) {
|
||||
ref
|
||||
.watch(hiveBoxMangaInfo)
|
||||
.put("${getSourceName()}/${getMangaName()}-showPagesNumber", value);
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
ref
|
||||
.watch(hiveBoxMangaInfo)
|
||||
.put("${getSourceName()}/${getMangaName()}-showPagesNumber", value);
|
||||
}
|
||||
}
|
||||
|
||||
bool getShowPageNumber() {
|
||||
return ref.watch(hiveBoxMangaInfo).get(
|
||||
"${getSourceName()}/${getMangaName()}-showPagesNumber",
|
||||
defaultValue: true);
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
return ref.watch(hiveBoxMangaInfo).get(
|
||||
"${getSourceName()}/${getMangaName()}-showPagesNumber",
|
||||
defaultValue: true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void setMangaHistoryUpdate() {
|
||||
ref.watch(hiveBoxMangaHistory).put(
|
||||
mangaReaderModel.modelManga.link,
|
||||
MangaHistoryModel(
|
||||
date: DateTime.now().toString(),
|
||||
modelManga: mangaReaderModel.modelManga));
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
ref.watch(hiveBoxMangaHistory).put(
|
||||
mangaReaderModel.modelManga.link,
|
||||
MangaHistoryModel(
|
||||
date: DateTime.now().toString(),
|
||||
modelManga: mangaReaderModel.modelManga));
|
||||
}
|
||||
}
|
||||
|
||||
int getChapterIndex() {
|
||||
|
|
@ -99,28 +121,42 @@ class ReaderController extends _$ReaderController {
|
|||
}
|
||||
|
||||
void setChapterIndex() {
|
||||
ref.watch(hiveBoxMangaInfo).put(
|
||||
"${getSourceName()}/${getMangaName()}-chapter_index",
|
||||
mangaReaderModel.index.toString());
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
ref.watch(hiveBoxMangaInfo).put(
|
||||
"${getSourceName()}/${getMangaName()}-chapter_index",
|
||||
mangaReaderModel.index.toString());
|
||||
}
|
||||
}
|
||||
|
||||
int getPageIndex() {
|
||||
return ref.watch(hiveBoxMangaInfo).get(
|
||||
"${getSourceName()}/${getMangaName()}/${getChapterTitle()}-page_index",
|
||||
defaultValue: 0);
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
return ref.watch(hiveBoxMangaInfo).get(
|
||||
"${getSourceName()}/${getMangaName()}/${getChapterTitle()}-page_index",
|
||||
defaultValue: 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getPageLength() {
|
||||
final page = ref.watch(hiveBoxMangaInfo).get(
|
||||
"${getSourceName()}/${getMangaName()}/${getChapterTitle()}-pageurl",
|
||||
) as List;
|
||||
return page.length;
|
||||
int getPageLength(List incognitoPageLength) {
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
final page = ref.watch(hiveBoxMangaInfo).get(
|
||||
"${getSourceName()}/${getMangaName()}/${getChapterTitle()}-pageurl",
|
||||
) as List;
|
||||
return page.length;
|
||||
}
|
||||
return incognitoPageLength.length;
|
||||
}
|
||||
|
||||
void setPageIndex(int newIndex) {
|
||||
ref.watch(hiveBoxMangaInfo).put(
|
||||
"${getSourceName()}/${getMangaName()}/${getChapterTitle()}-page_index",
|
||||
newIndex);
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
ref.watch(hiveBoxMangaInfo).put(
|
||||
"${getSourceName()}/${getMangaName()}/${getChapterTitle()}-page_index",
|
||||
newIndex);
|
||||
}
|
||||
}
|
||||
|
||||
String getMangaName() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mangayomi/views/more/widgets/incognito_mode_widget.dart';
|
||||
import 'package:mangayomi/views/more/widgets/list_tile_widget.dart';
|
||||
|
||||
class MoreScreen extends StatelessWidget {
|
||||
const MoreScreen({super.key});
|
||||
|
|
@ -29,17 +31,7 @@ class MoreScreen extends StatelessWidget {
|
|||
// onChanged: (value) {},
|
||||
// ),
|
||||
// ),
|
||||
ListTile(
|
||||
onTap: () {},
|
||||
leading: const SizedBox(
|
||||
height: 40, child: Icon(CupertinoIcons.eyeglasses)),
|
||||
subtitle: const Text('pauses reading history'),
|
||||
title: const Text('Incognito mode'),
|
||||
trailing: Switch(
|
||||
value: false,
|
||||
onChanged: (value) {},
|
||||
),
|
||||
),
|
||||
const IncognitoModeWidget(),
|
||||
const Divider(
|
||||
color: Colors.grey,
|
||||
),
|
||||
|
|
@ -77,25 +69,22 @@ class MoreScreen extends StatelessWidget {
|
|||
// const Divider(
|
||||
// color: Colors.grey,
|
||||
// ),
|
||||
ListTile(
|
||||
ListTileWidget(
|
||||
onTap: () {
|
||||
context.push('/settings');
|
||||
},
|
||||
leading: const SizedBox(
|
||||
height: 40, child: Icon(Icons.settings_outlined)),
|
||||
title: const Text('Settings'),
|
||||
icon: Icons.settings_outlined,
|
||||
title: 'Settings',
|
||||
),
|
||||
ListTile(
|
||||
ListTileWidget(
|
||||
onTap: () {},
|
||||
leading: const SizedBox(
|
||||
height: 40, child: Icon(Icons.info_outline)),
|
||||
title: const Text('About'),
|
||||
icon: Icons.info_outline,
|
||||
title: 'About',
|
||||
),
|
||||
ListTile(
|
||||
ListTileWidget(
|
||||
onTap: () {},
|
||||
leading: const SizedBox(
|
||||
height: 40, child: Icon(Icons.help_outline)),
|
||||
title: const Text('Help'),
|
||||
icon: Icons.help_outline,
|
||||
title: 'Help',
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'blend_level_state_provider.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$blendLevelStateHash() => r'11d6ef7888230e249039d24cea788b3a9b4fb6e2';
|
||||
String _$blendLevelStateHash() => r'20a7e4e5cb5ff9d60bcf60c2c7e9b36584c3acb0';
|
||||
|
||||
/// See also [BlendLevelState].
|
||||
@ProviderFor(BlendLevelState)
|
||||
|
|
|
|||
|
|
@ -77,7 +77,14 @@ class _ThemeSelectorState extends ConsumerState<ThemeSelector> {
|
|||
optionButtonPadding: EdgeInsets.zero,
|
||||
optionButtonMargin: EdgeInsets.zero,
|
||||
),
|
||||
Text(ThemeAA.schemes[index].name)
|
||||
const SizedBox(
|
||||
height: 3,
|
||||
),
|
||||
Text(
|
||||
ThemeAA.schemes[index].name,
|
||||
style: const TextStyle(
|
||||
fontSize: 12, fontWeight: FontWeight.w300),
|
||||
)
|
||||
],
|
||||
),
|
||||
if (selected == index)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:mangayomi/providers/hive_provider.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'incognito_mode_state_provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
class IncognitoModeState extends _$IncognitoModeState {
|
||||
@override
|
||||
bool build() {
|
||||
return ref
|
||||
.watch(hiveBoxSettings)
|
||||
.get('incognitoMode', defaultValue: false)!;
|
||||
}
|
||||
|
||||
void setIncognitoMode(bool value) {
|
||||
state = value;
|
||||
ref.watch(hiveBoxSettings).put('incognitoMode', state);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'incognito_mode_state_provider.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$incognitoModeStateHash() =>
|
||||
r'614663075117c18594fda5884b79451ec77c3f1f';
|
||||
|
||||
/// See also [IncognitoModeState].
|
||||
@ProviderFor(IncognitoModeState)
|
||||
final incognitoModeStateProvider =
|
||||
AutoDisposeNotifierProvider<IncognitoModeState, bool>.internal(
|
||||
IncognitoModeState.new,
|
||||
name: r'incognitoModeStateProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$incognitoModeStateHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$IncognitoModeState = AutoDisposeNotifier<bool>;
|
||||
// ignore_for_file: unnecessary_raw_strings, subtype_of_sealed_class, invalid_use_of_internal_member, do_not_use_environment, prefer_const_constructors, public_member_api_docs, avoid_private_typedef_functions
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:flutter/src/widgets/placeholder.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mangayomi/views/more/widgets/list_tile_widget.dart';
|
||||
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
const SettingsScreen({super.key});
|
||||
|
|
@ -10,14 +9,14 @@ class SettingsScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Settings"),
|
||||
title: const Text("Settings"),
|
||||
actions: [],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text("Appearance"),
|
||||
leading: const Icon(Icons.color_lens_rounded),
|
||||
ListTileWidget(
|
||||
title: 'Appearance',
|
||||
icon: Icons.color_lens_rounded,
|
||||
onTap: () => context.push('/appearance')),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
32
lib/views/more/widgets/incognito_mode_widget.dart
Normal file
32
lib/views/more/widgets/incognito_mode_widget.dart
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mangayomi/views/more/settings/providers/incognito_mode_state_provider.dart';
|
||||
import 'package:mangayomi/views/more/widgets/list_tile_widget.dart';
|
||||
|
||||
class IncognitoModeWidget extends ConsumerWidget {
|
||||
const IncognitoModeWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
return ListTileWidget(
|
||||
onTap: () {
|
||||
if (incognitoMode == true) {
|
||||
ref.read(incognitoModeStateProvider.notifier).setIncognitoMode(false);
|
||||
} else {
|
||||
ref.read(incognitoModeStateProvider.notifier).setIncognitoMode(true);
|
||||
}
|
||||
},
|
||||
icon: CupertinoIcons.eyeglasses,
|
||||
subtitle: 'pauses reading history',
|
||||
title: 'Incognito mode',
|
||||
trailing: Switch(
|
||||
value: incognitoMode,
|
||||
onChanged: (value) {
|
||||
ref.read(incognitoModeStateProvider.notifier).setIncognitoMode(value);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
33
lib/views/more/widgets/list_tile_widget.dart
Normal file
33
lib/views/more/widgets/list_tile_widget.dart
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:mangayomi/utils/colors.dart';
|
||||
|
||||
class ListTileWidget extends StatelessWidget {
|
||||
final VoidCallback onTap;
|
||||
final String title;
|
||||
final IconData icon;
|
||||
final String? subtitle;
|
||||
final Widget? trailing;
|
||||
const ListTileWidget(
|
||||
{super.key,
|
||||
required this.onTap,
|
||||
required this.title,
|
||||
required this.icon,
|
||||
this.subtitle,
|
||||
this.trailing});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
onTap: onTap,
|
||||
subtitle: subtitle != null ? Text(subtitle!) : null,
|
||||
leading: SizedBox(
|
||||
height: 40,
|
||||
child: Icon(
|
||||
icon,
|
||||
color: generalColor(context),
|
||||
)),
|
||||
title: Text(title),
|
||||
trailing: trailing,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue