页面字体跟随系统字体

main
落雨楓 2 years ago
parent 949752dbd1
commit 4ae5685dde

@ -12,6 +12,7 @@ class WikiPageParserController extends GetxController {
var contentHtml = "".obs; var contentHtml = "".obs;
var safeAreaPadding = const EdgeInsets.all(0).obs; var safeAreaPadding = const EdgeInsets.all(0).obs;
var textZoom = 100.obs;
var loading = true.obs; var loading = true.obs;
@ -29,6 +30,14 @@ class WikiPageParserController extends GetxController {
); );
} }
}); });
ever(textZoom, (_) {
webviewCotroller?.setOptions(
options: InAppWebViewGroupOptions(
android: AndroidInAppWebViewOptions(textZoom: textZoom.value),
),
);
});
} }
void onWebViewCreated(InAppWebViewController controller) { void onWebViewCreated(InAppWebViewController controller) {
@ -90,6 +99,8 @@ class _WikiParserState extends ReactiveState<WikiPageParser> {
void receiveProps() { void receiveProps() {
c.contentHtml.value = widget.contentHtml ?? ""; c.contentHtml.value = widget.contentHtml ?? "";
c.safeAreaPadding.value = widget.padding ?? const EdgeInsets.all(0); c.safeAreaPadding.value = widget.padding ?? const EdgeInsets.all(0);
c.textZoom.value =
(MediaQuery.of(Get.context!).textScaleFactor * 100).round();
} }
Widget _buildRender() { Widget _buildRender() {
@ -126,6 +137,11 @@ class _WikiParserState extends ReactiveState<WikiPageParser> {
child: InAppWebView( child: InAppWebView(
onWebViewCreated: c.onWebViewCreated, onWebViewCreated: c.onWebViewCreated,
onPageCommitVisible: c.onPageCommitVisible, onPageCommitVisible: c.onPageCommitVisible,
initialOptions: InAppWebViewGroupOptions(
android: AndroidInAppWebViewOptions(
textZoom: c.textZoom.value,
),
),
), ),
), ),
if (c.loading.value) if (c.loading.value)
@ -140,6 +156,7 @@ class _WikiParserState extends ReactiveState<WikiPageParser> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var sc = Get.find<AppSettingsController>(); var sc = Get.find<AppSettingsController>();
return Obx(() => sc.betaPageRender.value ? _buildRender() : _buildWebview()); return Obx(
() => sc.betaPageRender.value ? _buildRender() : _buildWebview());
} }
} }

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save