mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
feature: improve corner radius subtitle background (#298)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
72dde479c8
commit
71eab225f9
1 changed files with 9 additions and 8 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
|
@ -170,18 +171,18 @@ class SubtitleText extends ConsumerWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final fillScreen = ref.watch(videoPlayerSettingsProvider.select((value) => value.fillScreen));
|
final fillScreen = ref.watch(videoPlayerSettingsProvider.select((value) => value.fillScreen));
|
||||||
|
final fontSize = ref.read(subtitleSettingsProvider.select((value) => value.fontSize));
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: (fillScreen ? EdgeInsets.zero : EdgeInsets.only(left: padding.left, right: padding.right))
|
padding: (fillScreen ? EdgeInsets.zero : EdgeInsets.only(left: padding.left, right: padding.right))
|
||||||
.add(const EdgeInsets.all(16)),
|
.add(const EdgeInsets.all(16)),
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final textScale = MediaQuery.textScalerOf(context)
|
final textScale = MediaQuery.textScalerOf(context).scale((fontSize *
|
||||||
.scale((ref.read(subtitleSettingsProvider.select((value) => value.fontSize)) *
|
math.sqrt(
|
||||||
math.sqrt(
|
((constraints.maxWidth * constraints.maxHeight) /
|
||||||
((constraints.maxWidth * constraints.maxHeight) /
|
(kTextScaleFactorReferenceWidth * kTextScaleFactorReferenceHeight))
|
||||||
(kTextScaleFactorReferenceWidth * kTextScaleFactorReferenceHeight))
|
.clamp(0.0, 1.0),
|
||||||
.clamp(0.0, 1.0),
|
)));
|
||||||
)));
|
|
||||||
|
|
||||||
// Function to calculate the height of the text
|
// Function to calculate the height of the text
|
||||||
double getTextHeight(BuildContext context, String text, TextStyle style) {
|
double getTextHeight(BuildContext context, String text, TextStyle style) {
|
||||||
|
|
@ -221,7 +222,7 @@ class SubtitleText extends ConsumerWidget {
|
||||||
constraints: BoxConstraints(maxWidth: constraints.maxWidth, maxHeight: constraints.maxHeight),
|
constraints: BoxConstraints(maxWidth: constraints.maxWidth, maxHeight: constraints.maxHeight),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: subModel.backGroundColor,
|
color: subModel.backGroundColor,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(clampDouble(textScale / 10, 2, 12)),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue