app/lib/ui/home/dialogs/home_md_content_dialog_ui.dart

57 lines
1.7 KiB
Dart
Raw Normal View History

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(
2024-03-15 00:01:06 +08:00
child: Padding(
2024-12-14 13:48:24 +08:00
padding:
const EdgeInsets.only(left: 8, right: 8, top: 2, bottom: 2),
2024-03-15 00:01:06 +08:00
child: Text(S.current.action_close),
),
onPressed: () {
Navigator.pop(context);
})
],
),
);
}
Future<String> _getContent() async {
final r = await RSHttp.getText(url);
return r;
}
2024-12-14 13:48:24 +08:00
}