added subtitle setting feature

This commit is contained in:
kodjomoustapha 2024-02-22 17:54:13 +01:00
parent 0660c0e6bb
commit 341486b004
5 changed files with 1443 additions and 66 deletions

View file

@ -167,6 +167,8 @@ class Settings {
late CustomColorFilter? customColorFilter;
late PlayerSubtitleSettings? playerSubtitleSettings;
bool? enableCustomColorFilter;
@enumerated
@ -247,7 +249,8 @@ class Settings {
this.fullScreenReader = true,
this.enableCustomColorFilter = false,
this.customColorFilter,
this.colorFilterBlendMode = ColorFilterBlendMode.none});
this.colorFilterBlendMode = ColorFilterBlendMode.none,
this.playerSubtitleSettings});
Settings.fromJson(Map<String, dynamic> json) {
animatePageTransitions = json['animatePageTransitions'];
@ -376,10 +379,16 @@ class Settings {
aniSkipTimeoutLength = json['aniSkipTimeoutLength'];
btServerAddress = json['btServerAddress'];
btServerPort = json['btServerPort'];
customColorFilter = json['customColorFilter'];
customColorFilter = json['customColorFilter'] != null
? CustomColorFilter.fromJson(json['customColorFilter'])
: null;
enableCustomColorFilter = json['enableCustomColorFilter'];
colorFilterBlendMode =
ColorFilterBlendMode.values[json['colorFilterBlendMode']];
playerSubtitleSettings = json['playerSubtitleSettings'] != null
? PlayerSubtitleSettings.fromJson(json['customColorFilter'])
: null;
}
Map<String, dynamic> toJson() => {
@ -477,9 +486,12 @@ class Settings {
'btServerAddress': btServerAddress,
'btServerPort': btServerPort,
'fullScreenReader': fullScreenReader,
'customColorFilter': customColorFilter,
if (customColorFilter != null)
'customColorFilter': customColorFilter!.toJson(),
'enableCustomColorFilter': enableCustomColorFilter,
'colorFilterBlendMode': colorFilterBlendMode.index
'colorFilterBlendMode': colorFilterBlendMode.index,
if (playerSubtitleSettings != null)
'playerSubtitleSettings': playerSubtitleSettings!.toJson(),
};
}
@ -714,6 +726,76 @@ class CustomColorFilter {
Map<String, dynamic> toJson() => {'a': a, 'r': r, 'g': g, 'b': b};
}
@embedded
class PlayerSubtitleSettings {
int? size;
bool? useBold;
bool? useItalic;
int? textColorA;
int? textColorR;
int? textColorG;
int? textColorB;
int? borderColorA;
int? borderColorR;
int? borderColorG;
int? borderColorB;
int? backgroundColorA;
int? backgroundColorR;
int? backgroundColorG;
int? backgroundColorB;
PlayerSubtitleSettings(
{this.size,
this.useBold,
this.useItalic,
this.textColorA,
this.textColorR,
this.textColorG,
this.textColorB,
this.borderColorA,
this.borderColorR,
this.borderColorG,
this.borderColorB,
this.backgroundColorA,
this.backgroundColorR,
this.backgroundColorG,
this.backgroundColorB});
PlayerSubtitleSettings.fromJson(Map<String, dynamic> json) {
size = json['size'];
useBold = json['useBold'];
useItalic = json['useItalic'];
textColorA = json['textColorA'];
textColorR = json['textColorR'];
textColorG = json['textColorG'];
textColorB = json['textColorB'];
borderColorA = json['borderColorA'];
borderColorR = json['borderColorR'];
borderColorG = json['borderColorG'];
borderColorB = json['borderColorB'];
backgroundColorA = json['backgroundColorA'];
backgroundColorR = json['backgroundColorR'];
backgroundColorG = json['backgroundColorG'];
backgroundColorB = json['backgroundColorB'];
}
Map<String, dynamic> toJson() => {
'size': size,
'useBold': useBold,
'useItalic': useItalic,
'textColorA': textColorA,
'textColorR': textColorR,
'textColorG': textColorG,
'textColorB': textColorB,
'borderColorA': borderColorA,
'borderColorR': borderColorR,
'borderColorG': borderColorG,
'borderColorB': borderColorB,
'backgroundColorA': backgroundColorA,
'backgroundColorR': backgroundColorR,
'backgroundColorG': backgroundColorG,
'backgroundColorB': backgroundColorB
};
}
enum ColorFilterBlendMode {
none,
multiply,

File diff suppressed because it is too large Load diff

View file

@ -918,7 +918,25 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
fontWeight: FontWeight.bold,
color: Colors.white,
fontFamily: "",
shadows: [Shadow(offset: Offset(0.2, 0.0), blurRadius: 7.0)],
shadows: [
Shadow(
// bottomLeft
offset: Offset(-2.5, -2.5),
color: Colors.black),
Shadow(
// bottomRight
offset: Offset(2.5, -2.5),
color: Colors.black),
Shadow(
// topRight
offset: Offset(2.5, 2.5),
color: Colors.black),
Shadow(
// topLeft
offset: Offset(-2.5, 2.5),
color: Colors.black),
Shadow(offset: Offset(0.2, 0.0), blurRadius: 9.0)
],
backgroundColor: Colors.transparent),
),
fit: fit,

View file

@ -7,7 +7,7 @@ part of 'color_filter_provider.dart';
// **************************************************************************
String _$customColorFilterStateHash() =>
r'b66789f6af4135d6f446d9cdc88ba58e73fde870';
r'5138b52d1465b1e0109b9757375e8ce4fbeb21d9';
/// See also [CustomColorFilterState].
@ProviderFor(CustomColorFilterState)

View file

@ -6,7 +6,7 @@ part of 'blend_level_state_provider.dart';
// RiverpodGenerator
// **************************************************************************
String _$blendLevelStateHash() => r'4928d5e9bc01d7ee9378458cd4d6a294248e10a4';
String _$blendLevelStateHash() => r'ceb7965073b2d6676a91acbe662bfa881f2f5e30';
/// See also [BlendLevelState].
@ProviderFor(BlendLevelState)