YSNewDetail.dart 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:ysairplane/base/YSBase.dart';
  4. import 'package:ysairplane/tools/YSNetWorking.dart';
  5. import 'package:ysairplane/tools/YSTools.dart';
  6. class YSNewDetail extends StatefulWidget {
  7. final String newId;
  8. const YSNewDetail({Key key, this.newId}) : super(key: key);
  9. @override
  10. _YSNewDetailState createState() => _YSNewDetailState();
  11. }
  12. class _YSNewDetailState extends State<YSNewDetail> {
  13. Map _dict;
  14. @override
  15. void initState() {
  16. Future.delayed(Duration(seconds: 0)).then((value){
  17. _getNewsDetailData();
  18. });
  19. super.initState();
  20. }
  21. @override
  22. Widget build(BuildContext context) {
  23. return YSBase(
  24. ystitle: '详情',
  25. yschild: _dict==null?Container():Column(
  26. crossAxisAlignment: CrossAxisAlignment.start,
  27. children: [
  28. Container(
  29. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(160),
  30. child: Column(
  31. crossAxisAlignment: CrossAxisAlignment.start,
  32. children: [
  33. Container(
  34. padding: EdgeInsets.all(hsp(40)),
  35. child: Text('${_dict['title']}',style: TextStyle(color: Color(0xFF333333),fontSize: zsp(36),fontWeight: FontWeight.bold),),
  36. ),
  37. Container(
  38. padding: EdgeInsets.only(top: hsp(10),left: hsp(40),right: hsp(40),bottom: hsp(60)),
  39. child: Text('${_dict['createtime']} ${_dict['author']}',style: TextStyle(color: Color(0xFF999999),fontSize: zsp(24)),),
  40. ),
  41. ],
  42. ),
  43. ),
  44. Container(
  45. height: hsp(160),
  46. padding: EdgeInsets.all(hsp(30)),
  47. child: Row(
  48. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  49. children: [
  50. Container(
  51. width: (MediaQuery.of(context).size.width-wsp(100))/2,
  52. height: hsp(83),
  53. color: Color(0xFFF8F8F8),
  54. alignment: Alignment.center,
  55. child: Row(
  56. mainAxisSize: MainAxisSize.min,
  57. children: [
  58. Image(image: AssetImage('lib/images/agree.png'),height: hsp(50),width: hsp(50),),
  59. Text(' ${_dict['likeCount']}',style: TextStyle(fontSize: zsp(28),color: Color(0xFF636363)),)
  60. ],
  61. ),
  62. ),
  63. Container(
  64. width: (MediaQuery.of(context).size.width-wsp(100))/2,
  65. height: hsp(83),
  66. color: Color(0xFFF8F8F8),
  67. alignment: Alignment.center,
  68. child: Row(
  69. mainAxisSize: MainAxisSize.min,
  70. children: [
  71. Image(image: AssetImage('lib/images/wechat.png'),height: hsp(50),width: hsp(50),),
  72. Text(' 微信好友',style: TextStyle(fontSize: zsp(28),color: Color(0xFF636363)),)
  73. ],
  74. ),
  75. )
  76. ],
  77. ),
  78. )
  79. ],
  80. ),
  81. );
  82. }
  83. _getNewsDetailData() async{
  84. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/headline/details',parameter: {'id':widget.newId},isLoading: true);
  85. if(dict!=null){
  86. setState(() {
  87. _dict = dict['data'];
  88. });
  89. }
  90. }
  91. }