fix: Hide subtitles with empty text (#242)

Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
PartyDonut 2025-02-28 10:07:41 +01:00 committed by GitHub
parent 48b1e4a6fb
commit 3ca3d72b9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -209,43 +209,46 @@ class SubtitleText extends ConsumerWidget {
// Ensure the text doesn't go off-screen
position = position.clamp(0, availableHeight - textHeight);
return IgnorePointer(
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Positioned(
bottom: position,
child: Container(
constraints: BoxConstraints(maxWidth: constraints.maxWidth, maxHeight: constraints.maxHeight),
decoration: BoxDecoration(
color: subModel.backGroundColor,
borderRadius: BorderRadius.circular(16),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
text,
style: subModel.backGroundStyle.copyWith(fontSize: textScale),
textAlign: TextAlign.center,
return Visibility(
visible: text.isEmpty ? false : true,
child: IgnorePointer(
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Positioned(
bottom: position,
child: Container(
constraints: BoxConstraints(maxWidth: constraints.maxWidth, maxHeight: constraints.maxHeight),
decoration: BoxDecoration(
color: subModel.backGroundColor,
borderRadius: BorderRadius.circular(16),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
text,
style: subModel.backGroundStyle.copyWith(fontSize: textScale),
textAlign: TextAlign.center,
),
),
),
),
),
Positioned(
bottom: position,
child: Container(
constraints: BoxConstraints(maxWidth: constraints.maxWidth, maxHeight: constraints.maxHeight),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
text,
style: subModel.style.copyWith(fontSize: textScale),
textAlign: TextAlign.center,
Positioned(
bottom: position,
child: Container(
constraints: BoxConstraints(maxWidth: constraints.maxWidth, maxHeight: constraints.maxHeight),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
text,
style: subModel.style.copyWith(fontSize: textScale),
textAlign: TextAlign.center,
),
),
),
),
)
],
)
],
),
),
);
},