Add Tap zones setting #54 , Fix #55 Fullscreen issue when watching local anime

This commit is contained in:
kodjomoustapha 2023-11-27 20:43:48 +01:00
parent 08de8e3d57
commit 0ca453bc7d
12 changed files with 254 additions and 106 deletions

View file

@ -260,6 +260,7 @@
"weekly":"Weekly",
"restore_backup_warning_title":"Restoring a backup will overwrite all existing data.\n\nContinue restoring?",
"services":"Services",
"tracking_warning_info":"One-way sync yo update the chapter progress in tracking services. Set up tracking for individual entries from their tracking button."
"tracking_warning_info":"One-way sync yo update the chapter progress in tracking services. Set up tracking for individual entries from their tracking button.",
"use_page_tap_zones":"Use page tap zones"
}

View file

@ -260,5 +260,6 @@
"weekly":"Chaque semaine",
"restore_backup_warning_title":"La restauration d'une sauvegarde écrasera toutes les données existantes.\n\nContinuer la restauration ?",
"services":"Services",
"tracking_warning_info":"Synchronisation à sens unique pour mettre à jour la progression du chapitre dans les services de suivi. Configurez le suivi des entrées individuelles à partir de leur boutton de suivi."
"tracking_warning_info":"Synchronisation à sens unique pour mettre à jour la progression du chapitre dans les services de suivi. Configurez le suivi des entrées individuelles à partir de leur boutton de suivi.",
"use_page_tap_zones":"Utiliser les zones tactiles"
}

View file

@ -139,6 +139,8 @@ class Settings {
String? autoBackupLocation;
bool? usePageTapZones;
Settings(
{this.id = 227,
this.displayType = DisplayType.compactGrid,
@ -198,7 +200,8 @@ class Settings {
this.backupFrequency,
this.backupFrequencyOptions,
this.autoBackupLocation,
this.startDatebackup});
this.startDatebackup,
this.usePageTapZones = true});
Settings.fromJson(Map<String, dynamic> json) {
animatePageTransitions = json['animatePageTransitions'];
@ -310,6 +313,7 @@ class Settings {
backupFrequencyOptions = json['backupFrequencyOptions']?.cast<int>();
autoBackupLocation = json['autoBackupLocation'];
startDatebackup = json['startDatebackup'];
usePageTapZones = json['usePageTapZones'];
}
Map<String, dynamic> toJson() {
@ -407,6 +411,7 @@ class Settings {
data['backupFrequencyOptions'] = backupFrequencyOptions;
data['autoBackupLocation'] = autoBackupLocation;
data['startDatebackup'] = startDatebackup;
data['usePageTapZones'] = usePageTapZones;
return data;
}
}

View file

@ -340,8 +340,13 @@ const SettingsSchema = CollectionSchema(
name: r'themeIsDark',
type: IsarType.bool,
),
r'userAgent': PropertySchema(
r'usePageTapZones': PropertySchema(
id: 61,
name: r'usePageTapZones',
type: IsarType.bool,
),
r'userAgent': PropertySchema(
id: 62,
name: r'userAgent',
type: IsarType.string,
)
@ -714,7 +719,8 @@ void _settingsSerialize(
);
writer.writeLong(offsets[59], object.startDatebackup);
writer.writeBool(offsets[60], object.themeIsDark);
writer.writeString(offsets[61], object.userAgent);
writer.writeBool(offsets[61], object.usePageTapZones);
writer.writeString(offsets[62], object.userAgent);
}
Settings _settingsDeserialize(
@ -835,7 +841,8 @@ Settings _settingsDeserialize(
),
startDatebackup: reader.readLongOrNull(offsets[59]),
themeIsDark: reader.readBoolOrNull(offsets[60]),
userAgent: reader.readStringOrNull(offsets[61]),
usePageTapZones: reader.readBoolOrNull(offsets[61]),
userAgent: reader.readStringOrNull(offsets[62]),
);
object.chapterFilterBookmarkedList =
reader.readObjectList<ChapterFilterBookmarked>(
@ -1064,6 +1071,8 @@ P _settingsDeserializeProp<P>(
case 60:
return (reader.readBoolOrNull(offset)) as P;
case 61:
return (reader.readBoolOrNull(offset)) as P;
case 62:
return (reader.readStringOrNull(offset)) as P;
default:
throw IsarError('Unknown property with id $propertyId');
@ -5097,6 +5106,34 @@ extension SettingsQueryFilter
});
}
QueryBuilder<Settings, Settings, QAfterFilterCondition>
usePageTapZonesIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNull(
property: r'usePageTapZones',
));
});
}
QueryBuilder<Settings, Settings, QAfterFilterCondition>
usePageTapZonesIsNotNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNotNull(
property: r'usePageTapZones',
));
});
}
QueryBuilder<Settings, Settings, QAfterFilterCondition>
usePageTapZonesEqualTo(bool? value) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'usePageTapZones',
value: value,
));
});
}
QueryBuilder<Settings, Settings, QAfterFilterCondition> userAgentIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNull(
@ -6021,6 +6058,18 @@ extension SettingsQuerySortBy on QueryBuilder<Settings, Settings, QSortBy> {
});
}
QueryBuilder<Settings, Settings, QAfterSortBy> sortByUsePageTapZones() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'usePageTapZones', Sort.asc);
});
}
QueryBuilder<Settings, Settings, QAfterSortBy> sortByUsePageTapZonesDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'usePageTapZones', Sort.desc);
});
}
QueryBuilder<Settings, Settings, QAfterSortBy> sortByUserAgent() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'userAgent', Sort.asc);
@ -6667,6 +6716,18 @@ extension SettingsQuerySortThenBy
});
}
QueryBuilder<Settings, Settings, QAfterSortBy> thenByUsePageTapZones() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'usePageTapZones', Sort.asc);
});
}
QueryBuilder<Settings, Settings, QAfterSortBy> thenByUsePageTapZonesDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'usePageTapZones', Sort.desc);
});
}
QueryBuilder<Settings, Settings, QAfterSortBy> thenByUserAgent() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'userAgent', Sort.asc);
@ -7000,6 +7061,12 @@ extension SettingsQueryWhereDistinct
});
}
QueryBuilder<Settings, Settings, QDistinct> distinctByUsePageTapZones() {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'usePageTapZones');
});
}
QueryBuilder<Settings, Settings, QDistinct> distinctByUserAgent(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
@ -7425,6 +7492,12 @@ extension SettingsQueryProperty
});
}
QueryBuilder<Settings, bool?, QQueryOperations> usePageTapZonesProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'usePageTapZones');
});
}
QueryBuilder<Settings, String?, QQueryOperations> userAgentProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'userAgent');

