chore: prepare yanting monorepo handoff
This commit is contained in:
+135
@@ -0,0 +1,135 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'data/api/report_data_source.dart';
|
||||
import 'features/shell_page.dart';
|
||||
import 'theme/app_theme.dart';
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({required this.dataSource, super.key});
|
||||
|
||||
final ReportDataSource dataSource;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: '研听',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: buildAppTheme(),
|
||||
scrollBehavior: const WhitespaceStretchScrollBehavior(),
|
||||
home: ShellPage(dataSource: dataSource),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class WhitespaceStretchScrollBehavior extends MaterialScrollBehavior {
|
||||
const WhitespaceStretchScrollBehavior();
|
||||
|
||||
@override
|
||||
Widget buildOverscrollIndicator(
|
||||
BuildContext context,
|
||||
Widget child,
|
||||
ScrollableDetails details,
|
||||
) {
|
||||
return _WhitespaceStretchIndicator(child: child);
|
||||
}
|
||||
}
|
||||
|
||||
class _WhitespaceStretchIndicator extends StatefulWidget {
|
||||
const _WhitespaceStretchIndicator({required this.child});
|
||||
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
State<_WhitespaceStretchIndicator> createState() =>
|
||||
_WhitespaceStretchIndicatorState();
|
||||
}
|
||||
|
||||
class _WhitespaceStretchIndicatorState
|
||||
extends State<_WhitespaceStretchIndicator>
|
||||
with SingleTickerProviderStateMixin {
|
||||
static const double _maxStretch = 64;
|
||||
static const double _dragResistance = 0.38;
|
||||
|
||||
late final AnimationController _offsetController =
|
||||
AnimationController.unbounded(vsync: this)..addListener(_onTick);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return NotificationListener<ScrollNotification>(
|
||||
onNotification: _handleScrollNotification,
|
||||
child: ClipRect(
|
||||
child: Transform.translate(
|
||||
offset: Offset(0, _offsetController.value),
|
||||
child: widget.child,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_offsetController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
bool _handleScrollNotification(ScrollNotification notification) {
|
||||
if (notification.metrics.axis != Axis.vertical) {
|
||||
return false;
|
||||
}
|
||||
if (notification is OverscrollNotification) {
|
||||
final overscroll = notification.overscroll;
|
||||
final atTop =
|
||||
notification.metrics.pixels <= notification.metrics.minScrollExtent;
|
||||
final atBottom =
|
||||
notification.metrics.pixels >= notification.metrics.maxScrollExtent;
|
||||
if (atTop && overscroll < 0) {
|
||||
_setOffset(
|
||||
(_offsetController.value - overscroll * _dragResistance).clamp(
|
||||
0,
|
||||
_maxStretch,
|
||||
),
|
||||
);
|
||||
} else if (atBottom && overscroll > 0) {
|
||||
_setOffset(
|
||||
(_offsetController.value - overscroll * _dragResistance).clamp(
|
||||
-_maxStretch,
|
||||
0,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (notification is ScrollUpdateNotification &&
|
||||
notification.dragDetails == null) {
|
||||
_releaseOffset();
|
||||
}
|
||||
if (notification is ScrollEndNotification) {
|
||||
_releaseOffset();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void _setOffset(num next) {
|
||||
if (next == _offsetController.value) {
|
||||
return;
|
||||
}
|
||||
_offsetController.stop();
|
||||
_offsetController.value = next.toDouble();
|
||||
}
|
||||
|
||||
void _releaseOffset() {
|
||||
if (_offsetController.value == 0) {
|
||||
return;
|
||||
}
|
||||
_offsetController.animateTo(
|
||||
0,
|
||||
duration: const Duration(milliseconds: 260),
|
||||
curve: Curves.easeOutCubic,
|
||||
);
|
||||
}
|
||||
|
||||
void _onTick() {
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../models/models.dart';
|
||||
|
||||
abstract class ReportDataSource {
|
||||
Future<List<ReportCardModel>> recommended();
|
||||
Future<List<ReportCardModel>> reports();
|
||||
Future<List<Institution>> institutions();
|
||||
Future<Institution> institutionDetail(String institutionId);
|
||||
Future<List<AudioItem>> listen();
|
||||
Future<ReportDetail> reportDetail(String reportId);
|
||||
Future<ModuleDetail> moduleDetail(String reportId, String moduleId);
|
||||
}
|
||||
|
||||
class RnbApiDataSource implements ReportDataSource {
|
||||
RnbApiDataSource({
|
||||
http.Client? client,
|
||||
this.baseUrl = const String.fromEnvironment('RNB_API_BASE'),
|
||||
}) : client = client ?? http.Client();
|
||||
|
||||
final http.Client client;
|
||||
final String baseUrl;
|
||||
|
||||
Future<JsonMap> _get(String path) async {
|
||||
if (baseUrl.isEmpty) {
|
||||
throw StateError('RNB_API_BASE is required for live API requests.');
|
||||
}
|
||||
final response = await client.get(Uri.parse('$baseUrl$path'));
|
||||
if (response.statusCode != 200) {
|
||||
throw StateError('Request failed: ${response.statusCode}');
|
||||
}
|
||||
return jsonDecode(utf8.decode(response.bodyBytes)) as JsonMap;
|
||||
}
|
||||
|
||||
List<JsonMap> _items(JsonMap body) => asMapList(body['items']);
|
||||
|
||||
@override
|
||||
Future<List<ReportCardModel>> recommended() async {
|
||||
final body = await _get('/feed/recommended');
|
||||
return _items(body).map(ReportCardModel.fromJson).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<ReportCardModel>> reports() async {
|
||||
final body = await _get('/reports');
|
||||
return _items(body).map(ReportCardModel.fromJson).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Institution>> institutions() async {
|
||||
final body = await _get('/institutions');
|
||||
return _items(body).map(Institution.fromJson).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Institution> institutionDetail(String institutionId) async {
|
||||
return Institution.fromJson(await _get('/institutions/$institutionId'));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<AudioItem>> listen() async {
|
||||
final body = await _get('/listen');
|
||||
return _items(body).map(AudioItem.fromJson).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ReportDetail> reportDetail(String reportId) async {
|
||||
return ReportDetail.fromJson(await _get('/reports/$reportId'));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ModuleDetail> moduleDetail(String reportId, String moduleId) async {
|
||||
return ModuleDetail.fromJson(await _get('/reports/$reportId/modules/$moduleId'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
typedef JsonMap = Map<String, dynamic>;
|
||||
|
||||
String asString(Object? value, [String fallback = '']) =>
|
||||
value == null ? fallback : value.toString();
|
||||
|
||||
int asInt(Object? value, [int fallback = 0]) {
|
||||
if (value is int) return value;
|
||||
if (value is num) return value.round();
|
||||
return int.tryParse(asString(value)) ?? fallback;
|
||||
}
|
||||
|
||||
bool asBool(Object? value) => value == true;
|
||||
|
||||
List<String> asStringList(Object? value) {
|
||||
if (value is List) return value.map((item) => item.toString()).toList();
|
||||
return const [];
|
||||
}
|
||||
|
||||
JsonMap asMap(Object? value) {
|
||||
if (value is Map<String, dynamic>) return value;
|
||||
if (value is Map) return value.map((key, val) => MapEntry(key.toString(), val));
|
||||
return const {};
|
||||
}
|
||||
|
||||
List<JsonMap> asMapList(Object? value) {
|
||||
if (value is List) return value.map(asMap).where((item) => item.isNotEmpty).toList();
|
||||
return const [];
|
||||
}
|
||||
|
||||
String formatDate(String? iso) {
|
||||
if (iso == null || iso.isEmpty) return '';
|
||||
final parsed = DateTime.tryParse(iso);
|
||||
if (parsed == null) return iso;
|
||||
return '${parsed.year}年${parsed.month}月${parsed.day}日';
|
||||
}
|
||||
|
||||
String formatDuration(int seconds) {
|
||||
final safe = seconds < 0 ? 0 : seconds;
|
||||
final minutes = safe ~/ 60;
|
||||
final secs = safe % 60;
|
||||
return '$minutes:${secs.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
class Institution {
|
||||
const Institution({
|
||||
required this.id,
|
||||
required this.nameCn,
|
||||
this.nameEn = '',
|
||||
this.institutionType = '',
|
||||
this.sourceTier = '',
|
||||
this.websiteUrl = '',
|
||||
this.coveredTopics = const [],
|
||||
this.reportCount = 0,
|
||||
this.latestReportAt,
|
||||
this.credibilityNote = '',
|
||||
this.introCn = '',
|
||||
this.recentReports = const [],
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String nameCn;
|
||||
final String nameEn;
|
||||
final String institutionType;
|
||||
final String sourceTier;
|
||||
final String websiteUrl;
|
||||
final List<String> coveredTopics;
|
||||
final int reportCount;
|
||||
final String? latestReportAt;
|
||||
final String credibilityNote;
|
||||
final String introCn;
|
||||
final List<ReportCardModel> recentReports;
|
||||
|
||||
factory Institution.fromJson(JsonMap json) {
|
||||
return Institution(
|
||||
id: asString(json['institution_id']),
|
||||
nameCn: asString(json['name_cn']),
|
||||
nameEn: asString(json['name_en']),
|
||||
institutionType: asString(json['institution_type']),
|
||||
sourceTier: asString(json['source_tier']),
|
||||
websiteUrl: asString(json['website_url']),
|
||||
coveredTopics: asStringList(json['covered_topics']),
|
||||
reportCount: asInt(json['report_count']),
|
||||
latestReportAt: json['latest_report_at']?.toString(),
|
||||
credibilityNote: asString(json['credibility_note']),
|
||||
introCn: asString(json['intro_cn']),
|
||||
recentReports: asMapList(json['recent_reports'])
|
||||
.map(ReportCardModel.fromJson)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ReportCardModel {
|
||||
const ReportCardModel({
|
||||
required this.id,
|
||||
required this.titleCn,
|
||||
required this.institution,
|
||||
this.subtitleCn = '',
|
||||
this.oneLiner = '',
|
||||
this.topics = const [],
|
||||
this.releasedAt,
|
||||
this.hasAudio = false,
|
||||
this.interpretationLabel = '研报解读',
|
||||
this.sourceTier = '',
|
||||
this.cacheVersion = '',
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String titleCn;
|
||||
final String subtitleCn;
|
||||
final String oneLiner;
|
||||
final Institution institution;
|
||||
final List<String> topics;
|
||||
final String? releasedAt;
|
||||
final bool hasAudio;
|
||||
final String interpretationLabel;
|
||||
final String sourceTier;
|
||||
final String cacheVersion;
|
||||
|
||||
factory ReportCardModel.fromJson(JsonMap json) {
|
||||
final institution = Institution.fromJson(asMap(json['institution']));
|
||||
return ReportCardModel(
|
||||
id: asString(json['report_id']),
|
||||
titleCn: asString(json['title_cn']),
|
||||
subtitleCn: asString(json['subtitle_cn']),
|
||||
oneLiner: asString(json['one_liner']),
|
||||
institution: institution,
|
||||
topics: asStringList(json['topics']),
|
||||
releasedAt: json['released_at']?.toString(),
|
||||
hasAudio: asBool(json['has_audio']),
|
||||
interpretationLabel: asString(json['interpretation_label'], '研报解读'),
|
||||
sourceTier: asString(json['source_tier']),
|
||||
cacheVersion: asString(json['cache_version']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AudioItem {
|
||||
const AudioItem({
|
||||
required this.audioId,
|
||||
required this.reportId,
|
||||
required this.titleCn,
|
||||
required this.reportTitleCn,
|
||||
required this.durationSec,
|
||||
required this.institution,
|
||||
this.releasedAt,
|
||||
this.cacheVersion = '',
|
||||
});
|
||||
|
||||
final String audioId;
|
||||
final String reportId;
|
||||
final String titleCn;
|
||||
final String reportTitleCn;
|
||||
final int durationSec;
|
||||
final Institution institution;
|
||||
final String? releasedAt;
|
||||
final String cacheVersion;
|
||||
|
||||
factory AudioItem.fromJson(JsonMap json) {
|
||||
return AudioItem(
|
||||
audioId: asString(json['audio_id']),
|
||||
reportId: asString(json['report_id']),
|
||||
titleCn: asString(json['title_cn']),
|
||||
reportTitleCn: asString(json['report_title_cn'], asString(json['title_cn'])),
|
||||
durationSec: asInt(json['duration_sec']),
|
||||
institution: Institution.fromJson(asMap(json['institution'])),
|
||||
releasedAt: json['released_at']?.toString(),
|
||||
cacheVersion: asString(json['cache_version']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DisplayModule {
|
||||
const DisplayModule({
|
||||
required this.id,
|
||||
required this.type,
|
||||
required this.titleCn,
|
||||
required this.renderMode,
|
||||
this.layer = '',
|
||||
this.hasDetailPage = false,
|
||||
this.sortOrder = 0,
|
||||
this.content = const {},
|
||||
this.preview = const {},
|
||||
this.contentRef = '',
|
||||
this.contentEtag = '',
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String type;
|
||||
final String titleCn;
|
||||
final String layer;
|
||||
final String renderMode;
|
||||
final bool hasDetailPage;
|
||||
final int sortOrder;
|
||||
final JsonMap content;
|
||||
final JsonMap preview;
|
||||
final String contentRef;
|
||||
final String contentEtag;
|
||||
|
||||
factory DisplayModule.fromJson(JsonMap json) {
|
||||
return DisplayModule(
|
||||
id: asString(json['module_id']),
|
||||
type: asString(json['type']),
|
||||
titleCn: asString(json['title_cn'], asString(json['type'])),
|
||||
layer: asString(json['layer']),
|
||||
renderMode: asString(json['render_mode'], 'inline'),
|
||||
hasDetailPage: asBool(json['has_detail_page']),
|
||||
sortOrder: asInt(json['sort_order']),
|
||||
content: asMap(json['content']),
|
||||
preview: asMap(json['preview']),
|
||||
contentRef: asString(json['content_ref']),
|
||||
contentEtag: asString(json['content_etag']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ReportDetail {
|
||||
const ReportDetail({
|
||||
required this.id,
|
||||
required this.titleCn,
|
||||
required this.institution,
|
||||
this.subtitleCn = '',
|
||||
this.originalTitle = '',
|
||||
this.oneLiner = '',
|
||||
this.source = const {},
|
||||
this.topics = const [],
|
||||
this.hasAudio = false,
|
||||
this.interpretationLabel = '研报解读',
|
||||
this.riskDisclaimer = '',
|
||||
this.releasedAt,
|
||||
this.cacheVersion = '',
|
||||
this.modules = const [],
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String titleCn;
|
||||
final String subtitleCn;
|
||||
final String originalTitle;
|
||||
final String oneLiner;
|
||||
final Institution institution;
|
||||
final JsonMap source;
|
||||
final List<String> topics;
|
||||
final bool hasAudio;
|
||||
final String interpretationLabel;
|
||||
final String riskDisclaimer;
|
||||
final String? releasedAt;
|
||||
final String cacheVersion;
|
||||
final List<DisplayModule> modules;
|
||||
|
||||
factory ReportDetail.fromJson(JsonMap json) {
|
||||
return ReportDetail(
|
||||
id: asString(json['report_id']),
|
||||
titleCn: asString(json['title_cn']),
|
||||
subtitleCn: asString(json['subtitle_cn']),
|
||||
originalTitle: asString(json['original_title']),
|
||||
oneLiner: asString(json['one_liner']),
|
||||
institution: Institution.fromJson(asMap(json['institution'])),
|
||||
source: asMap(json['source']),
|
||||
topics: asStringList(json['topics']),
|
||||
hasAudio: asBool(json['has_audio']),
|
||||
interpretationLabel: asString(json['interpretation_label'], '研报解读'),
|
||||
riskDisclaimer: asString(json['risk_disclaimer']),
|
||||
releasedAt: json['released_at']?.toString(),
|
||||
cacheVersion: asString(json['cache_version']),
|
||||
modules: asMapList(json['modules']).map(DisplayModule.fromJson).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
ReportCardModel asCard() {
|
||||
return ReportCardModel(
|
||||
id: id,
|
||||
titleCn: titleCn,
|
||||
subtitleCn: subtitleCn,
|
||||
oneLiner: oneLiner,
|
||||
institution: institution,
|
||||
topics: topics,
|
||||
releasedAt: releasedAt,
|
||||
hasAudio: hasAudio,
|
||||
interpretationLabel: interpretationLabel,
|
||||
sourceTier: asString(source['source_tier']),
|
||||
cacheVersion: cacheVersion,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ModuleDetail {
|
||||
const ModuleDetail({
|
||||
required this.id,
|
||||
required this.type,
|
||||
required this.titleCn,
|
||||
this.content = const {},
|
||||
this.contentEtag = '',
|
||||
this.cacheVersion = '',
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String type;
|
||||
final String titleCn;
|
||||
final JsonMap content;
|
||||
final String contentEtag;
|
||||
final String cacheVersion;
|
||||
|
||||
factory ModuleDetail.fromJson(JsonMap json) {
|
||||
return ModuleDetail(
|
||||
id: asString(json['module_id']),
|
||||
type: asString(json['type']),
|
||||
titleCn: asString(json['title_cn'], asString(json['type'])),
|
||||
content: asMap(json['content']),
|
||||
contentEtag: asString(json['content_etag']),
|
||||
cacheVersion: asString(json['cache_version']),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,993 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../data/api/report_data_source.dart';
|
||||
import '../../../data/models/models.dart';
|
||||
import '../../../theme/wise_tokens.dart';
|
||||
import '../../../widgets/app_card.dart';
|
||||
import '../../../widgets/badges.dart';
|
||||
import '../../../widgets/mini_player.dart';
|
||||
|
||||
typedef StartModuleAudio =
|
||||
void Function(
|
||||
String audioId,
|
||||
String reportId,
|
||||
String title,
|
||||
int durationSec,
|
||||
);
|
||||
|
||||
class ModuleRendererRegistry {
|
||||
const ModuleRendererRegistry();
|
||||
|
||||
Widget card({
|
||||
required BuildContext context,
|
||||
required DisplayModule module,
|
||||
required ReportDetail report,
|
||||
required ReportDataSource dataSource,
|
||||
required PlayerStateModel player,
|
||||
StartModuleAudio? onStartAudio,
|
||||
VoidCallback? onToggleAudio,
|
||||
void Function(int delta)? onSeekAudio,
|
||||
VoidCallback? onSpeed,
|
||||
}) {
|
||||
final openDetail = module.hasDetailPage
|
||||
? () => Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => ModuleDetailPage(
|
||||
reportId: report.id,
|
||||
module: module,
|
||||
report: report,
|
||||
dataSource: dataSource,
|
||||
registry: this,
|
||||
),
|
||||
),
|
||||
)
|
||||
: null;
|
||||
return AppCard(
|
||||
onTap: openDetail,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_ModuleHeader(module: module),
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
_contentFor(
|
||||
context,
|
||||
type: module.type,
|
||||
payload: module.renderMode == 'inline'
|
||||
? module.content
|
||||
: module.preview,
|
||||
report: report,
|
||||
player: player,
|
||||
onStartAudio: onStartAudio,
|
||||
onToggleAudio: onToggleAudio,
|
||||
onSeekAudio: onSeekAudio,
|
||||
onSpeed: onSpeed,
|
||||
compact: module.renderMode != 'inline',
|
||||
),
|
||||
if (module.hasDetailPage) ...[
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TextButton.icon(
|
||||
onPressed: openDetail,
|
||||
icon: const Icon(Icons.open_in_new),
|
||||
label: const Text('查看详情'),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget page(
|
||||
BuildContext context,
|
||||
String type,
|
||||
JsonMap payload, {
|
||||
ReportDetail? report,
|
||||
}) {
|
||||
return _contentFor(
|
||||
context,
|
||||
type: type,
|
||||
payload: payload,
|
||||
report: report,
|
||||
player: const PlayerStateModel(),
|
||||
compact: false,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _contentFor(
|
||||
BuildContext context, {
|
||||
required String type,
|
||||
required JsonMap payload,
|
||||
required PlayerStateModel player,
|
||||
ReportDetail? report,
|
||||
StartModuleAudio? onStartAudio,
|
||||
VoidCallback? onToggleAudio,
|
||||
void Function(int delta)? onSeekAudio,
|
||||
VoidCallback? onSpeed,
|
||||
bool compact = false,
|
||||
}) {
|
||||
return switch (type) {
|
||||
'basic_info' => _BasicInfo(payload: payload, report: report),
|
||||
'core_insights' => _CoreInsights(payload: payload),
|
||||
'source_compliance' => _SourceCompliance(
|
||||
payload: payload,
|
||||
report: report,
|
||||
),
|
||||
'audio' => _AudioModule(
|
||||
payload: payload,
|
||||
report: report,
|
||||
player: player,
|
||||
onStartAudio: onStartAudio,
|
||||
onToggleAudio: onToggleAudio,
|
||||
onSeekAudio: onSeekAudio,
|
||||
onSpeed: onSpeed,
|
||||
),
|
||||
'institution' => _InstitutionModule(payload: payload, report: report),
|
||||
'executive_overview' => _SectionsModule(
|
||||
payload: payload,
|
||||
compact: compact,
|
||||
),
|
||||
'key_data' => _KeyDataModule(payload: payload, compact: compact),
|
||||
'timeline' => _TimelineModule(payload: payload, compact: compact),
|
||||
'study_guide' => _StudyGuideModule(payload: payload, compact: compact),
|
||||
'structure_graph' => _StructureGraphModule(
|
||||
payload: payload,
|
||||
compact: compact,
|
||||
),
|
||||
'related_sources' => _RelatedSourcesModule(
|
||||
payload: payload,
|
||||
compact: compact,
|
||||
),
|
||||
'differentiated_view' => _DifferentiatedViewModule(
|
||||
payload: payload,
|
||||
compact: compact,
|
||||
),
|
||||
'weaknesses' => _WeaknessesModule(payload: payload, compact: compact),
|
||||
'infographic' => _FallbackModule(type: '信息图', payload: payload),
|
||||
'research_discovery' => _FallbackModule(type: '延伸研究', payload: payload),
|
||||
_ => _FallbackModule(type: type, payload: payload),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ModuleDetailPage extends StatefulWidget {
|
||||
const ModuleDetailPage({
|
||||
required this.reportId,
|
||||
required this.module,
|
||||
required this.report,
|
||||
required this.dataSource,
|
||||
required this.registry,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String reportId;
|
||||
final DisplayModule module;
|
||||
final ReportDetail report;
|
||||
final ReportDataSource dataSource;
|
||||
final ModuleRendererRegistry registry;
|
||||
|
||||
@override
|
||||
State<ModuleDetailPage> createState() => _ModuleDetailPageState();
|
||||
}
|
||||
|
||||
class _ModuleDetailPageState extends State<ModuleDetailPage> {
|
||||
late Future<ModuleDetail> future = widget.dataSource.moduleDetail(
|
||||
widget.reportId,
|
||||
widget.module.id,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(widget.module.titleCn)),
|
||||
body: FutureBuilder<ModuleDetail>(
|
||||
future: future,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
if (snapshot.hasError) {
|
||||
return Center(
|
||||
child: Text(
|
||||
snapshot.error.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
final detail = snapshot.data!;
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(WiseSpacing.x4),
|
||||
children: [
|
||||
AppCard(
|
||||
child: widget.registry.page(
|
||||
context,
|
||||
detail.type,
|
||||
detail.content,
|
||||
report: widget.report,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Text(
|
||||
'缓存版本 ${detail.cacheVersion}',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ModuleHeader extends StatelessWidget {
|
||||
const _ModuleHeader({required this.module});
|
||||
|
||||
final DisplayModule module;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
module.titleCn,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
if (module.layer.isNotEmpty)
|
||||
AppBadge(text: module.layer.toUpperCase(), kind: BadgeKind.brand),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _BasicInfo extends StatelessWidget {
|
||||
const _BasicInfo({required this.payload, required this.report});
|
||||
|
||||
final JsonMap payload;
|
||||
final ReportDetail? report;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final topics = asStringList(payload['topics']).isEmpty
|
||||
? report?.topics ?? const []
|
||||
: asStringList(payload['topics']);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
asString(
|
||||
payload['summary_cn'],
|
||||
asString(payload['scope_cn'], report?.oneLiner ?? ''),
|
||||
),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
Wrap(
|
||||
spacing: WiseSpacing.x2,
|
||||
runSpacing: WiseSpacing.x2,
|
||||
children: [
|
||||
for (final topic in topics) AppBadge(text: topic),
|
||||
if (report?.releasedAt != null)
|
||||
AppBadge(text: formatDate(report!.releasedAt)),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CoreInsights extends StatelessWidget {
|
||||
const _CoreInsights({required this.payload});
|
||||
|
||||
final JsonMap payload;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final points = asMapList(payload['points']);
|
||||
if (points.isEmpty) return _TextLines(payload: payload);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
for (final point in points)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: WiseSpacing.x3),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppBadge(
|
||||
text: _kindLabel(asString(point['kind'])),
|
||||
kind: _kindBadge(asString(point['kind'])),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
Text(
|
||||
asString(point['text']),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SourceCompliance extends StatelessWidget {
|
||||
const _SourceCompliance({required this.payload, required this.report});
|
||||
|
||||
final JsonMap payload;
|
||||
final ReportDetail? report;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final institution = report?.institution;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (asString(payload['source_note']).isNotEmpty)
|
||||
Text(
|
||||
asString(payload['source_note']),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
if (institution != null) ...[
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
Text('发布机构', style: Theme.of(context).textTheme.titleMedium),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
_InfoLine(label: '机构名称', value: institution.nameCn),
|
||||
if (institution.nameEn.isNotEmpty)
|
||||
_InfoLine(label: '英文名称', value: institution.nameEn),
|
||||
if (institution.institutionType.isNotEmpty)
|
||||
_InfoLine(
|
||||
label: '机构类型',
|
||||
value: _institutionTypeLabel(institution.institutionType),
|
||||
),
|
||||
if (institution.sourceTier.isNotEmpty)
|
||||
_InfoLine(label: '来源层级', value: institution.sourceTier),
|
||||
if (institution.reportCount > 0)
|
||||
_InfoLine(label: '收录报告', value: '${institution.reportCount} 份'),
|
||||
if (institution.coveredTopics.isNotEmpty)
|
||||
_InfoLine(
|
||||
label: '覆盖主题',
|
||||
value: institution.coveredTopics.join('、'),
|
||||
),
|
||||
if (institution.websiteUrl.isNotEmpty)
|
||||
_InfoLine(label: '官网', value: institution.websiteUrl),
|
||||
if (institution.introCn.isNotEmpty)
|
||||
_InfoLine(label: '说明', value: institution.introCn),
|
||||
],
|
||||
if (asString(payload['copyright_cn']).isNotEmpty) ...[
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
Text(
|
||||
asString(payload['copyright_cn']),
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0x109A6500),
|
||||
borderRadius: BorderRadius.circular(WiseRadius.sm),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(WiseSpacing.x3),
|
||||
child: Text(
|
||||
asString(payload['disclaimer'], '本内容为公开/授权研报的结构化解读,不构成投资建议。'),
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(color: WiseColors.warning),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _InfoLine extends StatelessWidget {
|
||||
const _InfoLine({required this.label, required this.value});
|
||||
|
||||
final String label;
|
||||
final String value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (value.isEmpty) return const SizedBox.shrink();
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: WiseSpacing.x2),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.labelSmall?.copyWith(color: WiseColors.ink700),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
Text(value, style: Theme.of(context).textTheme.bodyMedium),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _AudioModule extends StatelessWidget {
|
||||
const _AudioModule({
|
||||
required this.payload,
|
||||
required this.report,
|
||||
required this.player,
|
||||
this.onStartAudio,
|
||||
this.onToggleAudio,
|
||||
this.onSeekAudio,
|
||||
this.onSpeed,
|
||||
});
|
||||
|
||||
final JsonMap payload;
|
||||
final ReportDetail? report;
|
||||
final PlayerStateModel player;
|
||||
final StartModuleAudio? onStartAudio;
|
||||
final VoidCallback? onToggleAudio;
|
||||
final void Function(int delta)? onSeekAudio;
|
||||
final VoidCallback? onSpeed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final title = asString(payload['title_cn'], report?.titleCn ?? '音频解读');
|
||||
final audioId = asString(
|
||||
payload['audio_id'],
|
||||
'local_${report?.id ?? title.hashCode}',
|
||||
);
|
||||
final duration = asInt(payload['duration_sec'], 180);
|
||||
return PlayerCard(
|
||||
title: title,
|
||||
durationSec: duration,
|
||||
player: player,
|
||||
onStart: () =>
|
||||
onStartAudio?.call(audioId, report?.id ?? '', title, duration),
|
||||
onToggle: onToggleAudio ?? () {},
|
||||
onSeek: onSeekAudio ?? (_) {},
|
||||
onSpeed: onSpeed ?? () {},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _InstitutionModule extends StatelessWidget {
|
||||
const _InstitutionModule({required this.payload, required this.report});
|
||||
|
||||
final JsonMap payload;
|
||||
final ReportDetail? report;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final name = asString(payload['name_cn'], report?.institution.nameCn ?? '');
|
||||
return Row(
|
||||
children: [
|
||||
const Icon(Icons.account_balance_outlined, color: WiseColors.primary),
|
||||
const SizedBox(width: WiseSpacing.x2),
|
||||
Expanded(
|
||||
child: Text(name, style: Theme.of(context).textTheme.bodyMedium),
|
||||
),
|
||||
Text(
|
||||
'${asInt(payload['report_count'], report?.institution.reportCount ?? 0)} 份',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SectionsModule extends StatelessWidget {
|
||||
const _SectionsModule({required this.payload, required this.compact});
|
||||
|
||||
final JsonMap payload;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final summary = asString(
|
||||
payload['preview_summary'],
|
||||
asString(payload['intro_cn']),
|
||||
);
|
||||
final sections = asMapList(payload['sections']);
|
||||
if (compact) return _Preview(payload: payload);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (summary.isNotEmpty)
|
||||
Text(summary, style: Theme.of(context).textTheme.bodyMedium),
|
||||
for (final section in sections) ...[
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Text(
|
||||
asString(section['heading']),
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
Text(
|
||||
asString(section['body']),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _KeyDataModule extends StatelessWidget {
|
||||
const _KeyDataModule({required this.payload, required this.compact});
|
||||
|
||||
final JsonMap payload;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (compact) return _Preview(payload: payload);
|
||||
final rows = asMapList(payload['rows']);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
for (final row in rows)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: WiseSpacing.x4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
asString(row['metric']),
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
Text(
|
||||
_valueWithUnit(row),
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
if (asString(
|
||||
row['judgment'],
|
||||
asString(row['importance']),
|
||||
).isNotEmpty) ...[
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
Text(
|
||||
asString(row['judgment'], asString(row['importance'])),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
if (asString(row['importance']).isNotEmpty &&
|
||||
asString(row['importance']) !=
|
||||
asString(row['judgment'])) ...[
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
Text(
|
||||
asString(row['importance']),
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _TimelineModule extends StatelessWidget {
|
||||
const _TimelineModule({required this.payload, required this.compact});
|
||||
|
||||
final JsonMap payload;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (compact) return _Preview(payload: payload);
|
||||
final events = asMapList(payload['events']);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
for (final event in events)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: WiseSpacing.x4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (asString(event['date']).isNotEmpty)
|
||||
Text(
|
||||
asString(event['date']),
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.labelSmall?.copyWith(color: WiseColors.primary),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
Text(
|
||||
asString(event['event']),
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
Text(
|
||||
asString(event['impact']),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _StudyGuideModule extends StatelessWidget {
|
||||
const _StudyGuideModule({required this.payload, required this.compact});
|
||||
|
||||
final JsonMap payload;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (compact) return _Preview(payload: payload);
|
||||
final faqs = asMapList(payload['faq_items']);
|
||||
final glossary = asMapList(payload['glossary']);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (asString(payload['intro_cn']).isNotEmpty)
|
||||
Text(
|
||||
asString(payload['intro_cn']),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
for (final item in faqs)
|
||||
ExpansionTile(
|
||||
tilePadding: EdgeInsets.zero,
|
||||
title: Text(asString(item['question'])),
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
asString(item['answer']),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (glossary.isNotEmpty) ...[
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Wrap(
|
||||
spacing: WiseSpacing.x2,
|
||||
runSpacing: WiseSpacing.x2,
|
||||
children: [
|
||||
for (final item in glossary)
|
||||
AppBadge(
|
||||
text:
|
||||
'${asString(item['term'])}: ${asString(item['definition'])}',
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _StructureGraphModule extends StatelessWidget {
|
||||
const _StructureGraphModule({required this.payload, required this.compact});
|
||||
|
||||
final JsonMap payload;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (compact) return _Preview(payload: payload);
|
||||
final nodes = asMapList(payload['nodes']);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
asString(payload['root']),
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
for (final node in nodes)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: WiseSpacing.x4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
asString(node['label']),
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
for (final child in asStringList(node['children']))
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: WiseSpacing.x1),
|
||||
child: Text(
|
||||
child,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _RelatedSourcesModule extends StatelessWidget {
|
||||
const _RelatedSourcesModule({required this.payload, required this.compact});
|
||||
|
||||
final JsonMap payload;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final items = asMapList(payload['items'] ?? payload['sources']);
|
||||
if (items.isEmpty) return _Preview(payload: payload);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
for (final item in items)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: WiseSpacing.x4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
asString(item['title']),
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
Text(
|
||||
asString(item['summary_cn'], asString(item['source_name'])),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DifferentiatedViewModule extends StatelessWidget {
|
||||
const _DifferentiatedViewModule({
|
||||
required this.payload,
|
||||
required this.compact,
|
||||
});
|
||||
|
||||
final JsonMap payload;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (compact) return _Preview(payload: payload);
|
||||
final items = asMapList(payload['divergences']);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
for (final item in items)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: WiseSpacing.x4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
asString(item['topic']),
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
if (asString(item['consensus_view']).isNotEmpty) ...[
|
||||
Text(
|
||||
'常见观点',
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.labelSmall?.copyWith(color: WiseColors.ink700),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
Text(
|
||||
asString(item['consensus_view']),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
],
|
||||
if (asString(item['report_position']).isNotEmpty) ...[
|
||||
Text(
|
||||
'报告观点',
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.labelSmall?.copyWith(color: WiseColors.primary),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
Text(
|
||||
asString(item['report_position']),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _WeaknessesModule extends StatelessWidget {
|
||||
const _WeaknessesModule({required this.payload, required this.compact});
|
||||
|
||||
final JsonMap payload;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (compact) return _Preview(payload: payload);
|
||||
final items = asMapList(payload['items']);
|
||||
final verificationNotes = asStringList(payload['verification_notes']);
|
||||
final counterEvidence = {
|
||||
for (final item in items)
|
||||
if (asString(item['counter_evidence']).isNotEmpty)
|
||||
asString(item['counter_evidence']),
|
||||
}.toList();
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (asString(payload['disclaimer_cn']).isNotEmpty)
|
||||
Text(
|
||||
asString(payload['disclaimer_cn']),
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
for (final item in items)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: WiseSpacing.x3,
|
||||
bottom: WiseSpacing.x2,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
asString(item['topic']),
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
Text(
|
||||
asString(item['weakness']),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (verificationNotes.isNotEmpty || counterEvidence.isNotEmpty) ...[
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0x109A6500),
|
||||
borderRadius: BorderRadius.circular(WiseRadius.sm),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(WiseSpacing.x3),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'需要继续验证',
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.labelSmall?.copyWith(color: WiseColors.warning),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x1),
|
||||
for (final note
|
||||
in verificationNotes.isNotEmpty
|
||||
? verificationNotes
|
||||
: counterEvidence)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: WiseSpacing.x1),
|
||||
child: Text(
|
||||
note,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Preview extends StatelessWidget {
|
||||
const _Preview({required this.payload});
|
||||
|
||||
final JsonMap payload;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final headline = asString(
|
||||
payload['preview_headline'],
|
||||
asString(payload['preview_summary'], asString(payload['root'])),
|
||||
);
|
||||
final highlights = asStringList(payload['highlights']);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (headline.isNotEmpty)
|
||||
Text(headline, style: Theme.of(context).textTheme.bodyMedium),
|
||||
for (final item in highlights.take(3))
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: WiseSpacing.x1),
|
||||
child: Text(
|
||||
'• $item',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _TextLines extends StatelessWidget {
|
||||
const _TextLines({required this.payload});
|
||||
|
||||
final JsonMap payload;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final values = payload.entries
|
||||
.where(
|
||||
(entry) => entry.value != null && entry.value.toString().isNotEmpty,
|
||||
)
|
||||
.map((entry) => '${entry.key}: ${entry.value}')
|
||||
.take(5)
|
||||
.join('\n');
|
||||
return Text(
|
||||
values.isEmpty ? '该模块暂无可展示内容。' : values,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FallbackModule extends StatelessWidget {
|
||||
const _FallbackModule({required this.type, required this.payload});
|
||||
|
||||
final String type;
|
||||
final JsonMap payload;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppBadge(text: '未知模块:$type', kind: BadgeKind.warning),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
_Preview(payload: payload),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _kindLabel(String kind) => switch (kind) {
|
||||
'view' => '观点',
|
||||
'number' => '数字',
|
||||
'risk' => '风险',
|
||||
_ => '要点',
|
||||
};
|
||||
|
||||
BadgeKind _kindBadge(String kind) => switch (kind) {
|
||||
'risk' => BadgeKind.warning,
|
||||
'number' => BadgeKind.audio,
|
||||
_ => BadgeKind.brand,
|
||||
};
|
||||
|
||||
String _valueWithUnit(JsonMap row) {
|
||||
final value = asString(row['value']);
|
||||
final unit = asString(row['unit']);
|
||||
if (unit.isEmpty) return value;
|
||||
return '$value $unit';
|
||||
}
|
||||
|
||||
String _institutionTypeLabel(String value) => switch (value) {
|
||||
'international_org' => '国际组织',
|
||||
'official' => '官方机构',
|
||||
'industry_org' => '行业组织',
|
||||
'asset_manager' => '资管机构',
|
||||
'bank_research' => '银行研究',
|
||||
'partner' => '合作机构',
|
||||
_ => value,
|
||||
};
|
||||
@@ -0,0 +1,199 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../data/api/report_data_source.dart';
|
||||
import '../../data/models/models.dart';
|
||||
import '../../theme/wise_tokens.dart';
|
||||
import '../../widgets/app_buttons.dart';
|
||||
import '../../widgets/app_card.dart';
|
||||
import '../../widgets/badges.dart';
|
||||
import '../../widgets/mini_player.dart';
|
||||
import '../../widgets/sheets.dart';
|
||||
import '../../widgets/states.dart';
|
||||
import 'modules/renderer_registry.dart';
|
||||
|
||||
class ReportDetailPage extends StatefulWidget {
|
||||
const ReportDetailPage({
|
||||
required this.reportId,
|
||||
required this.dataSource,
|
||||
this.player = const PlayerStateModel(),
|
||||
this.onStartAudio,
|
||||
this.onToggleAudio,
|
||||
this.onSeekAudio,
|
||||
this.onSpeed,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String reportId;
|
||||
final ReportDataSource dataSource;
|
||||
final PlayerStateModel player;
|
||||
final void Function(
|
||||
String audioId,
|
||||
String reportId,
|
||||
String title,
|
||||
int durationSec,
|
||||
)?
|
||||
onStartAudio;
|
||||
final VoidCallback? onToggleAudio;
|
||||
final void Function(int delta)? onSeekAudio;
|
||||
final VoidCallback? onSpeed;
|
||||
|
||||
@override
|
||||
State<ReportDetailPage> createState() => _ReportDetailPageState();
|
||||
}
|
||||
|
||||
class _ReportDetailPageState extends State<ReportDetailPage> {
|
||||
static const registry = ModuleRendererRegistry();
|
||||
late Future<ReportDetail> future = widget.dataSource.reportDetail(
|
||||
widget.reportId,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('研报详情')),
|
||||
body: FutureBuilder<ReportDetail>(
|
||||
future: future,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const LoadingState();
|
||||
}
|
||||
if (snapshot.hasError) {
|
||||
return ErrorState(
|
||||
message: snapshot.error.toString(),
|
||||
onRetry: () => setState(
|
||||
() => future = widget.dataSource.reportDetail(widget.reportId),
|
||||
),
|
||||
);
|
||||
}
|
||||
final detail = snapshot.data!;
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(WiseSpacing.x4),
|
||||
children: [
|
||||
AppCard(
|
||||
color: WiseColors.secondary200,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Wrap(
|
||||
spacing: WiseSpacing.x2,
|
||||
runSpacing: WiseSpacing.x2,
|
||||
children: [
|
||||
AppBadge(
|
||||
text: detail.interpretationLabel,
|
||||
kind: BadgeKind.brand,
|
||||
),
|
||||
if (detail.hasAudio)
|
||||
const AppBadge(
|
||||
text: '音频',
|
||||
icon: Icons.graphic_eq,
|
||||
kind: BadgeKind.audio,
|
||||
),
|
||||
AppBadge(
|
||||
text: asString(detail.source['source_tier']),
|
||||
icon: Icons.verified_outlined,
|
||||
kind: BadgeKind.tier,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Text(
|
||||
detail.titleCn,
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
if (detail.oneLiner.isNotEmpty) ...[
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
Text(
|
||||
detail.oneLiner,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Text(
|
||||
'${detail.institution.nameCn} · ${formatDate(detail.releasedAt)}',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
_ActionBar(detail: detail),
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
_Toc(modules: detail.modules),
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
for (final module in detail.modules) ...[
|
||||
registry.card(
|
||||
context: context,
|
||||
module: module,
|
||||
report: detail,
|
||||
dataSource: widget.dataSource,
|
||||
player: widget.player,
|
||||
onStartAudio: widget.onStartAudio,
|
||||
onToggleAudio: widget.onToggleAudio,
|
||||
onSeekAudio: widget.onSeekAudio,
|
||||
onSpeed: widget.onSpeed,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ActionBar extends StatelessWidget {
|
||||
const _ActionBar({required this.detail});
|
||||
|
||||
final ReportDetail detail;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppButton(
|
||||
label: '收藏',
|
||||
icon: Icons.favorite_border,
|
||||
kind: AppButtonKind.ghost,
|
||||
onPressed: () => showLoginSheet(context, reason: '登录后保存到你的收藏'),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: WiseSpacing.x2),
|
||||
Expanded(
|
||||
child: AppButton(
|
||||
label: '原文',
|
||||
icon: Icons.open_in_new,
|
||||
kind: AppButtonKind.ghost,
|
||||
onPressed: () => showOutboundSheet(context, title: detail.titleCn),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Toc extends StatelessWidget {
|
||||
const _Toc({required this.modules});
|
||||
|
||||
final List<DisplayModule> modules;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (modules.isEmpty) return const SizedBox.shrink();
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
for (final module in modules)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: WiseSpacing.x2),
|
||||
child: AppBadge(text: module.titleCn, kind: BadgeKind.brand),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../data/api/report_data_source.dart';
|
||||
import '../../data/models/models.dart';
|
||||
import '../../routing/app_routes.dart';
|
||||
import '../../theme/wise_tokens.dart';
|
||||
import '../../widgets/badges.dart';
|
||||
import '../../widgets/mini_player.dart';
|
||||
import '../../widgets/states.dart';
|
||||
import '../shared/report_card_widget.dart';
|
||||
|
||||
class FeedPage extends StatefulWidget {
|
||||
const FeedPage({
|
||||
required this.dataSource,
|
||||
required this.onPlay,
|
||||
this.player = const PlayerStateModel(),
|
||||
this.onStartModuleAudio,
|
||||
this.onToggleAudio,
|
||||
this.onSeekAudio,
|
||||
this.onSpeed,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final ReportDataSource dataSource;
|
||||
final void Function(AudioItem item) onPlay;
|
||||
final PlayerStateModel player;
|
||||
final void Function(String audioId, String reportId, String title, int durationSec)? onStartModuleAudio;
|
||||
final VoidCallback? onToggleAudio;
|
||||
final void Function(int delta)? onSeekAudio;
|
||||
final VoidCallback? onSpeed;
|
||||
|
||||
@override
|
||||
State<FeedPage> createState() => _FeedPageState();
|
||||
}
|
||||
|
||||
class _FeedPageState extends State<FeedPage> {
|
||||
String topic = '全部';
|
||||
late Future<List<ReportCardModel>> future = widget.dataSource.recommended();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<List<ReportCardModel>>(
|
||||
future: future,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) return const LoadingState();
|
||||
if (snapshot.hasError) return ErrorState(message: snapshot.error.toString(), onRetry: () => setState(() => future = widget.dataSource.recommended()));
|
||||
final items = snapshot.data ?? const [];
|
||||
final topics = ['全部', ...{for (final item in items) ...item.topics}];
|
||||
final visible = topic == '全部' ? items : items.where((item) => item.topics.contains(topic)).toList();
|
||||
if (items.isEmpty) return const EmptyState(title: '暂无可推荐的研报解读', message: '稍后再来看看最新内容');
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(WiseSpacing.x4),
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
for (final t in topics)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: WiseSpacing.x2),
|
||||
child: AppChip(label: t, selected: t == topic, onTap: () => setState(() => topic = t)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
if (visible.isEmpty)
|
||||
EmptyState(title: '暂无可推荐的研报解读', message: '换个主题,或去研报页看看全部内容', icon: Icons.filter_alt_off)
|
||||
else ...[
|
||||
ReportCardWidget(
|
||||
report: visible.first,
|
||||
hero: true,
|
||||
onTap: () => openReportDetail(
|
||||
context,
|
||||
widget.dataSource,
|
||||
visible.first,
|
||||
player: widget.player,
|
||||
onStartAudio: widget.onStartModuleAudio,
|
||||
onToggleAudio: widget.onToggleAudio,
|
||||
onSeekAudio: widget.onSeekAudio,
|
||||
onSpeed: widget.onSpeed,
|
||||
),
|
||||
onPlayTap: () => playFromReport(widget.onPlay, visible.first),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x5),
|
||||
Text('最新解读', style: Theme.of(context).textTheme.titleMedium),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
for (final report in visible.skip(1)) ...[
|
||||
ReportCardWidget(
|
||||
report: report,
|
||||
onTap: () => openReportDetail(
|
||||
context,
|
||||
widget.dataSource,
|
||||
report,
|
||||
player: widget.player,
|
||||
onStartAudio: widget.onStartModuleAudio,
|
||||
onToggleAudio: widget.onToggleAudio,
|
||||
onSeekAudio: widget.onSeekAudio,
|
||||
onSpeed: widget.onSpeed,
|
||||
),
|
||||
onPlayTap: () => playFromReport(widget.onPlay, report),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
],
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void playFromReport(void Function(AudioItem item) onPlay, ReportCardModel report) {
|
||||
onPlay(
|
||||
AudioItem(
|
||||
audioId: 'local_${report.id}',
|
||||
reportId: report.id,
|
||||
titleCn: report.titleCn,
|
||||
reportTitleCn: report.titleCn,
|
||||
durationSec: 180,
|
||||
institution: report.institution,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../data/api/report_data_source.dart';
|
||||
import '../../data/models/models.dart';
|
||||
import '../../routing/app_routes.dart';
|
||||
import '../../theme/wise_tokens.dart';
|
||||
import '../../widgets/app_buttons.dart';
|
||||
import '../../widgets/app_card.dart';
|
||||
import '../../widgets/badges.dart';
|
||||
import '../../widgets/sheets.dart';
|
||||
import '../../widgets/states.dart';
|
||||
import '../shared/report_card_widget.dart';
|
||||
|
||||
class InstitutionDetailPage extends StatefulWidget {
|
||||
const InstitutionDetailPage({required this.institutionId, required this.dataSource, super.key});
|
||||
|
||||
final String institutionId;
|
||||
final ReportDataSource dataSource;
|
||||
|
||||
@override
|
||||
State<InstitutionDetailPage> createState() => _InstitutionDetailPageState();
|
||||
}
|
||||
|
||||
class _InstitutionDetailPageState extends State<InstitutionDetailPage> {
|
||||
late Future<Institution> future = widget.dataSource.institutionDetail(widget.institutionId);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('机构主页')),
|
||||
body: FutureBuilder<Institution>(
|
||||
future: future,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) return const LoadingState();
|
||||
if (snapshot.hasError) return ErrorState(message: snapshot.error.toString(), onRetry: () => setState(() => future = widget.dataSource.institutionDetail(widget.institutionId)));
|
||||
final item = snapshot.data!;
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(WiseSpacing.x4),
|
||||
children: [
|
||||
AppCard(
|
||||
color: WiseColors.secondary200,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(item.nameCn, style: Theme.of(context).textTheme.headlineSmall),
|
||||
if (item.nameEn.isNotEmpty) Text(item.nameEn, style: Theme.of(context).textTheme.bodyMedium),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Wrap(
|
||||
spacing: WiseSpacing.x2,
|
||||
runSpacing: WiseSpacing.x2,
|
||||
children: [
|
||||
AppBadge(text: item.sourceTier, icon: Icons.verified_outlined, kind: BadgeKind.tier),
|
||||
AppBadge(text: '${item.reportCount} 份研报', kind: BadgeKind.brand),
|
||||
for (final topic in item.coveredTopics) AppBadge(text: topic),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
if (item.introCn.isNotEmpty)
|
||||
AppCard(child: Text(item.introCn, style: Theme.of(context).textTheme.bodyMedium)),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
if (item.credibilityNote.isNotEmpty)
|
||||
AppCard(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Icon(Icons.verified_user_outlined, color: WiseColors.positive),
|
||||
const SizedBox(width: WiseSpacing.x2),
|
||||
Expanded(child: Text(item.credibilityNote, style: Theme.of(context).textTheme.bodyMedium)),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x5),
|
||||
Text('最新研报', style: Theme.of(context).textTheme.titleMedium),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
if (item.recentReports.isEmpty)
|
||||
const EmptyState(title: '机构暂无研报', message: '稍后再试', icon: Icons.article_outlined)
|
||||
else
|
||||
for (final report in item.recentReports) ...[
|
||||
ReportCardWidget(
|
||||
report: report,
|
||||
onTap: () => openReportDetail(context, widget.dataSource, report),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
],
|
||||
AppButton(
|
||||
label: '了解相关服务',
|
||||
icon: Icons.open_in_new,
|
||||
kind: AppButtonKind.ghost,
|
||||
expand: true,
|
||||
onPressed: () => showOutboundSheet(context, title: item.nameCn),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../data/api/report_data_source.dart';
|
||||
import '../../data/models/models.dart';
|
||||
import '../../routing/app_routes.dart';
|
||||
import '../../theme/wise_tokens.dart';
|
||||
import '../../widgets/app_card.dart';
|
||||
import '../../widgets/badges.dart';
|
||||
import '../../widgets/states.dart';
|
||||
|
||||
class InstitutionsPage extends StatefulWidget {
|
||||
const InstitutionsPage({required this.dataSource, super.key});
|
||||
|
||||
final ReportDataSource dataSource;
|
||||
|
||||
@override
|
||||
State<InstitutionsPage> createState() => _InstitutionsPageState();
|
||||
}
|
||||
|
||||
class _InstitutionsPageState extends State<InstitutionsPage> {
|
||||
late Future<List<Institution>> future = widget.dataSource.institutions();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<List<Institution>>(
|
||||
future: future,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) return const LoadingState();
|
||||
if (snapshot.hasError) return ErrorState(message: snapshot.error.toString(), onRetry: () => setState(() => future = widget.dataSource.institutions()));
|
||||
final items = [...snapshot.data ?? const <Institution>[]]..sort((a, b) => b.reportCount.compareTo(a.reportCount));
|
||||
if (items.isEmpty) return const EmptyState(title: '暂无机构信息', message: '稍后再试', icon: Icons.account_balance_outlined);
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(WiseSpacing.x4),
|
||||
children: [
|
||||
Text('研报来源机构', style: Theme.of(context).textTheme.titleLarge),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
for (final item in items) ...[
|
||||
InstitutionCard(
|
||||
institution: item,
|
||||
onTap: () => openInstitutionDetail(context, widget.dataSource, item.id),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InstitutionCard extends StatelessWidget {
|
||||
const InstitutionCard({required this.institution, required this.onTap, super.key});
|
||||
|
||||
final Institution institution;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final initials = institution.nameCn.isEmpty ? '研' : institution.nameCn.characters.take(2).toString();
|
||||
return AppCard(
|
||||
onTap: onTap,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 25,
|
||||
backgroundColor: WiseColors.secondary200,
|
||||
foregroundColor: WiseColors.primary,
|
||||
child: Text(initials, style: const TextStyle(fontWeight: FontWeight.w800)),
|
||||
),
|
||||
const SizedBox(width: WiseSpacing.x3),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(institution.nameCn, style: Theme.of(context).textTheme.titleMedium),
|
||||
if (institution.nameEn.isNotEmpty)
|
||||
Text(institution.nameEn, maxLines: 1, overflow: TextOverflow.ellipsis, style: Theme.of(context).textTheme.bodySmall),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
Wrap(
|
||||
spacing: WiseSpacing.x2,
|
||||
runSpacing: WiseSpacing.x2,
|
||||
children: [
|
||||
if (institution.institutionType.isNotEmpty) AppBadge(text: institution.institutionType),
|
||||
for (final topic in institution.coveredTopics.take(3)) AppBadge(text: topic, kind: BadgeKind.brand),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: WiseSpacing.x2),
|
||||
Column(
|
||||
children: [
|
||||
Text('${institution.reportCount}', style: Theme.of(context).textTheme.titleMedium?.copyWith(color: WiseColors.primary)),
|
||||
Text('份研报', style: Theme.of(context).textTheme.bodySmall),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../data/api/report_data_source.dart';
|
||||
import '../../data/models/models.dart';
|
||||
import '../../theme/wise_tokens.dart';
|
||||
import '../../widgets/app_card.dart';
|
||||
import '../../widgets/states.dart';
|
||||
|
||||
class ListenPage extends StatefulWidget {
|
||||
const ListenPage({required this.dataSource, required this.onPlay, super.key});
|
||||
|
||||
final ReportDataSource dataSource;
|
||||
final void Function(AudioItem item) onPlay;
|
||||
|
||||
@override
|
||||
State<ListenPage> createState() => _ListenPageState();
|
||||
}
|
||||
|
||||
class _ListenPageState extends State<ListenPage> {
|
||||
late Future<List<AudioItem>> future = widget.dataSource.listen();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<List<AudioItem>>(
|
||||
future: future,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) return const LoadingState(label: '正在加载听单');
|
||||
if (snapshot.hasError) return ErrorState(message: snapshot.error.toString(), onRetry: () => setState(() => future = widget.dataSource.listen()));
|
||||
final items = snapshot.data ?? const [];
|
||||
if (items.isEmpty) return const EmptyState(title: '暂无音频研报', message: '先去研报页看看图文解读', icon: Icons.headphones_outlined);
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(WiseSpacing.x4),
|
||||
children: [
|
||||
Text('全站音频解读', style: Theme.of(context).textTheme.titleLarge),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
Text('游客可完整收听;真实音频流待后端接入。', style: Theme.of(context).textTheme.bodyMedium),
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
for (final item in items) ...[
|
||||
AppCard(
|
||||
onTap: () => widget.onPlay(item),
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton.filled(
|
||||
onPressed: () => widget.onPlay(item),
|
||||
icon: const Icon(Icons.play_arrow),
|
||||
style: IconButton.styleFrom(backgroundColor: WiseColors.primary, foregroundColor: Colors.white),
|
||||
),
|
||||
const SizedBox(width: WiseSpacing.x3),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(item.reportTitleCn, maxLines: 2, overflow: TextOverflow.ellipsis, style: Theme.of(context).textTheme.titleMedium),
|
||||
Text('${item.institution.nameCn} · ${formatDuration(item.durationSec)}', style: Theme.of(context).textTheme.bodySmall),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
LinearProgressIndicator(value: 0, minHeight: 4, color: WiseColors.accent, backgroundColor: WiseColors.border),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../data/api/report_data_source.dart';
|
||||
import '../../theme/wise_tokens.dart';
|
||||
import '../../widgets/app_buttons.dart';
|
||||
import '../../widgets/app_card.dart';
|
||||
import '../../widgets/sheets.dart';
|
||||
import '../../widgets/states.dart';
|
||||
|
||||
class ProfilePage extends StatelessWidget {
|
||||
const ProfilePage({required this.dataSource, super.key});
|
||||
|
||||
final ReportDataSource dataSource;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(WiseSpacing.x4),
|
||||
children: [
|
||||
AppCard(
|
||||
color: WiseColors.secondary200,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('游客', style: Theme.of(context).textTheme.headlineSmall),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
Text('浏览、阅读和完整收听不需要登录。收藏、历史同步和保存听单等待 auth 接口接入。', style: Theme.of(context).textTheme.bodyMedium),
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
AppButton(
|
||||
label: '登录后保存个人状态',
|
||||
icon: Icons.login,
|
||||
onPressed: () => showLoginSheet(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
_ProfileRow(icon: Icons.favorite_border, title: '收藏研报', subtitle: '登录后同步收藏', onTap: () => showLoginSheet(context, reason: '登录后保存到你的收藏')),
|
||||
_ProfileRow(icon: Icons.history, title: '浏览历史', subtitle: '本地历史占位,服务端同步待接入', onTap: () => showAppToast(context, '历史同步接口待接入')),
|
||||
_ProfileRow(icon: Icons.playlist_add_check, title: '保存听单', subtitle: '登录后保存到你的听单', onTap: () => showLoginSheet(context, reason: '登录后保存到你的听单')),
|
||||
_ProfileRow(icon: Icons.open_in_new, title: '了解研值相关服务', subtitle: '外跳前提示风险边界', onTap: () => showOutboundSheet(context, title: '研值相关服务')),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ProfileRow extends StatelessWidget {
|
||||
const _ProfileRow({required this.icon, required this.title, required this.subtitle, required this.onTap});
|
||||
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: WiseSpacing.x3),
|
||||
child: AppCard(
|
||||
onTap: onTap,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, color: WiseColors.primary),
|
||||
const SizedBox(width: WiseSpacing.x3),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title, style: Theme.of(context).textTheme.titleMedium),
|
||||
Text(subtitle, style: Theme.of(context).textTheme.bodySmall),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Icon(Icons.chevron_right, color: WiseColors.textTertiary),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../data/api/report_data_source.dart';
|
||||
import '../../data/models/models.dart';
|
||||
import '../../routing/app_routes.dart';
|
||||
import '../../theme/wise_tokens.dart';
|
||||
import '../../widgets/app_buttons.dart';
|
||||
import '../../widgets/badges.dart';
|
||||
import '../../widgets/mini_player.dart';
|
||||
import '../../widgets/states.dart';
|
||||
import '../shared/report_card_widget.dart';
|
||||
|
||||
class ReportsPage extends StatefulWidget {
|
||||
const ReportsPage({
|
||||
required this.dataSource,
|
||||
required this.onPlay,
|
||||
this.player = const PlayerStateModel(),
|
||||
this.onStartModuleAudio,
|
||||
this.onToggleAudio,
|
||||
this.onSeekAudio,
|
||||
this.onSpeed,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final ReportDataSource dataSource;
|
||||
final void Function(AudioItem item) onPlay;
|
||||
final PlayerStateModel player;
|
||||
final void Function(String audioId, String reportId, String title, int durationSec)? onStartModuleAudio;
|
||||
final VoidCallback? onToggleAudio;
|
||||
final void Function(int delta)? onSeekAudio;
|
||||
final VoidCallback? onSpeed;
|
||||
|
||||
@override
|
||||
State<ReportsPage> createState() => _ReportsPageState();
|
||||
}
|
||||
|
||||
class _ReportsPageState extends State<ReportsPage> {
|
||||
late Future<List<ReportCardModel>> future = widget.dataSource.reports();
|
||||
String query = '';
|
||||
String topic = '';
|
||||
bool hasAudio = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<List<ReportCardModel>>(
|
||||
future: future,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) return const LoadingState(label: '正在搜索研报');
|
||||
if (snapshot.hasError) return ErrorState(message: snapshot.error.toString(), onRetry: () => setState(() => future = widget.dataSource.reports()));
|
||||
final items = applyFilters(snapshot.data ?? const []);
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(WiseSpacing.x4),
|
||||
children: [
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: '搜索标题、机构或主题',
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
suffixIcon: query.isEmpty ? null : IconButton(onPressed: () => setState(() => query = ''), icon: const Icon(Icons.close)),
|
||||
filled: true,
|
||||
fillColor: WiseColors.surface,
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(WiseRadius.pill), borderSide: BorderSide.none),
|
||||
),
|
||||
onChanged: (value) => setState(() => query = value.trim()),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Row(
|
||||
children: [
|
||||
AppButton(label: '筛选', icon: Icons.tune, kind: AppButtonKind.ghost, onPressed: openFilterSheet),
|
||||
const SizedBox(width: WiseSpacing.x2),
|
||||
AppChip(label: '有音频', selected: hasAudio, onTap: () => setState(() => hasAudio = !hasAudio)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Text('共 ${items.length} 篇研报解读${query.isNotEmpty || topic.isNotEmpty || hasAudio ? '(已筛选)' : ''}', style: Theme.of(context).textTheme.bodySmall),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
if (items.isEmpty)
|
||||
EmptyState(
|
||||
title: query.isNotEmpty ? '未找到相关研报' : '当前筛选下暂无研报',
|
||||
message: query.isNotEmpty ? '换个关键词试试' : '调整筛选条件后再试',
|
||||
actionLabel: '清除筛选',
|
||||
onAction: () => setState(() {
|
||||
query = '';
|
||||
topic = '';
|
||||
hasAudio = false;
|
||||
}),
|
||||
)
|
||||
else
|
||||
for (final report in items) ...[
|
||||
ReportCardWidget(
|
||||
report: report,
|
||||
onTap: () => openReportDetail(
|
||||
context,
|
||||
widget.dataSource,
|
||||
report,
|
||||
player: widget.player,
|
||||
onStartAudio: widget.onStartModuleAudio,
|
||||
onToggleAudio: widget.onToggleAudio,
|
||||
onSeekAudio: widget.onSeekAudio,
|
||||
onSpeed: widget.onSpeed,
|
||||
),
|
||||
onPlayTap: () => widget.onPlay(AudioItem(audioId: 'local_${report.id}', reportId: report.id, titleCn: report.titleCn, reportTitleCn: report.titleCn, durationSec: 180, institution: report.institution)),
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
List<ReportCardModel> applyFilters(List<ReportCardModel> items) {
|
||||
return items.where((item) {
|
||||
final hay = '${item.titleCn} ${item.institution.nameCn} ${item.topics.join(' ')}'.toLowerCase();
|
||||
if (query.isNotEmpty && !hay.contains(query.toLowerCase())) return false;
|
||||
if (topic.isNotEmpty && !item.topics.contains(topic)) return false;
|
||||
if (hasAudio && !item.hasAudio) return false;
|
||||
return true;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
void openFilterSheet() {
|
||||
widget.dataSource.reports().then((items) {
|
||||
if (!mounted) return;
|
||||
final topics = {for (final item in items) ...item.topics}.toList();
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
showDragHandle: true,
|
||||
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(WiseRadius.lg))),
|
||||
builder: (context) => Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 4, 20, 28),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('筛选研报', style: Theme.of(context).textTheme.titleLarge),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Wrap(
|
||||
spacing: WiseSpacing.x2,
|
||||
runSpacing: WiseSpacing.x2,
|
||||
children: [
|
||||
AppChip(label: '全部主题', selected: topic.isEmpty, onTap: () => selectTopic('')),
|
||||
for (final t in topics) AppChip(label: t, selected: topic == t, onTap: () => selectTopic(t)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
AppButton(label: '完成', expand: true, onPressed: () => Navigator.pop(context)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void selectTopic(String value) {
|
||||
setState(() => topic = value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../data/models/models.dart';
|
||||
import '../../theme/wise_tokens.dart';
|
||||
import '../../widgets/app_card.dart';
|
||||
import '../../widgets/badges.dart';
|
||||
|
||||
class ReportCardWidget extends StatelessWidget {
|
||||
const ReportCardWidget({
|
||||
required this.report,
|
||||
required this.onTap,
|
||||
this.hero = false,
|
||||
this.onInstitutionTap,
|
||||
this.onPlayTap,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final ReportCardModel report;
|
||||
final VoidCallback onTap;
|
||||
final bool hero;
|
||||
final VoidCallback? onInstitutionTap;
|
||||
final VoidCallback? onPlayTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final child = Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Wrap(
|
||||
spacing: WiseSpacing.x2,
|
||||
runSpacing: WiseSpacing.x2,
|
||||
children: [
|
||||
AppBadge(text: report.interpretationLabel, kind: BadgeKind.brand),
|
||||
if (report.hasAudio)
|
||||
const AppBadge(text: '音频', icon: Icons.graphic_eq, kind: BadgeKind.audio),
|
||||
if (report.sourceTier.isNotEmpty)
|
||||
AppBadge(text: report.sourceTier, icon: Icons.verified_outlined, kind: BadgeKind.tier),
|
||||
for (final topic in report.topics.take(3)) AppBadge(text: topic),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Text(
|
||||
report.titleCn,
|
||||
maxLines: hero ? 3 : 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: hero
|
||||
? Theme.of(context).textTheme.titleLarge
|
||||
: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
if (report.oneLiner.isNotEmpty) ...[
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
Text(
|
||||
report.oneLiner,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: onInstitutionTap,
|
||||
child: Text(
|
||||
'${report.institution.nameCn}${report.releasedAt == null ? '' : ' · ${formatDate(report.releasedAt)}'}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (report.hasAudio)
|
||||
TextButton.icon(
|
||||
onPressed: onPlayTap,
|
||||
icon: const Icon(Icons.play_circle_outline, size: 18),
|
||||
label: const Text('听研报'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
return hero
|
||||
? HeroReportCard(onTap: onTap, child: child)
|
||||
: AppCard(onTap: onTap, child: child);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../data/api/report_data_source.dart';
|
||||
import '../data/models/models.dart';
|
||||
import '../theme/wise_tokens.dart';
|
||||
import '../widgets/mini_player.dart';
|
||||
import 'feed/feed_page.dart';
|
||||
import 'institutions/institutions_page.dart';
|
||||
import 'listen/listen_page.dart';
|
||||
import 'profile/profile_page.dart';
|
||||
import 'reports/reports_page.dart';
|
||||
|
||||
class ShellPage extends StatefulWidget {
|
||||
const ShellPage({required this.dataSource, super.key});
|
||||
|
||||
final ReportDataSource dataSource;
|
||||
|
||||
@override
|
||||
State<ShellPage> createState() => _ShellPageState();
|
||||
}
|
||||
|
||||
class _ShellPageState extends State<ShellPage> {
|
||||
int index = 0;
|
||||
PlayerStateModel player = const PlayerStateModel();
|
||||
Timer? timer;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
timer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void startAudio(AudioItem item) {
|
||||
timer?.cancel();
|
||||
setState(() {
|
||||
player = PlayerStateModel(
|
||||
audioId: item.audioId,
|
||||
reportId: item.reportId,
|
||||
title: item.titleCn,
|
||||
durationSec: item.durationSec,
|
||||
playing: true,
|
||||
speed: player.speed,
|
||||
);
|
||||
});
|
||||
timer = Timer.periodic(const Duration(seconds: 1), (_) => tick());
|
||||
}
|
||||
|
||||
void startModuleAudio(String audioId, String reportId, String title, int durationSec) {
|
||||
startAudio(
|
||||
AudioItem(
|
||||
audioId: audioId,
|
||||
reportId: reportId,
|
||||
titleCn: title,
|
||||
reportTitleCn: title,
|
||||
durationSec: durationSec,
|
||||
institution: const Institution(id: '', nameCn: ''),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void tick() {
|
||||
if (!player.playing) return;
|
||||
final next = player.positionSec + player.speed.round().clamp(1, 2);
|
||||
setState(() {
|
||||
player = player.copyWith(
|
||||
positionSec: next >= player.durationSec ? player.durationSec : next,
|
||||
playing: next < player.durationSec,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void toggleAudio() {
|
||||
if (!player.hasAudio) return;
|
||||
setState(() => player = player.copyWith(playing: !player.playing));
|
||||
}
|
||||
|
||||
void seekAudio(int delta) {
|
||||
if (!player.hasAudio) return;
|
||||
setState(() {
|
||||
player = player.copyWith(
|
||||
positionSec: (player.positionSec + delta).clamp(0, player.durationSec),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void cycleSpeed() {
|
||||
const speeds = [1.0, 1.25, 1.5, 2.0];
|
||||
final current = speeds.indexOf(player.speed);
|
||||
setState(() => player = player.copyWith(speed: speeds[(current + 1) % speeds.length]));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final pages = [
|
||||
FeedPage(
|
||||
dataSource: widget.dataSource,
|
||||
onPlay: startAudio,
|
||||
player: player,
|
||||
onStartModuleAudio: startModuleAudio,
|
||||
onToggleAudio: toggleAudio,
|
||||
onSeekAudio: seekAudio,
|
||||
onSpeed: cycleSpeed,
|
||||
),
|
||||
ReportsPage(
|
||||
dataSource: widget.dataSource,
|
||||
onPlay: startAudio,
|
||||
player: player,
|
||||
onStartModuleAudio: startModuleAudio,
|
||||
onToggleAudio: toggleAudio,
|
||||
onSeekAudio: seekAudio,
|
||||
onSpeed: cycleSpeed,
|
||||
),
|
||||
InstitutionsPage(dataSource: widget.dataSource),
|
||||
ListenPage(dataSource: widget.dataSource, onPlay: startAudio),
|
||||
ProfilePage(dataSource: widget.dataSource),
|
||||
];
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('研听'),
|
||||
Text(
|
||||
'全球机构研报中文解读',
|
||||
style: TextStyle(fontSize: 12, color: WiseColors.textSecondary, fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: pages[index],
|
||||
bottomNavigationBar: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
MiniPlayer(player: player, onToggle: toggleAudio),
|
||||
NavigationBar(
|
||||
selectedIndex: index,
|
||||
onDestinationSelected: (value) => setState(() => index = value),
|
||||
destinations: const [
|
||||
NavigationDestination(icon: Icon(Icons.auto_awesome_outlined), selectedIcon: Icon(Icons.auto_awesome), label: '推荐'),
|
||||
NavigationDestination(icon: Icon(Icons.article_outlined), selectedIcon: Icon(Icons.article), label: '研报'),
|
||||
NavigationDestination(icon: Icon(Icons.account_balance_outlined), selectedIcon: Icon(Icons.account_balance), label: '机构'),
|
||||
NavigationDestination(icon: Icon(Icons.headphones_outlined), selectedIcon: Icon(Icons.headphones), label: '听单'),
|
||||
NavigationDestination(icon: Icon(Icons.person_outline), selectedIcon: Icon(Icons.person), label: '我的'),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'app.dart';
|
||||
import 'data/api/report_data_source.dart';
|
||||
|
||||
export 'app.dart';
|
||||
export 'data/api/report_data_source.dart';
|
||||
export 'data/models/models.dart';
|
||||
|
||||
void main() {
|
||||
runApp(MyApp(dataSource: RnbApiDataSource()));
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../data/api/report_data_source.dart';
|
||||
import '../data/models/models.dart';
|
||||
import '../features/detail/report_detail_page.dart';
|
||||
import '../features/institutions/institution_detail_page.dart';
|
||||
import '../widgets/mini_player.dart';
|
||||
|
||||
void openReportDetail(
|
||||
BuildContext context,
|
||||
ReportDataSource dataSource,
|
||||
ReportCardModel report, {
|
||||
PlayerStateModel player = const PlayerStateModel(),
|
||||
void Function(String audioId, String reportId, String title, int durationSec)? onStartAudio,
|
||||
VoidCallback? onToggleAudio,
|
||||
void Function(int delta)? onSeekAudio,
|
||||
VoidCallback? onSpeed,
|
||||
}) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => ReportDetailPage(
|
||||
reportId: report.id,
|
||||
dataSource: dataSource,
|
||||
player: player,
|
||||
onStartAudio: onStartAudio,
|
||||
onToggleAudio: onToggleAudio,
|
||||
onSeekAudio: onSeekAudio,
|
||||
onSpeed: onSpeed,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void openInstitutionDetail(
|
||||
BuildContext context,
|
||||
ReportDataSource dataSource,
|
||||
String institutionId,
|
||||
) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => InstitutionDetailPage(
|
||||
institutionId: institutionId,
|
||||
dataSource: dataSource,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'wise_tokens.dart';
|
||||
|
||||
ThemeData buildAppTheme() {
|
||||
final scheme = ColorScheme.fromSeed(
|
||||
seedColor: WiseColors.primary,
|
||||
primary: WiseColors.primary,
|
||||
secondary: WiseColors.secondary,
|
||||
tertiary: WiseColors.accent,
|
||||
surface: WiseColors.surface,
|
||||
);
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: scheme,
|
||||
fontFamily: 'Inter',
|
||||
scaffoldBackgroundColor: WiseColors.canvas,
|
||||
appBarTheme: const AppBarTheme(
|
||||
backgroundColor: WiseColors.canvas,
|
||||
foregroundColor: WiseColors.primary,
|
||||
elevation: 0,
|
||||
centerTitle: false,
|
||||
titleTextStyle: TextStyle(
|
||||
color: WiseColors.primary,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
cardTheme: const CardThemeData(
|
||||
color: WiseColors.surface,
|
||||
elevation: 0,
|
||||
margin: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(WiseRadius.md)),
|
||||
),
|
||||
),
|
||||
navigationBarTheme: NavigationBarThemeData(
|
||||
backgroundColor: WiseColors.surface,
|
||||
indicatorColor: WiseColors.secondary200,
|
||||
labelTextStyle: WidgetStateProperty.resolveWith(
|
||||
(states) => TextStyle(
|
||||
color: states.contains(WidgetState.selected)
|
||||
? WiseColors.primary
|
||||
: WiseColors.textTertiary,
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
iconTheme: WidgetStateProperty.resolveWith(
|
||||
(states) => IconThemeData(
|
||||
color: states.contains(WidgetState.selected)
|
||||
? WiseColors.primary
|
||||
: WiseColors.textTertiary,
|
||||
),
|
||||
),
|
||||
),
|
||||
textTheme: const TextTheme(
|
||||
headlineSmall: TextStyle(
|
||||
color: WiseColors.ink,
|
||||
fontSize: 26,
|
||||
height: 1.18,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
titleLarge: TextStyle(
|
||||
color: WiseColors.ink,
|
||||
fontSize: 21,
|
||||
height: 1.22,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
titleMedium: TextStyle(
|
||||
color: WiseColors.ink,
|
||||
fontSize: 17,
|
||||
height: 1.25,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
bodyLarge: TextStyle(
|
||||
color: WiseColors.ink,
|
||||
fontSize: 16,
|
||||
height: 1.55,
|
||||
),
|
||||
bodyMedium: TextStyle(
|
||||
color: WiseColors.ink700,
|
||||
fontSize: 14,
|
||||
height: 1.5,
|
||||
),
|
||||
bodySmall: TextStyle(
|
||||
color: WiseColors.textSecondary,
|
||||
fontSize: 12,
|
||||
height: 1.45,
|
||||
),
|
||||
labelSmall: TextStyle(
|
||||
color: WiseColors.textSecondary,
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
final class WiseColors {
|
||||
static const primary = Color(0xFF163300);
|
||||
static const primarySoft = Color(0xFF1F4708);
|
||||
static const secondary = Color(0xFF9FE870);
|
||||
static const secondary200 = Color(0xFFE2F6D5);
|
||||
static const accent = Color(0xFF00A2DD);
|
||||
static const canvas = Color(0xFFF4F6F3);
|
||||
static const ink = Color(0xFF0E0F0C);
|
||||
static const ink700 = Color(0xFF454745);
|
||||
static const textSecondary = Color(0xFF5D7079);
|
||||
static const textTertiary = Color(0xFF768E9C);
|
||||
static const surface = Colors.white;
|
||||
static const border = Color(0x1A000000);
|
||||
static const positive = Color(0xFF008026);
|
||||
static const warning = Color(0xFF9A6500);
|
||||
static const negative = Color(0xFFCF2929);
|
||||
}
|
||||
|
||||
final class WiseSpacing {
|
||||
static const x1 = 4.0;
|
||||
static const x2 = 8.0;
|
||||
static const x3 = 12.0;
|
||||
static const x4 = 16.0;
|
||||
static const x5 = 20.0;
|
||||
static const x6 = 24.0;
|
||||
static const x8 = 32.0;
|
||||
static const x10 = 40.0;
|
||||
}
|
||||
|
||||
final class WiseRadius {
|
||||
static const sm = 10.0;
|
||||
static const md = 16.0;
|
||||
static const lg = 24.0;
|
||||
static const pill = 999.0;
|
||||
}
|
||||
|
||||
final class WiseMotion {
|
||||
static const short = Duration(milliseconds: 200);
|
||||
static const base = Duration(milliseconds: 350);
|
||||
static const curve = Cubic(0.8, 0.05, 0.2, 0.95);
|
||||
}
|
||||
|
||||
final class WiseShadows {
|
||||
static const card = [
|
||||
BoxShadow(
|
||||
color: Color(0x14000000),
|
||||
blurRadius: 20,
|
||||
offset: Offset(0, 6),
|
||||
),
|
||||
];
|
||||
static const elevated = [
|
||||
BoxShadow(
|
||||
color: Color(0x24000000),
|
||||
blurRadius: 32,
|
||||
offset: Offset(0, 10),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
const wiseFontStack = [
|
||||
'Inter',
|
||||
'-apple-system',
|
||||
'BlinkMacSystemFont',
|
||||
'PingFang SC',
|
||||
'Microsoft YaHei',
|
||||
'Helvetica Neue',
|
||||
'Arial',
|
||||
'sans-serif',
|
||||
];
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/wise_tokens.dart';
|
||||
|
||||
class AppButton extends StatelessWidget {
|
||||
const AppButton({
|
||||
required this.label,
|
||||
required this.onPressed,
|
||||
this.icon,
|
||||
this.kind = AppButtonKind.primary,
|
||||
this.expand = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final VoidCallback? onPressed;
|
||||
final IconData? icon;
|
||||
final AppButtonKind kind;
|
||||
final bool expand;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = switch (kind) {
|
||||
AppButtonKind.primary => (WiseColors.secondary, WiseColors.primary),
|
||||
AppButtonKind.dark => (WiseColors.primary, Colors.white),
|
||||
AppButtonKind.accent => (WiseColors.accent, Colors.white),
|
||||
AppButtonKind.ghost => (WiseColors.surface, WiseColors.primary),
|
||||
};
|
||||
final child = FilledButton.icon(
|
||||
onPressed: onPressed,
|
||||
icon: icon == null ? const SizedBox.shrink() : Icon(icon, size: 18),
|
||||
label: Text(label),
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: colors.$1,
|
||||
foregroundColor: colors.$2,
|
||||
disabledBackgroundColor: WiseColors.border,
|
||||
disabledForegroundColor: WiseColors.textTertiary,
|
||||
minimumSize: Size(expand ? double.infinity : 0, 44),
|
||||
shape: const StadiumBorder(),
|
||||
),
|
||||
);
|
||||
return expand ? SizedBox(width: double.infinity, child: child) : child;
|
||||
}
|
||||
}
|
||||
|
||||
enum AppButtonKind { primary, dark, accent, ghost }
|
||||
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/wise_tokens.dart';
|
||||
|
||||
class AppCard extends StatelessWidget {
|
||||
const AppCard({
|
||||
required this.child,
|
||||
this.onTap,
|
||||
this.padding = const EdgeInsets.all(WiseSpacing.x4),
|
||||
this.color = WiseColors.surface,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final VoidCallback? onTap;
|
||||
final EdgeInsetsGeometry padding;
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final content = DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(WiseRadius.md),
|
||||
boxShadow: WiseShadows.card,
|
||||
),
|
||||
child: Padding(padding: padding, child: child),
|
||||
);
|
||||
if (onTap == null) return content;
|
||||
return InkWell(
|
||||
borderRadius: BorderRadius.circular(WiseRadius.md),
|
||||
onTap: onTap,
|
||||
child: content,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HeroReportCard extends StatelessWidget {
|
||||
const HeroReportCard({required this.child, this.onTap, super.key});
|
||||
|
||||
final Widget child;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppCard(
|
||||
onTap: onTap,
|
||||
color: WiseColors.secondary200,
|
||||
padding: const EdgeInsets.all(WiseSpacing.x5),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/wise_tokens.dart';
|
||||
|
||||
class AppBadge extends StatelessWidget {
|
||||
const AppBadge({
|
||||
required this.text,
|
||||
this.icon,
|
||||
this.kind = BadgeKind.neutral,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final IconData? icon;
|
||||
final BadgeKind kind;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = switch (kind) {
|
||||
BadgeKind.brand => (WiseColors.secondary200, WiseColors.primarySoft),
|
||||
BadgeKind.audio => (const Color(0x1F00A2DD), WiseColors.accent),
|
||||
BadgeKind.tier => (const Color(0x1A008026), WiseColors.positive),
|
||||
BadgeKind.warning => (const Color(0x209A6500), WiseColors.warning),
|
||||
BadgeKind.neutral => (const Color(0x1286A7BD), WiseColors.textSecondary),
|
||||
};
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: colors.$1,
|
||||
borderRadius: BorderRadius.circular(WiseRadius.pill),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 4),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(icon, size: 14, color: colors.$2),
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
Text(
|
||||
text,
|
||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(color: colors.$2),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum BadgeKind { brand, audio, tier, warning, neutral }
|
||||
|
||||
class AppChip extends StatelessWidget {
|
||||
const AppChip({
|
||||
required this.label,
|
||||
this.selected = false,
|
||||
this.onTap,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final bool selected;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ActionChip(
|
||||
onPressed: onTap,
|
||||
label: Text(label),
|
||||
labelStyle: TextStyle(
|
||||
color: selected ? Colors.white : WiseColors.textSecondary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
backgroundColor: selected ? WiseColors.primary : WiseColors.surface,
|
||||
side: const BorderSide(color: WiseColors.border),
|
||||
shape: const StadiumBorder(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../data/models/models.dart';
|
||||
import '../theme/wise_tokens.dart';
|
||||
import 'app_card.dart';
|
||||
|
||||
class PlayerStateModel {
|
||||
const PlayerStateModel({
|
||||
this.audioId = '',
|
||||
this.reportId = '',
|
||||
this.title = '',
|
||||
this.durationSec = 0,
|
||||
this.positionSec = 0,
|
||||
this.playing = false,
|
||||
this.speed = 1.0,
|
||||
});
|
||||
|
||||
final String audioId;
|
||||
final String reportId;
|
||||
final String title;
|
||||
final int durationSec;
|
||||
final int positionSec;
|
||||
final bool playing;
|
||||
final double speed;
|
||||
|
||||
bool get hasAudio => audioId.isNotEmpty;
|
||||
|
||||
PlayerStateModel copyWith({
|
||||
String? audioId,
|
||||
String? reportId,
|
||||
String? title,
|
||||
int? durationSec,
|
||||
int? positionSec,
|
||||
bool? playing,
|
||||
double? speed,
|
||||
}) {
|
||||
return PlayerStateModel(
|
||||
audioId: audioId ?? this.audioId,
|
||||
reportId: reportId ?? this.reportId,
|
||||
title: title ?? this.title,
|
||||
durationSec: durationSec ?? this.durationSec,
|
||||
positionSec: positionSec ?? this.positionSec,
|
||||
playing: playing ?? this.playing,
|
||||
speed: speed ?? this.speed,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MiniPlayer extends StatelessWidget {
|
||||
const MiniPlayer({
|
||||
required this.player,
|
||||
required this.onToggle,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final PlayerStateModel player;
|
||||
final VoidCallback onToggle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!player.hasAudio) return const SizedBox.shrink();
|
||||
final ratio = player.durationSec == 0 ? 0.0 : player.positionSec / player.durationSec;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),
|
||||
child: AppCard(
|
||||
padding: const EdgeInsets.all(12),
|
||||
color: WiseColors.primary,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
IconButton.filled(
|
||||
onPressed: onToggle,
|
||||
icon: Icon(player.playing ? Icons.pause : Icons.play_arrow),
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: WiseColors.secondary,
|
||||
foregroundColor: WiseColors.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: WiseSpacing.x2),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
player.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w800),
|
||||
),
|
||||
Text(
|
||||
'${formatDuration(player.positionSec)} / ${formatDuration(player.durationSec)} · ${player.speed.toStringAsFixed(1)}x',
|
||||
style: const TextStyle(color: Color(0xCCFFFFFF), fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
LinearProgressIndicator(
|
||||
value: ratio.clamp(0, 1),
|
||||
minHeight: 4,
|
||||
backgroundColor: const Color(0x33FFFFFF),
|
||||
color: WiseColors.secondary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PlayerCard extends StatelessWidget {
|
||||
const PlayerCard({
|
||||
required this.title,
|
||||
required this.durationSec,
|
||||
required this.player,
|
||||
required this.onStart,
|
||||
required this.onToggle,
|
||||
required this.onSeek,
|
||||
required this.onSpeed,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final int durationSec;
|
||||
final PlayerStateModel player;
|
||||
final VoidCallback onStart;
|
||||
final VoidCallback onToggle;
|
||||
final void Function(int delta) onSeek;
|
||||
final VoidCallback onSpeed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final active = player.hasAudio && player.title == title;
|
||||
final position = active ? player.positionSec : 0;
|
||||
final ratio = durationSec == 0 ? 0.0 : position / durationSec;
|
||||
return AppCard(
|
||||
color: WiseColors.secondary200,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('音频解读', style: Theme.of(context).textTheme.titleMedium),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
Text(title, style: Theme.of(context).textTheme.bodyMedium),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
LinearProgressIndicator(
|
||||
value: ratio.clamp(0, 1),
|
||||
minHeight: 6,
|
||||
backgroundColor: Colors.white,
|
||||
color: WiseColors.accent,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(formatDuration(position), style: Theme.of(context).textTheme.bodySmall),
|
||||
Text(formatDuration(durationSec), style: Theme.of(context).textTheme.bodySmall),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Row(
|
||||
children: [
|
||||
IconButton.outlined(onPressed: () => onSeek(-15), icon: const Icon(Icons.replay_10)),
|
||||
IconButton.filled(
|
||||
onPressed: active ? onToggle : onStart,
|
||||
icon: Icon(active && player.playing ? Icons.pause : Icons.play_arrow),
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: WiseColors.primary,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
),
|
||||
IconButton.outlined(onPressed: () => onSeek(15), icon: const Icon(Icons.forward_10)),
|
||||
const Spacer(),
|
||||
TextButton(onPressed: onSpeed, child: Text('${player.speed.toStringAsFixed(1)}x')),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
'真实音频流待 /audio/{id}/stream 接入,当前为本地进度占位。',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/wise_tokens.dart';
|
||||
import 'app_buttons.dart';
|
||||
import 'states.dart';
|
||||
|
||||
Future<void> showLoginSheet(BuildContext context, {String reason = '登录后保存当前动作'}) {
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
showDragHandle: true,
|
||||
backgroundColor: WiseColors.surface,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(WiseRadius.lg)),
|
||||
),
|
||||
builder: (context) => Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 4, 20, 28),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('登录研听', style: Theme.of(context).textTheme.titleLarge),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
Text(reason, style: Theme.of(context).textTheme.bodyMedium),
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
AppButton(
|
||||
label: '使用手机号继续',
|
||||
icon: Icons.phone_iphone,
|
||||
expand: true,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
showAppToast(context, '登录接口待接入,已保留当前页面');
|
||||
},
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
AppButton(
|
||||
label: '微信 / Apple 登录占位',
|
||||
icon: Icons.account_circle_outlined,
|
||||
kind: AppButtonKind.ghost,
|
||||
expand: true,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
showAppToast(context, '真实 auth 待后端接入');
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> showOutboundSheet(BuildContext context, {required String title}) {
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
showDragHandle: true,
|
||||
backgroundColor: WiseColors.surface,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(WiseRadius.lg)),
|
||||
),
|
||||
builder: (context) => Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 4, 20, 28),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('即将打开外部服务', style: Theme.of(context).textTheme.titleLarge),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
Text(
|
||||
'$title\n外跳仅用于了解原文或相关服务,本内容不构成投资建议。',
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
AppButton(
|
||||
label: '确认并记录占位事件',
|
||||
icon: Icons.open_in_new,
|
||||
kind: AppButtonKind.accent,
|
||||
expand: true,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
showAppToast(context, '外跳事件接口待接入');
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/wise_tokens.dart';
|
||||
import 'app_buttons.dart';
|
||||
import 'app_card.dart';
|
||||
|
||||
class LoadingState extends StatelessWidget {
|
||||
const LoadingState({this.label = '正在加载研报解读', super.key});
|
||||
|
||||
final String label;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.separated(
|
||||
padding: const EdgeInsets.all(WiseSpacing.x4),
|
||||
itemCount: 4,
|
||||
separatorBuilder: (_, _) => const SizedBox(height: WiseSpacing.x3),
|
||||
itemBuilder: (context, index) => const SkeletonCard(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SkeletonCard extends StatelessWidget {
|
||||
const SkeletonCard({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppCard(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: const [
|
||||
SkeletonLine(width: 96),
|
||||
SizedBox(height: WiseSpacing.x3),
|
||||
SkeletonLine(width: double.infinity, height: 18),
|
||||
SizedBox(height: WiseSpacing.x2),
|
||||
SkeletonLine(width: 240),
|
||||
SizedBox(height: WiseSpacing.x3),
|
||||
SkeletonLine(width: 160),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SkeletonLine extends StatelessWidget {
|
||||
const SkeletonLine({required this.width, this.height = 12, super.key});
|
||||
|
||||
final double width;
|
||||
final double height;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: width,
|
||||
height: height,
|
||||
decoration: BoxDecoration(
|
||||
color: WiseColors.border,
|
||||
borderRadius: BorderRadius.circular(WiseRadius.pill),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class EmptyState extends StatelessWidget {
|
||||
const EmptyState({
|
||||
required this.title,
|
||||
required this.message,
|
||||
this.icon = Icons.search_off,
|
||||
this.actionLabel,
|
||||
this.onAction,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String message;
|
||||
final IconData icon;
|
||||
final String? actionLabel;
|
||||
final VoidCallback? onAction;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(WiseSpacing.x6),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: 42, color: WiseColors.primary),
|
||||
const SizedBox(height: WiseSpacing.x3),
|
||||
Text(title, style: Theme.of(context).textTheme.titleMedium),
|
||||
const SizedBox(height: WiseSpacing.x2),
|
||||
Text(
|
||||
message,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
if (actionLabel != null) ...[
|
||||
const SizedBox(height: WiseSpacing.x4),
|
||||
AppButton(label: actionLabel!, onPressed: onAction, kind: AppButtonKind.ghost),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ErrorState extends StatelessWidget {
|
||||
const ErrorState({required this.message, this.onRetry, super.key});
|
||||
|
||||
final String message;
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return EmptyState(
|
||||
icon: Icons.cloud_off_outlined,
|
||||
title: '内容暂时加载失败',
|
||||
message: message,
|
||||
actionLabel: onRetry == null ? null : '重试',
|
||||
onAction: onRetry,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void showAppToast(BuildContext context, String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: WiseColors.primary,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(WiseRadius.md)),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user