mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-28 05:34:45 +08:00
feat:riverpod 迁移 HomeMdContentDialogUI
This commit is contained in:
55
lib/ui/home/dialogs/home_md_content_dialog_ui.dart
Normal file
55
lib/ui/home/dialogs/home_md_content_dialog_ui.dart
Normal file
@ -0,0 +1,55 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/material.dart' show Material;
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:starcitizen_doctor/common/io/rs_http.dart';
|
||||
import 'package:starcitizen_doctor/widgets/widgets.dart';
|
||||
|
||||
class HomeMdContentDialogUI extends HookConsumerWidget {
|
||||
final String title;
|
||||
final String url;
|
||||
|
||||
const HomeMdContentDialogUI(
|
||||
{super.key, required this.title, required this.url});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Material(
|
||||
child: ContentDialog(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context).size.width * .6,
|
||||
),
|
||||
title: Text(title),
|
||||
content: LoadingWidget(
|
||||
onLoadData: _getContent,
|
||||
childBuilder: (BuildContext context, String data) {
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 12, right: 12),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: makeMarkdownView(data),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
FilledButton(
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.only(left: 8, right: 8, top: 2, bottom: 2),
|
||||
child: Text("关闭"),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
})
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> _getContent() async {
|
||||
final r = await RSHttp.getText(url);
|
||||
return r;
|
||||
}
|
||||
}
|
@ -10,7 +10,8 @@ import 'package:starcitizen_doctor/common/helper/system_helper.dart';
|
||||
import 'package:starcitizen_doctor/widgets/widgets.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import 'home_countdown_dialog_ui.dart';
|
||||
import 'dialogs/home_countdown_dialog_ui.dart';
|
||||
import 'dialogs/home_md_content_dialog_ui.dart';
|
||||
import 'home_ui_model.dart';
|
||||
|
||||
class HomeUI extends HookConsumerWidget {
|
||||
@ -729,14 +730,14 @@ class HomeUI extends HookConsumerWidget {
|
||||
launchUrlString(homeState.appPlacardData?.link);
|
||||
return;
|
||||
case "doc":
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return BaseUIContainer(
|
||||
// uiCreate: () => MDContentDialogUI(),
|
||||
// modelCreate: () => MDContentDialogUIModel(
|
||||
// appPlacardData?.title ?? "公告详情", appPlacardData?.link));
|
||||
// });
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return HomeMdContentDialogUI(
|
||||
title: homeState.appPlacardData?.title ?? "公告详情",
|
||||
url: homeState.appPlacardData?.link,
|
||||
);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -176,20 +176,6 @@ class HomeUIModel extends _$HomeUIModel {
|
||||
appVersionData: appGlobalState.networkVersionData!,
|
||||
);
|
||||
|
||||
// if (await File(
|
||||
// "${AppConf.applicationSupportDir}\\webview_data\\enable_webview_localization_capture")
|
||||
// .exists()) {
|
||||
// webViewModel.enableCapture = true;
|
||||
// BaseUIContainer(
|
||||
// uiCreate: () => WebviewLocalizationCaptureUI(),
|
||||
// modelCreate: () =>
|
||||
// WebviewLocalizationCaptureUIModel(webViewModel))
|
||||
// .push(context!)
|
||||
// .then((_) {
|
||||
// webViewModel.enableCapture = false;
|
||||
// });
|
||||
// }
|
||||
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
await webViewModel.launch(url, appGlobalState.networkVersionData!);
|
||||
}
|
||||
@ -264,9 +250,10 @@ class HomeUIModel extends _$HomeUIModel {
|
||||
|
||||
Future _loadRRS() async {
|
||||
try {
|
||||
final rssVideoItems = await RSSApi.getRssVideo();
|
||||
final rssTextItems = await RSSApi.getRssText();
|
||||
state = state.copyWith(
|
||||
rssVideoItems: await RSSApi.getRssVideo(),
|
||||
rssTextItems: await RSSApi.getRssText());
|
||||
rssVideoItems: rssVideoItems, rssTextItems: rssTextItems);
|
||||
dPrint("RSS update Success !");
|
||||
} catch (e) {
|
||||
dPrint("_loadRRS Error:$e");
|
||||
|
Reference in New Issue
Block a user