import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:vbvs_app/common/color/appColors.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; class HelpArticle extends StatelessWidget { Map article; HelpArticle({super.key, required this.article}); // get articleController => Get.find(); get userInfoController => Get.find(); var isLike = 0.obs; // @override // Widget build(BuildContext context) { // String top_imgOrVideo = ""; // if (article['imgOrVideo'] == 0) { // top_imgOrVideo = // ''''''; // } else { // top_imgOrVideo = // ''''''; // } // String newText = article['text']; // RegExp(" d.group(1)) // .toList() // .forEach((d) { // newText = newText.replaceAll("$d", getStorageResourceUrl("$d")); // }); // String html = ''' // // // // Test Page // // // //
// ${top_imgOrVideo} //
//
${article['title']}
//
//
${article['author']}
//
${time_08_Formatter(article['created_at'])}
//
// ${newText} //
// // // '''; // print("$html"); // // articleController.readAdd(article['id']); // String? uid = userInfoController.model.user?.uid; // print("${userInfoController.model.user}"); // // uid = "sss"; // // if (uid != null) { // // articleController.findIsLike(uid, article['id']).then((d) { // // isLike.value = d; // // }); // // } // return LayoutBuilder( // builder: (context, boxConstraints) => GestureDetector( // onTap: () => FocusScope.of(context).unfocus(), // child: Scaffold( // appBar: AppBar( // backgroundColor: AppColors.bg_color, // automaticallyImplyLeading: false, // iconTheme: IconThemeData(color: Colors.white), // titleSpacing: 0, // leading: returnIconButtom, // ), // body: SafeArea( // top: true, // child: Container( // width: MediaQuery.sizeOf(context).width, // height: MediaQuery.sizeOf(context).height, // decoration: BoxDecoration( // color: Colors.white, // // color: AppColors.bg_color, // // image: DecorationImage( // // image: AssetImage("assets/images/background.png$test"), // // fit: BoxFit.cover, // // ), // ), // child: Column( // children: [ // Expanded( // child: Container( // // child: WebViewWidget( // // controller: WebViewController() // // ..setJavaScriptMode(JavaScriptMode.unrestricted) // // ..loadHtmlString(html), // // ), // child: InAppWebView( // initialData: // InAppWebViewInitialData(data: html, encoding: ""), // ), // ), // ), // ], // ), // ), // ), // ), // ), // ); // } Widget build(BuildContext context) { return Scaffold( backgroundColor: const Color(0xFF042C46), appBar: AppBar( backgroundColor: const Color(0xFF042C46), title: Text("问题与帮助", style: TextStyle(color: Colors.white)), centerTitle: true, leading: IconButton( icon: Icon(Icons.arrow_back, color: Colors.white), onPressed: () => Navigator.pop(context), ), elevation: 0, ), body: Column( children: [ Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), alignment: Alignment.centerLeft, child: Text( article['title'], style: const TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold), ), ), Expanded( child: InAppWebView( initialData: InAppWebViewInitialData( data: wrapHtml(article['content']), ), ), ), ], ), ); } /// 包装成完整 HTML 页面,添加适配样式 String wrapHtml(String htmlContent) { return """ $htmlContent """; } }