Implemented text scroll to chapter/episode list

title text scroll (like a marquee effect) when the chapter/episode name is too long.
This commit is contained in:
Enbiya Olgun 2025-04-21 22:47:23 +02:00
parent ef4abc47f2
commit 6d99d9a690
3 changed files with 55 additions and 7 deletions

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:marquee/marquee.dart';
import 'package:mangayomi/models/chapter.dart';
import 'package:mangayomi/models/manga.dart';
import 'package:mangayomi/providers/l10n_providers.dart';
@ -64,13 +65,7 @@ class ChapterListTileWidget extends ConsumerWidget {
chapter.isBookmarked!
? Icon(Icons.bookmark, size: 16, color: context.primaryColor)
: Container(),
Flexible(
child: Text(
chapter.name!,
style: const TextStyle(fontSize: 13),
overflow: TextOverflow.ellipsis,
),
),
Flexible(child: _buildTitle(chapter.name!, context)),
],
),
subtitle: Row(
@ -141,4 +136,40 @@ class ChapterListTileWidget extends ConsumerWidget {
),
);
}
Widget _buildTitle(String text, BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
final textPainter = TextPainter(
text: TextSpan(text: text, style: const TextStyle(fontSize: 13)),
maxLines: 1,
textDirection: TextDirection.ltr,
)..layout(
maxWidth: (constraints.maxWidth - (35 + 5)),
); // - Download icon size (download_page_widget.dart, Widget Build SizedBox width: 35)
final isOverflowing = textPainter.didExceedMaxLines;
if (isOverflowing) {
return SizedBox(
height: 20,
child: Marquee(
text: text,
style: const TextStyle(fontSize: 13),
blankSpace: 40.0,
velocity: 30.0,
pauseAfterRound: const Duration(seconds: 1),
startPadding: 10.0,
),
);
} else {
return Text(
text,
style: const TextStyle(fontSize: 13),
overflow: TextOverflow.ellipsis,
);
}
},
);
}
}

View file

@ -479,6 +479,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.6"
fading_edge_scrollview:
dependency: transitive
description:
name: fading_edge_scrollview
sha256: "1f84fe3ea8e251d00d5735e27502a6a250e4aa3d3b330d3fdcb475af741464ef"
url: "https://pub.dev"
source: hosted
version: "4.1.1"
fake_async:
dependency: transitive
description:
@ -1117,6 +1125,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.3-main.0"
marquee:
dependency: "direct main"
description:
name: marquee
sha256: a87e7e80c5d21434f90ad92add9f820cf68be374b226404fe881d2bba7be0862
url: "https://pub.dev"
source: hosted
version: "2.3.0"
matcher:
dependency: transitive
description:

View file

@ -81,6 +81,7 @@ dependencies:
protobuf: ^3.1.0
device_info_plus: ^11.3.3
flutter_app_installer: ^1.0.0
marquee: ^2.2.3
dependency_overrides:
ffi: ^2.1.3