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:math' as math;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
|
@ -170,18 +171,18 @@ class SubtitleText extends ConsumerWidget {
|
|||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final fillScreen = ref.watch(videoPlayerSettingsProvider.select((value) => value.fillScreen));
|
||||
final fontSize = ref.read(subtitleSettingsProvider.select((value) => value.fontSize));
|
||||
return Padding(
|
||||
padding: (fillScreen ? EdgeInsets.zero : EdgeInsets.only(left: padding.left, right: padding.right))
|
||||
.add(const EdgeInsets.all(16)),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final textScale = MediaQuery.textScalerOf(context)
|
||||
.scale((ref.read(subtitleSettingsProvider.select((value) => value.fontSize)) *
|
||||
math.sqrt(
|
||||
((constraints.maxWidth * constraints.maxHeight) /
|
||||
(kTextScaleFactorReferenceWidth * kTextScaleFactorReferenceHeight))
|
||||
.clamp(0.0, 1.0),
|
||||
)));
|
||||
final textScale = MediaQuery.textScalerOf(context).scale((fontSize *
|
||||
math.sqrt(
|
||||
((constraints.maxWidth * constraints.maxHeight) /
|
||||
(kTextScaleFactorReferenceWidth * kTextScaleFactorReferenceHeight))
|
||||
.clamp(0.0, 1.0),
|
||||
)));
|
||||
|
||||
// Function to calculate the height of the text
|
||||
double getTextHeight(BuildContext context, String text, TextStyle style) {
|
||||
|
|
@ -221,7 +222,7 @@ class SubtitleText extends ConsumerWidget {
|
|||
constraints: BoxConstraints(maxWidth: constraints.maxWidth, maxHeight: constraints.maxHeight),
|
||||
decoration: BoxDecoration(
|
||||
color: subModel.backGroundColor,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderRadius: BorderRadius.circular(clampDouble(textScale / 10, 2, 12)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue