fix:对比原型增加功能交互
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
import '../../data/api/report_data_source.dart';
|
||||
import '../../data/content_providers.dart';
|
||||
import '../../data/models/models.dart';
|
||||
import '../../data/providers.dart';
|
||||
import '../../routing/app_routes.dart';
|
||||
import '../../theme/yanting_tokens.dart';
|
||||
import '../../widgets/badges.dart';
|
||||
@@ -41,28 +41,25 @@ class FeedPage extends HookConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final topic = useState('全部');
|
||||
final snapshot = ref.watch(recommendedReportsProvider);
|
||||
final currentTopic = ref.watch(recommendTopicProvider);
|
||||
final snapshot = ref.watch(recommendedByTopicProvider);
|
||||
const topics = ['全部', '宏观', '贵金属', '大宗', '能源', '跨资产', '央行'];
|
||||
|
||||
return snapshot.when(
|
||||
loading: () => const LoadingState(),
|
||||
error: (error, _) => ErrorState(
|
||||
message: error.toString(),
|
||||
onRetry: () => ref.invalidate(recommendedReportsProvider),
|
||||
onRetry: () => ref.invalidate(recommendedByTopicProvider),
|
||||
),
|
||||
data: (items) {
|
||||
final currentTopic = topic.value;
|
||||
final topics = [
|
||||
'全部',
|
||||
...{for (final item in items) ...item.topics},
|
||||
];
|
||||
final visible = currentTopic == '全部'
|
||||
? items
|
||||
: items
|
||||
.where((item) => item.topics.contains(currentTopic))
|
||||
.toList();
|
||||
if (items.isEmpty) {
|
||||
return const EmptyState(title: '暂无可推荐的研报解读', message: '稍后再来看看最新内容');
|
||||
return EmptyState(
|
||||
title: currentTopic == '全部' ? '暂无可推荐的研报解读' : '当前主题暂无内容',
|
||||
message: currentTopic == '全部' ? '稍后再来看看最新内容' : '换个主题,或去研报页看看全部内容',
|
||||
icon: currentTopic == '全部'
|
||||
? Icons.inbox_outlined
|
||||
: Icons.filter_alt_off,
|
||||
);
|
||||
}
|
||||
return ListView(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
@@ -83,41 +80,44 @@ class FeedPage extends HookConsumerWidget {
|
||||
child: AppChip(
|
||||
label: t,
|
||||
selected: t == currentTopic,
|
||||
onTap: () => topic.value = t,
|
||||
onTap: () =>
|
||||
ref.read(recommendTopicProvider.notifier).select(t),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: YantingSpacing.cardGap),
|
||||
if (visible.isEmpty)
|
||||
const EmptyState(
|
||||
title: '暂无可推荐的研报解读',
|
||||
message: '换个主题,或去研报页看看全部内容',
|
||||
icon: Icons.filter_alt_off,
|
||||
)
|
||||
else ...[
|
||||
ReportCardWidget(
|
||||
report: visible.first,
|
||||
hero: true,
|
||||
onTap: () => openReportDetail(
|
||||
ReportCardWidget(
|
||||
report: items.first,
|
||||
hero: true,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(profileControllerProvider.notifier)
|
||||
.addHistory(items.first.id);
|
||||
openReportDetail(
|
||||
context,
|
||||
dataSource,
|
||||
visible.first,
|
||||
items.first,
|
||||
player: player,
|
||||
onStartAudio: onStartModuleAudio,
|
||||
onToggleAudio: onToggleAudio,
|
||||
onSeekAudio: onSeekAudio,
|
||||
onSpeed: onSpeed,
|
||||
),
|
||||
onPlayTap: () => _playFromReport(onPlay, visible.first),
|
||||
),
|
||||
const SizedBox(height: YantingSpacing.sectionGap),
|
||||
const SectionTitle(title: '最新解读', icon: Icons.chevron_right),
|
||||
for (final report in visible.skip(1)) ...[
|
||||
ReportCardWidget(
|
||||
report: report,
|
||||
onTap: () => openReportDetail(
|
||||
);
|
||||
},
|
||||
onPlayTap: () => _playFromReport(onPlay, items.first),
|
||||
),
|
||||
const SizedBox(height: YantingSpacing.sectionGap),
|
||||
const SectionTitle(title: '最新解读', icon: Icons.chevron_right),
|
||||
for (final report in items.skip(1)) ...[
|
||||
ReportCardWidget(
|
||||
report: report,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(profileControllerProvider.notifier)
|
||||
.addHistory(report.id);
|
||||
openReportDetail(
|
||||
context,
|
||||
dataSource,
|
||||
report,
|
||||
@@ -126,11 +126,11 @@ class FeedPage extends HookConsumerWidget {
|
||||
onToggleAudio: onToggleAudio,
|
||||
onSeekAudio: onSeekAudio,
|
||||
onSpeed: onSpeed,
|
||||
),
|
||||
onPlayTap: () => _playFromReport(onPlay, report),
|
||||
),
|
||||
const SizedBox(height: YantingSpacing.x3),
|
||||
],
|
||||
);
|
||||
},
|
||||
onPlayTap: () => _playFromReport(onPlay, report),
|
||||
),
|
||||
const SizedBox(height: YantingSpacing.x3),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user