ArticleInfo.dart 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import 'package:farmer_client/services/news.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:get/get.dart';
  5. import 'package:get/get_core/src/get_main.dart';
  6. import '../../models/entities/NewsInformationInfoTextModel.dart';
  7. import '../../models/entities/NewsInformationModel.dart';
  8. import '../../widgets/layout/BasicPage.dart';
  9. class ArticleInfo extends BasicPage {
  10. String newsId = '';
  11. final newsInfoContent = Rx<NewsInformationInfoTextModel>(NewsInformationInfoTextModel());
  12. final newsList = Rx<List<ExtendContent>>([]);
  13. @override
  14. void beforeShow() {
  15. // TODO: implement beforeShow
  16. super.beforeShow();
  17. if (Get.arguments['newsId'] != null) {
  18. newsId = Get.arguments['newsId'];
  19. getNewsInfo(newsId).then((value) {
  20. newsInfoContent.value = NewsInformationInfoTextModel.fromJson(value);
  21. newsList.value = newsInfoContent.value.contentList!;
  22. });
  23. }
  24. }
  25. @override
  26. Widget builder(BuildContext context) {
  27. naviTitle = '资讯详情';
  28. return Container(
  29. padding: EdgeInsets.fromLTRB(15, 30, 15, 50),
  30. child: Column(
  31. children: [
  32. Container(
  33. alignment: Alignment.center,
  34. child: Row(
  35. mainAxisAlignment: MainAxisAlignment.center,
  36. children: [
  37. Image(
  38. image: AssetImage('images/icons/decorate.png'),
  39. width: 17,
  40. ),
  41. Obx(()=>
  42. Text(
  43. newsInfoContent.value.title.toString(),
  44. style: TextStyle(
  45. fontSize: 17.sp,
  46. fontWeight: FontWeight.bold,
  47. ),
  48. )
  49. ),
  50. Image(
  51. image: AssetImage('images/icons/decorate.png'), width: 17),
  52. ],
  53. ),
  54. ),
  55. Obx(() => Column(
  56. children: newsList.value.map((item) {
  57. if (item.contentType != 'image') {
  58. return Container(
  59. padding: EdgeInsets.fromLTRB(0, 20, 0, 10),
  60. width: 344.w,
  61. child: Text(
  62. item.content.toString(),
  63. style: TextStyle(fontSize: 14.sp),
  64. ),
  65. );
  66. } else {
  67. return Container(
  68. padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
  69. child: Image(
  70. image: NetworkImage(item.content.toString()),
  71. width: 320.w,
  72. height: 260.w,
  73. fit: BoxFit.fill,
  74. ),
  75. );
  76. }
  77. }).toList(),
  78. )),
  79. ],
  80. ),
  81. );
  82. }
  83. }