You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

230 lines
8.4 KiB

import 'dart:convert';
import 'dart:ui';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/data/article.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:flutter/cupertino.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../generated/l10n.dart';
import '../../utils/font_weight.dart';
import '../view_widget/custom_image.dart';
class ShareTrends extends StatefulWidget {
final Map<String, dynamic>? arguments;
ShareTrends({this.arguments});
@override
State<StatefulWidget> createState() {
return _ShareTrends();
}
}
class _ShareTrends extends State<ShareTrends> {
ApiService? apiService;
bool topSetting = false;
final TextEditingController textController = TextEditingController();
var commentFocus = FocusNode();
Article? article;
@override
void initState() {
super.initState();
queryDetails(widget.arguments?["articleId"]);
}
///详情接口
queryDetails(id) async {
apiService ??= ApiService(Dio(),
context: context,
token: SharedInstance.instance.token,
showLoading: true,
);
BaseData<Article>? baseData = await apiService?.informationInfo(id).catchError((onError) {
debugPrint(onError.toString());
return BaseData<Article>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
setState(() {
article = baseData?.data;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFFF9FAF7),
body: Container(
child: Column(
children: [
Container(
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top + 11.h, bottom: 14.w,
),
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
alignment: Alignment.center,
margin: EdgeInsets.only(
left: 60.w,
),
child: Text(
"转发",
style: TextStyle(
color: Colors.black,
fontSize: 17.sp,
fontWeight: MyFontWeight.regular,
),
),
),
),
Container(
alignment: Alignment.center,
margin: EdgeInsets.only(right: 16.w),
padding: EdgeInsets.symmetric(
horizontal: 16.w,
vertical: 3.h,
),
decoration: BoxDecoration(
color: Color(0xFF32A060),
borderRadius: BorderRadius.circular(10.5),
),
child: Text(
S.of(context).fabu,
style: TextStyle(
color: Colors.white,
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
),
],
),
),
Expanded(
child: Container(
margin: EdgeInsets.symmetric(vertical: 14.h),
width: double.infinity,
color: Colors.white,
padding: EdgeInsets.only(left: 20.w, right: 16.w),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Color(0xffF2F2F2),
borderRadius: BorderRadius.circular(6),
),
margin: EdgeInsets.only(top: 30.w),
child: Container(
margin: EdgeInsets.only(
left: 16.w,
right: 10.w,
),
alignment: Alignment.topLeft,
child: TextField(
textInputAction: TextInputAction.send,
onEditingComplete: () {},
maxLines: 8,
minLines: 1,
focusNode: commentFocus,
controller: textController,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "想说点什么...",
hintStyle: TextStyle(
fontSize: 14.sp,
color: Color(0xFF7C7C7C),
),
),
),
),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pushNamed(
'/router/scan_web',
arguments: {
"result": widget.arguments?["shareUrl"],
"title": "一心回乡",
},
);
},
child: Container(
decoration: BoxDecoration(
color: Color(0xFFF2F2F2),
borderRadius: BorderRadius.circular(6),
),
padding: EdgeInsets.only(
top: 8.h,
bottom: 8.h,
left: 8.w,
right: 10.w,
),
margin: EdgeInsets.only(top: 12.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (article?.content != null &&
article!.content!
.contains("images\":[\"") ||
(article?.coverImg ?? "") != "")
MImage(
article?.content != null &&
article!.content!
.contains("images\":[\"")
? jsonDecode(article!.content!)["images"][0]
: article?.coverImg ?? "",
radius: BorderRadius.circular(2),
fit: BoxFit.fill,
width: 64,
height: 64,
errorSrc: "assets/image/default_2_1.webp",
fadeSrc: "assets/image/default_2_1.webp",
),
if (article?.content != null ||
article?.coverImg != null)
SizedBox(
width: 7.w,
),
Expanded(
child: Text(
article?.mainTitle ?? "",
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xFF4D4D4D),
fontSize: 14.sp,
height: 1.4.h,
fontWeight: MyFontWeight.regular,
),
),
),
],
),
),
),
],
),
),
),
],
),
),
);
}
}