View file

@ -41,10 +41,6 @@ class _AnimePlayerViewState extends riv.ConsumerState<AnimePlayerView> {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky,
overlays: []);
final serversData = ref.watch(getVideoListProvider(
episode: widget.episode,
));
@ -576,12 +572,13 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage> {
}),
if (!isFullScreen)
IconButton(
icon: const Icon(Icons.fit_screen_sharp,
icon: const Icon(Icons.fit_screen_outlined,
size: 25, color: Colors.white),
onPressed: () async {
_changeFitLabel(ref);
},
),
const MaterialFullscreenButton(iconSize: 25)
],
),
],
@ -637,38 +634,37 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (_isDesktop)
Row(
children: [
if (hasPrevEpisode)
IconButton(
onPressed: () {
pushReplacementMangaReaderView(
context: context,
chapter: _streamController.getPrevEpisode());
},
icon: const Icon(
Icons.skip_previous,
size: 25,
color: Colors.white,
),
),
const MaterialDesktopPlayOrPauseButton(iconSize: 25),
if (hasNextEpisode)
IconButton(
onPressed: () {
pushReplacementMangaReaderView(
Row(
children: [
if (hasPrevEpisode)
IconButton(
onPressed: () {
pushReplacementMangaReaderView(
context: context,
chapter: _streamController.getNextEpisode(),
);
},
icon: const Icon(Icons.skip_next,
size: 25, color: Colors.white),
chapter: _streamController.getPrevEpisode());
},
icon: const Icon(
Icons.skip_previous,
size: 25,
color: Colors.white,
),
const MaterialDesktopVolumeButton(iconSize: 25),
const MaterialDesktopPositionIndicator()
],
),
),
const MaterialDesktopPlayOrPauseButton(iconSize: 25),
if (hasNextEpisode)
IconButton(
onPressed: () {
pushReplacementMangaReaderView(
context: context,
chapter: _streamController.getNextEpisode(),
);
},
icon: const Icon(Icons.skip_next,
size: 25, color: Colors.white),
),
const MaterialDesktopVolumeButton(iconSize: 25),
const MaterialDesktopPositionIndicator()
],
),
Row(
children: [
if (!isFullScreen)
@ -701,8 +697,7 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage> {
_changeFitLabel(ref);
},
),
if (_isDesktop)
const MaterialDesktopFullscreenButton(iconSize: 25)
const MaterialDesktopFullscreenButton(iconSize: 25)
],
),
],

