123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import 'package:farmer_client/services/news.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_easyloading/flutter_easyloading.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get.dart';
- import '../../models/entities/NewsInformationInfoTextModel.dart';
- import '../../widgets/layout/BasicPage.dart';
-
- class ArticleInfo extends BasicPage {
- String newsId = '';
- final newsInfoContent =
- Rx<NewsInformationInfoTextModel>(NewsInformationInfoTextModel());
- final newsList = Rx<List<ExtendContent>>([]);
-
- @override
- void beforeShow() {
- // TODO: implement beforeShow
- super.beforeShow();
- if (Get.arguments['newsId'] != null) {
- EasyLoading.show(status: '数据加载中...');
-
- newsId = Get.arguments['newsId'];
-
- getNewsInfo(newsId).then((value) {
- newsInfoContent.value = NewsInformationInfoTextModel.fromJson(value);
- newsList.value = newsInfoContent.value.contentList!;
- EasyLoading.dismiss();
- });
- }
- }
-
- @override
- Widget builder(BuildContext context) {
- naviTitle = '资讯详情';
- return Container(
- padding: EdgeInsets.all(15.w),
- child: ListView(
- children: [
- Container(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Image(
- image: AssetImage('images/icons/decorate.png'),
- width: 17,
- ),
- Container(
- alignment: Alignment.center,
- width: 260.w,
- child: Obx(() => Text(
- newsInfoContent.value.title.toString(),
- style: TextStyle(
- fontSize: 17.sp,
- fontWeight: FontWeight.bold,
- ),
- )),
- ),
- Image(
- image: AssetImage('images/icons/decorate.png'), width: 17),
- ],
- ),
- ),
- Obx(() => Column(
- children: newsList.value.map((item) {
- if (item.contentType != 'image') {
- return Container(
- padding: EdgeInsets.fromLTRB(0, 20, 0, 10),
- width: 344.w,
- child: Text(
- item.content.toString(),
- style: TextStyle(fontSize: 14.sp),
- ),
- );
- } else {
- return Container(
- padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
- child: Image(
- image: NetworkImage(item.content.toString()),
- width: 320.w,
- fit: BoxFit.fill,
- ),
- );
- }
- }).toList(),
- )),
- ],
- ),
- );
- }
- }
|