fix(flutter): 首页 feed 静默刷新与进度条细节
This commit is contained in:
1 parent
a3126723d2
commit
82fe237c24
8 files changed
+190
-17
No files matched your search
@@ -44,6 +44,19 @@ class CatalogController extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// 静默刷新首页聚合:成功替换数据,失败返回 false。
|
||||
///
|
||||
/// 不触碰 [loading]/[error],因此页面不会切到全屏 loading 或清空旧数据。
|
||||
Future<bool> refresh() async {
|
||||
try {
|
||||
feed = await repository.fetchHomeFeed();
|
||||
notifyListeners();
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// 需要完整剧集时补一次详情;已加载过则直接返回,避免重复请求。
|
||||
Future<Drama> requireDetail(Drama drama) async {
|
||||
if (drama.detailLoaded) return drama;
|
||||
|
||||
@@ -71,7 +71,7 @@ class HomePage extends StatelessWidget {
|
||||
return _HomeTabs(
|
||||
key: ValueKey(catalog.dramas.first.id),
|
||||
dramas: catalog.dramas,
|
||||
onRefreshFeed: catalog.load,
|
||||
onRefreshFeed: catalog.refresh,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class _HomeTabs extends StatefulWidget {
|
||||
});
|
||||
|
||||
final List<Drama> dramas;
|
||||
final VoidCallback onRefreshFeed;
|
||||
final Future<bool> Function() onRefreshFeed;
|
||||
|
||||
@override
|
||||
State<_HomeTabs> createState() => _HomeTabsState();
|
||||
|
||||
@@ -76,7 +76,7 @@ class PlayerPage extends StatefulWidget {
|
||||
final ValueChanged<Drama>? onDramaChanged;
|
||||
final ValueChanged<bool>? onImmersiveChanged;
|
||||
final Future<void> Function(Drama drama, Episode episode)? onOpenFullPlayer;
|
||||
final VoidCallback? onRefreshFeed;
|
||||
final Future<bool> Function()? onRefreshFeed;
|
||||
final WalletController? wallet;
|
||||
final DownloadController? downloads;
|
||||
|
||||
@@ -420,7 +420,13 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
|
||||
if (!mounted || !widget.active) return;
|
||||
logic.session.setUserWantsPlay(true);
|
||||
},
|
||||
onRefreshFeed: () => widget.onRefreshFeed?.call(),
|
||||
onRefreshFeed: () async {
|
||||
final ok = await widget.onRefreshFeed?.call() ?? true;
|
||||
if (!context.mounted || ok) return;
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(l10n.catalogError)));
|
||||
},
|
||||
onDownload: () => requestEpisodeDownload(context, episode.id),
|
||||
onClear: () => setState(() => _chromeVisible = false),
|
||||
onSearch:
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'interaction_rail.dart';
|
||||
part 'home_feed_overlay_parts.dart';
|
||||
|
||||
const Color _overlayPill = Color(0x66000000);
|
||||
const Color _fullBarBackground = Color(0x4D000000);
|
||||
const double _topIconSize = 36;
|
||||
const double _topIconGlyph = 22;
|
||||
const double _tabGap = 22;
|
||||
@@ -25,7 +26,7 @@ const double _metaFontSize = 12;
|
||||
const double _tagFontSize = 11;
|
||||
const double _fullBarHeight = 44;
|
||||
const double _progressHeight = 2;
|
||||
const double _progressHitHeight = 20;
|
||||
const double _progressHitHeight = 24;
|
||||
const int _maxTags = 4;
|
||||
final RegExp _tagSplitter = RegExp(r'[,/、·]');
|
||||
|
||||
@@ -100,7 +101,7 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
||||
_header(context),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: const Alignment(1.0, 0.45),
|
||||
alignment: const Alignment(1.0, 0.68),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 0, 10, 16),
|
||||
child: _rail(),
|
||||
@@ -358,6 +359,12 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
||||
height: _fullBarHeight,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
key: const Key('home-feed-full-series-bg'),
|
||||
color: _fullBarBackground,
|
||||
),
|
||||
),
|
||||
Positioned.fill(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
|
||||
@@ -4,6 +4,8 @@ part of 'home_feed_overlay.dart';
|
||||
|
||||
const double _thumbSize = 6;
|
||||
const double _thumbActiveSize = 10;
|
||||
const double _trackActiveHeight = 4;
|
||||
const double _lineCenterFromBottom = 6;
|
||||
|
||||
/// 顶部频道 tab:漫剧点击提示即将上线。
|
||||
enum _FeedTab {
|
||||
@@ -199,10 +201,6 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
||||
return GestureDetector(
|
||||
key: const Key('home-feed-progress'),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTapDown: (details) {
|
||||
widget.onScrubStart?.call();
|
||||
_commit(details.localPosition.dx / width);
|
||||
},
|
||||
onHorizontalDragStart: (details) {
|
||||
widget.onScrubStart?.call();
|
||||
_update(details.localPosition.dx / width);
|
||||
@@ -233,11 +231,14 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
||||
}
|
||||
|
||||
Widget _track(double fraction, double width) {
|
||||
final active = _preview != null;
|
||||
final size = active ? _thumbActiveSize : _thumbSize;
|
||||
final dragging = _preview != null;
|
||||
final trackHeight = dragging ? _trackActiveHeight : widget.height;
|
||||
final size = dragging ? _thumbActiveSize : _thumbSize;
|
||||
final left = (width * fraction - size / 2)
|
||||
.clamp(0.0, width - size)
|
||||
.toDouble();
|
||||
final lineBottom = _lineCenterFromBottom - trackHeight / 2;
|
||||
final thumbBottom = _lineCenterFromBottom - size / 2;
|
||||
return SizedBox(
|
||||
height: widget.hitHeight,
|
||||
child: Stack(
|
||||
@@ -246,21 +247,25 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: Container(height: widget.height, color: Colors.white24),
|
||||
bottom: lineBottom,
|
||||
child: Container(
|
||||
key: const Key('home-feed-progress-track'),
|
||||
height: trackHeight,
|
||||
color: Colors.white24,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
bottom: lineBottom,
|
||||
child: Container(
|
||||
width: width * fraction,
|
||||
height: widget.height,
|
||||
height: trackHeight,
|
||||
color: AppColors.blue,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: left,
|
||||
bottom: 0,
|
||||
bottom: thumbBottom,
|
||||
child: Container(
|
||||
key: const Key('home-feed-progress-thumb'),
|
||||
width: size,
|
||||
|
||||
Reference in new issue
Block a user