View file

@ -38,6 +38,7 @@ class ImageViewCenter extends ConsumerWidget {
return isLocale
? archiveImage != null
? ExtendedImage.memory(archiveImage,
filterQuality: FilterQuality.medium,
fit: getBoxFit(scaleType),
clearMemoryCacheWhenDispose: true,
enableMemoryCache: false,
@ -46,6 +47,7 @@ class ImageViewCenter extends ConsumerWidget {
onDoubleTap: onDoubleTap)
: ExtendedImage.file(
File("${datas.path!.path}" "${padIndex(datas.index! + 1)}.jpg"),
filterQuality: FilterQuality.medium,
fit: getBoxFit(scaleType),
clearMemoryCacheWhenDispose: true,
enableMemoryCache: false,
@ -54,6 +56,7 @@ class ImageViewCenter extends ConsumerWidget {
onDoubleTap: onDoubleTap)
: ExtendedImage.network(datas.url!.trim().trimLeft().trimRight(),
fit: getBoxFit(scaleType),
filterQuality: FilterQuality.medium,
headers: ref.watch(headersProvider(
source: datas.chapter!.manga.value!.source!,
lang: datas.chapter!.manga.value!.lang!)),

View file

@ -48,7 +48,8 @@ class ImageViewVertical extends ConsumerWidget {
? archiveImage != null
? ExtendedImage.memory(archiveImage,
fit: getBoxFit(scaleType),
enableMemoryCache: false,
filterQuality: FilterQuality.medium,
enableMemoryCache: true,
enableLoadState: true, loadStateChanged: (state) {
if (state.extendedImageLoadState == LoadState.loading) {
return Container(
@ -60,7 +61,8 @@ class ImageViewVertical extends ConsumerWidget {
})
: ExtendedImage.file(
fit: getBoxFit(scaleType),
enableMemoryCache: false,
enableMemoryCache: true,
filterQuality: FilterQuality.medium,
File(
'${datas.path!.path}${padIndex(datas.index! + 1)}.jpg'),
enableLoadState: true, loadStateChanged: (state) {
@ -73,6 +75,7 @@ class ImageViewVertical extends ConsumerWidget {
return null;
})
: ExtendedImage.network(datas.url!.trim().trimLeft().trimRight(),
filterQuality: FilterQuality.medium,
headers: ref.watch(headersProvider(
source: datas.chapter!.manga.value!.source!,
lang: datas.chapter!.manga.value!.lang!)),

View file

@ -257,6 +257,7 @@ class _MangaChapterPageGalleryState
_processCropBorders();
final backgroundColor = ref.watch(backgroundColorStateProvider);
final cropBorders = ref.watch(cropBordersStateProvider);
final usePageTapZones = ref.watch(usePageTapZonesStateProvider);
final l10n = l10nLocalizations(context)!;
return WillPopScope(
onWillPop: () async {
@ -653,8 +654,8 @@ class _MangaChapterPageGalleryState
},
itemCount: _uChapDataPreload.length,
onPageChanged: _onPageChanged)),
_gestureRightLeft(failedToLoadImage),
_gestureTopBottom(failedToLoadImage),
_gestureRightLeft(failedToLoadImage, usePageTapZones),
_gestureTopBottom(failedToLoadImage, usePageTapZones),
_showMore(),
_showPage(),
],
@ -1565,7 +1566,7 @@ class _MangaChapterPageGalleryState
return !(index * 2 < pageLength) ? pageLength - 1 : index1 - 1;
}
Widget _gestureRightLeft(bool failedToLoadImage) {
Widget _gestureRightLeft(bool failedToLoadImage, bool usePageTapZones) {
return Consumer(
builder: (context, ref, child) {
return Row(
@ -1575,13 +1576,15 @@ class _MangaChapterPageGalleryState
flex: 2,
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
if (_isReverseHorizontal) {
_onBtnTapped(_currentIndex! + 1, false);
} else {
_onBtnTapped(_currentIndex! - 1, true);
}
},
onTap: usePageTapZones
? () {
if (_isReverseHorizontal) {
_onBtnTapped(_currentIndex! + 1, false);
} else {
_onBtnTapped(_currentIndex! - 1, true);
}
}
: null,
onDoubleTapDown: _isVerticalContinous()
? (TapDownDetails details) {
_toggleScale(details.globalPosition);
@ -1618,13 +1621,15 @@ class _MangaChapterPageGalleryState
flex: 2,
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
if (_isReverseHorizontal) {
_onBtnTapped(_currentIndex! - 1, true);
} else {
_onBtnTapped(_currentIndex! + 1, false);
}
},
onTap: usePageTapZones
? () {
if (_isReverseHorizontal) {
_onBtnTapped(_currentIndex! - 1, true);
} else {
_onBtnTapped(_currentIndex! + 1, false);
}
}
: null,
onDoubleTapDown: _isVerticalContinous()
? (TapDownDetails details) {
_toggleScale(details.globalPosition);
@ -1639,7 +1644,7 @@ class _MangaChapterPageGalleryState
);
}
Widget _gestureTopBottom(bool failedToLoadImage) {
Widget _gestureTopBottom(bool failedToLoadImage, bool usePageTapZones) {
return Consumer(
builder: (context, ref, child) {
return Column(
@ -1652,7 +1657,9 @@ class _MangaChapterPageGalleryState
onTap: () {
failedToLoadImage
? _isViewFunction()
: _onBtnTapped(_currentIndex! - 1, true);
: usePageTapZones
? _onBtnTapped(_currentIndex! - 1, true)
: null;
},
onDoubleTapDown: _isVerticalContinous()
? (TapDownDetails details) {
@ -1674,7 +1681,9 @@ class _MangaChapterPageGalleryState
onTap: () {
failedToLoadImage
? _isViewFunction()
: _onBtnTapped(_currentIndex! + 1, false);
: usePageTapZones
? _onBtnTapped(_currentIndex! + 1, false)
: null;
},
onDoubleTapDown: _isVerticalContinous()
? (TapDownDetails details) {
@ -1696,7 +1705,7 @@ class _MangaChapterPageGalleryState
readerMode == ReaderMode.webtoon;
}
_showModalSettings() {
void _showModalSettings() {
final l10n = l10nLocalizations(context)!;
late TabController tabBarController;
tabBarController = TabController(length: 3, vsync: this);
@ -1732,6 +1741,8 @@ class _MangaChapterPageGalleryState
children: [
Consumer(builder: (context, ref, chil) {
final readerMode = ref.watch(_currentReaderMode);
final usePageTapZones =
ref.watch(usePageTapZonesStateProvider);
final cropBorders =
ref.watch(cropBordersStateProvider);
@ -1775,6 +1786,22 @@ class _MangaChapterPageGalleryState
.notifier)
.set(value);
}),
SwitchListTile(
value: usePageTapZones,
title: Text(l10n.use_page_tap_zones,
style: TextStyle(
color: Theme.of(context)
.textTheme
.bodyLarge!
.color!
.withOpacity(0.9),
fontSize: 14)),
onChanged: (value) {
ref
.read(usePageTapZonesStateProvider
.notifier)
.set(value);
}),
],
),
),

View file

@ -107,3 +107,18 @@ class BackgroundColorState extends _$BackgroundColorState {
() => isar.settings.putSync(settings!..backgroundColor = value));
}
}
@riverpod
class UsePageTapZonesState extends _$UsePageTapZonesState {
@override
bool build() {
return isar.settings.getSync(227)!.usePageTapZones ?? true;
}
void set(bool value) {
final settings = isar.settings.getSync(227);
state = value;
isar.writeTxnSync(
() => isar.settings.putSync(settings!..usePageTapZones = value));
}
}

View file

@ -123,5 +123,22 @@ final backgroundColorStateProvider =
);
typedef _$BackgroundColorState = AutoDisposeNotifier<BackgroundColor>;
String _$usePageTapZonesStateHash() =>
r'476a7831ca38386e6cd9c83e7c8943f1f4ba20b7';
/// See also [UsePageTapZonesState].
@ProviderFor(UsePageTapZonesState)
final usePageTapZonesStateProvider =
AutoDisposeNotifierProvider<UsePageTapZonesState, bool>.internal(
UsePageTapZonesState.new,
name: r'usePageTapZonesStateProvider',
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
? null
: _$usePageTapZonesStateHash,
dependencies: null,
allTransitiveDependencies: null,
);
typedef _$UsePageTapZonesState = AutoDisposeNotifier<bool>;
// ignore_for_file: type=lint
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member

View file

@ -11,7 +11,6 @@ class ReaderScreen extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final l10n = l10nLocalizations(context);
final defaultReadingMode = ref.watch(defaultReadingModeStateProvider);
final animatePageTransitions =
ref.watch(animatePageTransitionsStateProvider);
@ -21,9 +20,10 @@ class ReaderScreen extends ConsumerWidget {
final pagePreloadAmount = ref.watch(pagePreloadAmountStateProvider);
final scaleType = ref.watch(scaleTypeStateProvider);
final backgroundColor = ref.watch(backgroundColorStateProvider);
final usePageTapZones = ref.watch(usePageTapZonesStateProvider);
return Scaffold(
appBar: AppBar(
title: Text(l10n!.reader),
title: Text(context.l10n.reader),
),
body: SingleChildScrollView(
child: Column(
@ -34,7 +34,7 @@ class ReaderScreen extends ConsumerWidget {
context: context,
builder: (context) {
return AlertDialog(
title: Text(l10n.default_reading_mode),
title: Text(context.l10n.default_reading_mode),
content: SizedBox(
width: mediaWidth(context, 0.8),
child: ListView.builder(
@ -71,7 +71,7 @@ class ReaderScreen extends ConsumerWidget {
Navigator.pop(context);
},
child: Text(
l10n.cancel,
context.l10n.cancel,
style:
TextStyle(color: primaryColor(context)),
)),
@ -81,7 +81,7 @@ class ReaderScreen extends ConsumerWidget {
);
});
},
title: Text(l10n.default_reading_mode),
title: Text(context.l10n.default_reading_mode),
subtitle: Text(
getReaderModeName(defaultReadingMode, context),
style: TextStyle(fontSize: 11, color: secondaryColor(context)),
@ -94,7 +94,7 @@ class ReaderScreen extends ConsumerWidget {
builder: (context) {
return AlertDialog(
title: Text(
l10n.double_tap_animation_speed,
context.l10n.double_tap_animation_speed,
),
content: SizedBox(
width: mediaWidth(context, 0.8),
@ -133,7 +133,7 @@ class ReaderScreen extends ConsumerWidget {
Navigator.pop(context);
},
child: Text(
l10n.cancel,
context.l10n.cancel,
style:
TextStyle(color: primaryColor(context)),
)),
@ -143,7 +143,7 @@ class ReaderScreen extends ConsumerWidget {
);
});
},
title: Text(l10n.double_tap_animation_speed),
title: Text(context.l10n.double_tap_animation_speed),
subtitle: Text(
getAnimationSpeedName(doubleTapAnimationSpeed, context),
style: TextStyle(fontSize: 11, color: secondaryColor(context)),
@ -155,7 +155,7 @@ class ReaderScreen extends ConsumerWidget {
context: context,
builder: (context) {
return AlertDialog(
title: Text(l10n.background_color),
title: Text(context.l10n.background_color),
content: SizedBox(
width: mediaWidth(context, 0.8),
child: ListView.builder(
@ -193,7 +193,7 @@ class ReaderScreen extends ConsumerWidget {
Navigator.pop(context);
},
child: Text(
l10n.cancel,
context.l10n.cancel,
style:
TextStyle(color: primaryColor(context)),
)),
@ -203,7 +203,7 @@ class ReaderScreen extends ConsumerWidget {
);
});
},
title: Text(l10n.background_color),
title: Text(context.l10n.background_color),
subtitle: Text(
getBackgroundColorName(backgroundColor, context),
style: TextStyle(fontSize: 11, color: secondaryColor(context)),
@ -217,7 +217,7 @@ class ReaderScreen extends ConsumerWidget {
builder: (context) {
return AlertDialog(
title: Text(
l10n.page_preload_amount,
context.l10n.page_preload_amount,
),
content: SizedBox(
width: mediaWidth(context, 0.8),
@ -252,7 +252,7 @@ class ReaderScreen extends ConsumerWidget {
Navigator.pop(context);
},
child: Text(
l10n.cancel,
context.l10n.cancel,
style:
TextStyle(color: primaryColor(context)),
)),
@ -262,9 +262,9 @@ class ReaderScreen extends ConsumerWidget {
);
});
},
title: Text(l10n.page_preload_amount),
title: Text(context.l10n.page_preload_amount),
subtitle: Text(
l10n.page_preload_amount_subtitle,
context.l10n.page_preload_amount_subtitle,
style: TextStyle(fontSize: 11, color: secondaryColor(context)),
),
),
@ -275,7 +275,7 @@ class ReaderScreen extends ConsumerWidget {
builder: (context) {
return AlertDialog(
title: Text(
l10n.scale_type,
context.l10n.scale_type,
),
content: SizedBox(
width: mediaWidth(context, 0.8),
@ -312,7 +312,7 @@ class ReaderScreen extends ConsumerWidget {
Navigator.pop(context);
},
child: Text(
l10n.cancel,
context.l10n.cancel,
style:
TextStyle(color: primaryColor(context)),
)),
@ -322,7 +322,7 @@ class ReaderScreen extends ConsumerWidget {
);
});
},
title: Text(l10n.scale_type),
title: Text(context.l10n.scale_type),
subtitle: Text(
getScaleTypeNames(context)[scaleType.index],
style: TextStyle(fontSize: 11, color: secondaryColor(context)),
@ -330,7 +330,7 @@ class ReaderScreen extends ConsumerWidget {
),
SwitchListTile(
value: animatePageTransitions,
title: Text(l10n.animate_page_transitions),
title: Text(context.l10n.animate_page_transitions),
onChanged: (value) {
ref
.read(animatePageTransitionsStateProvider.notifier)
@ -338,10 +338,16 @@ class ReaderScreen extends ConsumerWidget {
}),
SwitchListTile(
value: cropBorders,
title: Text(l10n.crop_borders),
title: Text(context.l10n.crop_borders),
onChanged: (value) {
ref.read(cropBordersStateProvider.notifier).set(value);
}),
SwitchListTile(
value: usePageTapZones,
title: Text(context.l10n.use_page_tap_zones),
onChanged: (value) {
ref.read(usePageTapZonesStateProvider.notifier).set(value);
}),
],
),
),
@ -350,24 +356,23 @@ class ReaderScreen extends ConsumerWidget {
}
String getReaderModeName(ReaderMode readerMode, BuildContext context) {
final l10n = l10nLocalizations(context);
return switch (readerMode) {
ReaderMode.vertical => l10n!.reading_mode_vertical,
ReaderMode.verticalContinuous => l10n!.reading_mode_vertical_continuous,
ReaderMode.ltr => l10n!.reading_mode_left_to_right,
ReaderMode.rtl => l10n!.reading_mode_right_to_left,
_ => l10n!.reading_mode_webtoon
ReaderMode.vertical => context.l10n.reading_mode_vertical,
ReaderMode.verticalContinuous =>
context.l10n.reading_mode_vertical_continuous,
ReaderMode.ltr => context.l10n.reading_mode_left_to_right,
ReaderMode.rtl => context.l10n.reading_mode_right_to_left,
_ => context.l10n.reading_mode_webtoon
};
}
String getBackgroundColorName(
BackgroundColor backgroundColor, BuildContext context) {
final l10n = l10nLocalizations(context)!;
return switch (backgroundColor) {
BackgroundColor.white => l10n.white,
BackgroundColor.grey => l10n.grey,
BackgroundColor.black => l10n.black,
_ => l10n.automaic,
BackgroundColor.white => context.l10n.white,
BackgroundColor.grey => context.l10n.grey,
BackgroundColor.black => context.l10n.black,
_ => context.l10n.automaic,
};
}
@ -381,21 +386,20 @@ Color? getBackgroundColor(BackgroundColor backgroundColor) {
}
String getAnimationSpeedName(int type, BuildContext context) {
final l10n = l10nLocalizations(context);
return switch (type) {
0 => l10n!.no_animation,
1 => l10n!.normal,
_ => l10n!.fast,
0 => context.l10n.no_animation,
1 => context.l10n.normal,
_ => context.l10n.fast,
};
}
List<String> getScaleTypeNames(BuildContext context) {
final l10n = l10nLocalizations(context)!;
return [
l10n.scale_type_fit_screen,
l10n.scale_type_stretch,
l10n.scale_type_fit_width,
l10n.scale_type_fit_height,
context.l10n.scale_type_fit_screen,
context.l10n.scale_type_stretch,
context.l10n.scale_type_fit_width,
context.l10n.scale_type_fit_height,
// l10n.scale_type_original_size,
// l10n.scale_type_smart_fit,
];

View file

@ -35,3 +35,7 @@ AppLocalizations? l10nLocalizations(BuildContext context) =>
Locale currentLocale(BuildContext context) {
return Localizations.localeOf(context);
}
extension L10nExtension on BuildContext {
AppLocalizations get l10n => AppLocalizations.of(this)!;
}