w-R
3 years ago
33 changed files with 2915 additions and 915 deletions
@ -0,0 +1,176 @@
|
||||
import 'package:dio/dio.dart'; |
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
||||
import 'package:huixiang/generated/l10n.dart'; |
||||
import 'package:huixiang/retrofit/data/article.dart'; |
||||
import 'package:huixiang/retrofit/data/banner.dart'; |
||||
import 'package:huixiang/retrofit/data/base_data.dart'; |
||||
import 'package:huixiang/retrofit/data/page.dart'; |
||||
import 'package:huixiang/retrofit/retrofit_api.dart'; |
||||
import 'package:huixiang/utils/font_weight.dart'; |
||||
import 'package:huixiang/view_widget/classic_header.dart'; |
||||
import 'package:huixiang/view_widget/custom_image.dart'; |
||||
import 'package:huixiang/view_widget/hot_item.dart'; |
||||
import 'package:huixiang/view_widget/my_appbar.dart'; |
||||
import 'package:huixiang/view_widget/my_footer.dart'; |
||||
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
||||
import 'package:shared_preferences/shared_preferences.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
|
||||
class ArticleList extends StatefulWidget { |
||||
final List<Article> articles; |
||||
|
||||
ArticleList(this.articles,); |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _ArticleList(); |
||||
} |
||||
} |
||||
|
||||
class _ArticleList extends State<ArticleList> { |
||||
ApiService apiService; |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
|
||||
SharedPreferences.getInstance().then((value) => { |
||||
apiService = ApiService(Dio(), |
||||
context: context, token: value.getString("token")), |
||||
}); |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Container( |
||||
margin: EdgeInsets.only(top:20,left:16,right: 16), |
||||
child:Column( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
mainAxisAlignment: MainAxisAlignment.spaceAround, |
||||
children: [ |
||||
Padding(padding:EdgeInsets.only(bottom: 12), |
||||
child:Text( |
||||
"最新文章", |
||||
overflow: TextOverflow.ellipsis, |
||||
maxLines: 2, |
||||
style: TextStyle( |
||||
fontSize: 15.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Colors.black, |
||||
), |
||||
)), |
||||
ListView.builder( |
||||
padding: EdgeInsets.zero, |
||||
itemCount: widget.articles.length, |
||||
scrollDirection: Axis.vertical, |
||||
shrinkWrap: true, |
||||
physics: NeverScrollableScrollPhysics(), |
||||
itemBuilder: (context, position) { |
||||
return GestureDetector( |
||||
onTap: () { |
||||
Navigator.of(context).pushNamed( |
||||
'/router/web_page', |
||||
arguments: {"articleId": widget.articles[position].id}); |
||||
widget.articles[position].viewers = (widget.articles[position].viewers + 1); |
||||
setState(() {}); |
||||
}, |
||||
child: articleItem(widget.articles[position],position), |
||||
); |
||||
}, |
||||
), |
||||
], |
||||
)); |
||||
} |
||||
|
||||
Widget articleItem(Article articles,position) { |
||||
return Container( |
||||
width: double.infinity, |
||||
padding: EdgeInsets.all(16), |
||||
margin: EdgeInsets.only(bottom: 12), |
||||
color: Colors.white, |
||||
child:Row( |
||||
children: [ |
||||
Expanded(child: Column( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
mainAxisAlignment: MainAxisAlignment.spaceAround, |
||||
children: [ |
||||
Text( |
||||
widget?.articles[position]?.mainTitle ?? "", |
||||
overflow: TextOverflow.ellipsis, |
||||
maxLines: 1, |
||||
style: TextStyle( |
||||
fontSize: 14.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Colors.black, |
||||
), |
||||
), |
||||
SizedBox(height:5), |
||||
Text( |
||||
widget?.articles[position]?.viceTitle ?? "", |
||||
// overflow: TextOverflow.ellipsis, |
||||
// maxLines: 1, |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
color: Color(0xFF353535), |
||||
), |
||||
), |
||||
SizedBox(height: 10), |
||||
Row( |
||||
children: [ |
||||
Text( |
||||
(widget.articles[position] != null && |
||||
widget.articles[position].author != null) |
||||
? widget.articles[position].author.name |
||||
: "", |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Color(0xFF8E8E8E), |
||||
), |
||||
), |
||||
SizedBox(width:8), |
||||
Image.asset( |
||||
"assets/image/browse.png", |
||||
width: 14, |
||||
height: 14, |
||||
color: Color(0xFF808080), |
||||
), |
||||
Expanded(child: Text( |
||||
"${widget?.articles[position]?.viewers}" |
||||
?? "", |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
color: Color(0xFF8D8D8D), |
||||
), |
||||
)), |
||||
Text( |
||||
widget?.articles[position]?.createTime?.split(" ")[0] |
||||
?? "", |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
color: Color(0xFF8D8D8D), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
], |
||||
),), |
||||
SizedBox(width:12), |
||||
MImage( |
||||
widget?.articles[position]?.coverImg ?? "", |
||||
fit: BoxFit.cover, |
||||
radius: BorderRadius.all(Radius.circular(2)), |
||||
width:96, |
||||
height:96, |
||||
), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,239 @@
|
||||
import 'package:dio/dio.dart'; |
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter/rendering.dart'; |
||||
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
||||
import 'package:huixiang/community/headlines/headlines_banner.dart'; |
||||
import 'package:huixiang/community/headlines/headlines_collection.dart'; |
||||
import 'package:huixiang/main.dart'; |
||||
import 'package:huixiang/retrofit/data/article.dart'; |
||||
import 'package:huixiang/retrofit/data/banner.dart'; |
||||
import 'package:huixiang/retrofit/data/base_data.dart'; |
||||
import 'package:huixiang/retrofit/data/brand.dart'; |
||||
import 'package:huixiang/retrofit/data/category_select_list.dart'; |
||||
import 'package:huixiang/retrofit/data/collect_class_list.dart'; |
||||
import 'package:huixiang/retrofit/data/course_list.dart'; |
||||
import 'package:huixiang/retrofit/data/headlines_list.dart'; |
||||
import 'package:huixiang/retrofit/data/headlines_list_details.dart'; |
||||
import 'package:huixiang/retrofit/data/page.dart'; |
||||
import 'package:huixiang/retrofit/retrofit_api.dart'; |
||||
import 'package:huixiang/utils/event_type.dart'; |
||||
import 'package:huixiang/view_widget/classic_header.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
import 'package:huixiang/view_widget/store_title_tab.dart'; |
||||
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
||||
import 'package:shared_preferences/shared_preferences.dart'; |
||||
|
||||
import 'article_list.dart'; |
||||
|
||||
class ArticlePage extends StatefulWidget { |
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _ArticlePage(); |
||||
} |
||||
} |
||||
|
||||
class _ArticlePage extends State<ArticlePage> |
||||
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { |
||||
final ScrollController scrollController = ScrollController(); |
||||
final RefreshController refreshController = RefreshController(); |
||||
|
||||
ApiService apiService; |
||||
List<GlobalKey> globaKeys = []; |
||||
List<Brand> brands = []; |
||||
List<BannerData> bannerData = []; |
||||
List<Article> articles = []; |
||||
List<HeadlinesList> headlines = []; |
||||
int pageNum = 1; |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
|
||||
eventBus.on<EventType>().listen((event) { |
||||
print("object: ArticlePage"); |
||||
if (event.type < 3) { |
||||
setState(() {}); |
||||
} |
||||
}); |
||||
queryArticleList(); |
||||
queryHeadlinesBanner(); |
||||
queryHeadlinesList(); |
||||
} |
||||
|
||||
@override |
||||
void dispose() { |
||||
super.dispose(); |
||||
refreshController.dispose(); |
||||
} |
||||
|
||||
///banner |
||||
queryHeadlinesBanner() async { |
||||
if (apiService == null) { |
||||
SharedPreferences value = await SharedPreferences.getInstance(); |
||||
apiService = ApiService( |
||||
Dio(), |
||||
context: context, |
||||
token: value.getString("token"), |
||||
); |
||||
} |
||||
BaseData<PageInfo<BannerData>> baseData = |
||||
await apiService.queryBanner({ |
||||
"model": {"type": "INFORMATION"}, |
||||
}).catchError((onError) { |
||||
refreshController.refreshFailed(); |
||||
}); |
||||
if (baseData != null && baseData.isSuccess) { |
||||
bannerData.clear(); |
||||
bannerData.addAll(baseData.data.records); |
||||
refreshController.refreshCompleted(); |
||||
} else { |
||||
refreshController.refreshFailed(); |
||||
// SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
||||
} |
||||
EasyLoading.dismiss(); |
||||
} |
||||
|
||||
///文章列表 |
||||
queryArticleList() async { |
||||
if (apiService == null) { |
||||
SharedPreferences value = await SharedPreferences.getInstance(); |
||||
apiService = ApiService( |
||||
Dio(), |
||||
context: context, |
||||
token: value.getString("token"), |
||||
); |
||||
} |
||||
BaseData<PageInfo<Article>> baseData = await apiService.queryArticle({ |
||||
"pageNum": pageNum, |
||||
"pageSize": 10, |
||||
"searchKey": "", |
||||
"state": 1, |
||||
"type": 2 |
||||
}).catchError((onError){ |
||||
refreshController.refreshFailed(); |
||||
refreshController.loadFailed(); |
||||
}); |
||||
if (baseData != null && baseData.isSuccess) { |
||||
refreshController.refreshCompleted(); |
||||
refreshController.loadComplete(); |
||||
if(pageNum == 1) { |
||||
articles.clear(); |
||||
} |
||||
articles.addAll(baseData.data.list); |
||||
if (baseData.data.pageNum == baseData.data.pages) { |
||||
refreshController.loadNoData(); |
||||
} else { |
||||
pageNum += 1; |
||||
} |
||||
setState(() {}); |
||||
} else { |
||||
refreshController.refreshFailed(); |
||||
refreshController.loadFailed(); |
||||
} |
||||
} |
||||
|
||||
///文章合集列表 |
||||
queryHeadlinesList() async { |
||||
if (apiService == null) { |
||||
SharedPreferences value = await SharedPreferences.getInstance(); |
||||
apiService = ApiService( |
||||
Dio(), |
||||
context: context, |
||||
token: value.getString("token"), |
||||
); |
||||
} |
||||
BaseData<List<HeadlinesList>> baseData = await apiService.headlinesList().catchError((onError) {}); |
||||
if (baseData != null && baseData.isSuccess) { |
||||
setState(() { |
||||
headlines.clear(); |
||||
headlines.addAll(baseData.data); |
||||
headlines.forEach((element) { |
||||
// collectCourse(element.id); |
||||
}); |
||||
}); |
||||
} |
||||
EasyLoading.dismiss(); |
||||
} |
||||
|
||||
_onRefresh(){ |
||||
queryHeadlinesBanner(); |
||||
queryHeadlinesList();//分类列表 |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
super.build(context); |
||||
return |
||||
Stack( |
||||
children: [ |
||||
Positioned( |
||||
child: Container( |
||||
child: SmartRefresher( |
||||
controller: refreshController, |
||||
enablePullDown: true, |
||||
enablePullUp: false, |
||||
header: MyHeader(), |
||||
physics: ClampingScrollPhysics(), |
||||
onRefresh: _onRefresh, |
||||
scrollController: scrollController, |
||||
child: Container( |
||||
child: SingleChildScrollView( |
||||
physics: NeverScrollableScrollPhysics(), |
||||
child: Container( |
||||
color: Color(0xFFF7F7F7), |
||||
margin: EdgeInsets.only(top: 16.h), |
||||
child: Column( |
||||
children: classChildItem(), |
||||
), |
||||
), |
||||
), |
||||
), |
||||
), |
||||
), |
||||
bottom:0, |
||||
top: 0, |
||||
left: 0, |
||||
right: 0, |
||||
), |
||||
if (brands != null && brands.length > 0) |
||||
Positioned( |
||||
child: Container( |
||||
color: Colors.white, |
||||
child: StoreTitleTab( |
||||
brands, |
||||
globaKeys, |
||||
scrollController, |
||||
isScroll: true, |
||||
), |
||||
), |
||||
top: 0, |
||||
left: 0, |
||||
right: 0, |
||||
), |
||||
], |
||||
); |
||||
} |
||||
|
||||
List<Widget> classChildItem() { |
||||
var widgets = <Widget>[ |
||||
///课程banner |
||||
HeadlinesBanner(bannerData,), |
||||
|
||||
SizedBox(height: 28), |
||||
|
||||
///头条合集列表 |
||||
HeadlinesCollection(headlines,articles), |
||||
|
||||
///文章列表 |
||||
ArticleList(articles), |
||||
|
||||
|
||||
]; |
||||
|
||||
return widgets; |
||||
} |
||||
|
||||
@override |
||||
bool get wantKeepAlive => true; |
||||
} |
@ -0,0 +1,119 @@
|
||||
|
||||
import 'dart:convert'; |
||||
|
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_swiper/flutter_swiper.dart'; |
||||
import 'package:huixiang/retrofit/data/banner.dart'; |
||||
import 'package:huixiang/retrofit/data/base_data.dart'; |
||||
import 'package:huixiang/retrofit/data/page.dart'; |
||||
import 'package:huixiang/retrofit/retrofit_api.dart'; |
||||
import 'package:huixiang/view_widget/custom_image.dart'; |
||||
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
||||
|
||||
class HeadlinesBanner extends StatefulWidget { |
||||
|
||||
final List<BannerData> bannerData; |
||||
|
||||
HeadlinesBanner(this.bannerData); |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _HeadlinesBanner(); |
||||
} |
||||
|
||||
} |
||||
|
||||
class _HeadlinesBanner extends State<HeadlinesBanner> { |
||||
ApiService apiService; |
||||
final RefreshController refreshController = RefreshController(); |
||||
List<BannerData> bannerData = []; |
||||
|
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Container( |
||||
child: AspectRatio( |
||||
aspectRatio: 2.08, |
||||
child: Swiper( |
||||
viewportFraction: 0.88, |
||||
scale: 0.93, |
||||
pagination: SwiperPagination( |
||||
alignment: Alignment.bottomCenter, |
||||
builder: DotSwiperPaginationBuilder( |
||||
size: 8, |
||||
activeSize: 8, |
||||
space: 5, |
||||
activeColor: Colors.black, |
||||
color: Colors.black.withAlpha(76), |
||||
), |
||||
), |
||||
physics: BouncingScrollPhysics(), |
||||
itemBuilder: (context, position) { |
||||
return InkWell( |
||||
onTap: () { |
||||
bannerClick(widget.bannerData[position]); |
||||
}, |
||||
child: MImage( |
||||
(widget.bannerData != null && position < widget.bannerData.length) |
||||
? widget.bannerData[position].imgUrl |
||||
: "", |
||||
fit: BoxFit.cover, |
||||
radius: BorderRadius.circular(8), |
||||
errorSrc: "assets/image/default_2_1.png", |
||||
fadeSrc: "assets/image/default_2_1.png", |
||||
), |
||||
); |
||||
}, |
||||
itemCount: (widget.bannerData != null && widget.bannerData.length > 0) |
||||
? widget.bannerData.length |
||||
: 1), |
||||
), |
||||
); |
||||
} |
||||
|
||||
/// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章,4:页面跳转,5:课程) |
||||
bannerClick(BannerData bannerData) async { |
||||
switch (bannerData.contentType) { |
||||
case 1: |
||||
Navigator.of(context).pushNamed('/router/integral_store_page', |
||||
arguments: {"goodsId": bannerData.content}); |
||||
break; |
||||
case 2: |
||||
Navigator.of(context) |
||||
.pushNamed('/router/web_page', arguments: { |
||||
"activityId": bannerData.content, |
||||
}); |
||||
break; |
||||
case 3: |
||||
Navigator.of(context) |
||||
.pushNamed('/router/web_page', arguments: { |
||||
"articleId": bannerData.content, |
||||
}); |
||||
break; |
||||
case 4: |
||||
String router = bannerData.content; |
||||
if (router.contains("?")) { |
||||
String params = router.substring(router.indexOf("?")); |
||||
params = params.replaceAll("?", ""); |
||||
Map map = jsonDecode(params); |
||||
Navigator.of(context).pushNamed(router, arguments: map); |
||||
} else { |
||||
Navigator.of(context).pushNamed(router); |
||||
} |
||||
break; |
||||
case 5: |
||||
Navigator.of(context) |
||||
.pushNamed('/router/class_details', arguments: { |
||||
"id": bannerData.content, |
||||
}); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,166 @@
|
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; |
||||
import 'package:huixiang/retrofit/data/article.dart'; |
||||
import 'package:huixiang/retrofit/data/collect_class_list.dart'; |
||||
import 'package:huixiang/retrofit/data/course_list.dart'; |
||||
import 'package:huixiang/retrofit/data/headlines_list.dart'; |
||||
import 'package:huixiang/retrofit/retrofit_api.dart'; |
||||
import 'package:huixiang/utils/font_weight.dart'; |
||||
import 'package:huixiang/view_widget/custom_image.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
|
||||
class HeadlinesCollection extends StatefulWidget { |
||||
final List<HeadlinesList> headlines; |
||||
final List<Article> articles; |
||||
|
||||
HeadlinesCollection(this.headlines,this.articles); |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _HeadlinesCollection(); |
||||
} |
||||
} |
||||
|
||||
class _HeadlinesCollection extends State<HeadlinesCollection> { |
||||
ApiService apiService; |
||||
BMFCoordinate latLng; |
||||
|
||||
final TextEditingController editingController = TextEditingController(); |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Container( |
||||
height: 100, |
||||
margin: EdgeInsets.only(top:10), |
||||
child: ListView.builder( |
||||
scrollDirection: Axis.horizontal, |
||||
physics: BouncingScrollPhysics(), |
||||
padding: EdgeInsets.symmetric(horizontal: 10), |
||||
itemCount:widget.headlines == null ? 0 : widget.headlines.length, |
||||
itemBuilder: (context, position) { |
||||
return GestureDetector( |
||||
onTap: () { |
||||
Navigator.of(context).pushNamed( |
||||
'/router/headlines_column_details', |
||||
arguments: {"id":widget.headlines[position].id, |
||||
"articles":widget.articles}); |
||||
}, |
||||
child: headlinesCollectionItem(widget.headlines[position]), |
||||
); |
||||
}, |
||||
), |
||||
); |
||||
} |
||||
|
||||
Widget headlinesCollectionItem(HeadlinesList headlines) { |
||||
return Container( |
||||
width: 225.w, |
||||
height:110.h, |
||||
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.circular(4), |
||||
boxShadow: [ |
||||
BoxShadow( |
||||
color: Colors.black.withAlpha(10), |
||||
offset: Offset(0, 3), |
||||
blurRadius: 14, |
||||
spreadRadius: 0, |
||||
) |
||||
], |
||||
color: Colors.black, |
||||
), |
||||
margin: EdgeInsets.symmetric( |
||||
horizontal:6, |
||||
), |
||||
child: Stack( |
||||
children: [ |
||||
ClipRRect( |
||||
child: Opacity( |
||||
opacity: 0.8, |
||||
child: MImage( |
||||
headlines?.coverImg ?? "", |
||||
width: 225.w, |
||||
height: 110.h, |
||||
fit: BoxFit.fill, |
||||
errorSrc: "assets/image/default_1.png", |
||||
fadeSrc: "assets/image/default_1.png", |
||||
), |
||||
), |
||||
borderRadius: BorderRadius.vertical( |
||||
top: Radius.circular(4), |
||||
), |
||||
), |
||||
Container( |
||||
padding: EdgeInsets.all(12), |
||||
child: Column(children: [ |
||||
Expanded(child: Row( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
mainAxisAlignment: MainAxisAlignment.spaceAround, |
||||
children: [ |
||||
Container( |
||||
margin: EdgeInsets.only(right:4), |
||||
padding:EdgeInsets.only(left:2,right:2), |
||||
height: 16.h, |
||||
alignment: Alignment.center, |
||||
decoration: BoxDecoration( |
||||
borderRadius: |
||||
BorderRadius.circular(2), |
||||
color: Color(0xFF32A060), |
||||
), |
||||
child: Text( |
||||
"专栏", |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Colors.white, |
||||
), |
||||
), |
||||
), |
||||
Expanded(child:Text( |
||||
headlines?.name ?? "", |
||||
overflow: TextOverflow.ellipsis, |
||||
maxLines: 2, |
||||
style: TextStyle( |
||||
fontSize: 15.sp, |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
color: Colors.white, |
||||
), |
||||
),), |
||||
],)), |
||||
Row( |
||||
children: [ |
||||
Expanded(child:Text( |
||||
"更新3篇", |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Colors.white, |
||||
), |
||||
)), |
||||
Text( |
||||
"查看专栏", |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
color: Colors.white, |
||||
), |
||||
), |
||||
SizedBox(width: 2), |
||||
Image.asset( |
||||
"assets/image/t_right.png", |
||||
width: 14, |
||||
height: 14, |
||||
), |
||||
],), |
||||
],), |
||||
), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,344 @@
|
||||
import 'package:dio/dio.dart'; |
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
||||
import 'package:huixiang/retrofit/data/article.dart'; |
||||
import 'package:huixiang/retrofit/data/base_data.dart'; |
||||
import 'package:huixiang/retrofit/data/headlines_list.dart'; |
||||
import 'package:huixiang/retrofit/data/headlines_list_details.dart'; |
||||
import 'package:huixiang/retrofit/retrofit_api.dart'; |
||||
import 'package:huixiang/utils/font_weight.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
import 'package:huixiang/view_widget/custom_image.dart'; |
||||
import 'package:shared_preferences/shared_preferences.dart'; |
||||
|
||||
class HeadlinesColumnDetails extends StatefulWidget { |
||||
final Map<String, dynamic> arguments; |
||||
|
||||
HeadlinesColumnDetails({this.arguments}); |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _HeadlinesColumnDetails(); |
||||
} |
||||
} |
||||
|
||||
class _HeadlinesColumnDetails extends State<HeadlinesColumnDetails> |
||||
with WidgetsBindingObserver { |
||||
ApiService apiService; |
||||
List<Article> articles; |
||||
HeadlinesListDetails headlinesListDetails; |
||||
List<HeadlinesList> headlines = []; |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
articles = widget.arguments["articles"]; |
||||
WidgetsBinding.instance.addObserver(this); |
||||
queryHeadlinesDetails(widget.arguments["id"]); |
||||
queryHeadlinesList(widget.arguments["id"]); |
||||
} |
||||
|
||||
///文章合集详情 |
||||
queryHeadlinesDetails(id) async { |
||||
if (apiService == null) { |
||||
SharedPreferences value = await SharedPreferences.getInstance(); |
||||
apiService = ApiService( |
||||
Dio(), |
||||
context: context, |
||||
token: value.getString("token"), |
||||
); |
||||
} |
||||
BaseData<HeadlinesListDetails> baseData = |
||||
await apiService.headlinesDetails(id).catchError((error) {}); |
||||
if (baseData != null && baseData.isSuccess) { |
||||
setState(() { |
||||
headlinesListDetails = baseData.data; |
||||
}); |
||||
} |
||||
} |
||||
|
||||
///文章合集列表 |
||||
queryHeadlinesList(id) async { |
||||
if (apiService == null) { |
||||
SharedPreferences value = await SharedPreferences.getInstance(); |
||||
apiService = ApiService( |
||||
Dio(), |
||||
context: context, |
||||
token: value.getString("token"), |
||||
); |
||||
} |
||||
BaseData<List<HeadlinesList>> baseData = await apiService.headlinesList().catchError((onError) {}); |
||||
if (baseData != null && baseData.isSuccess) { |
||||
setState(() { |
||||
headlines.clear(); |
||||
headlines.addAll(baseData.data); |
||||
headlines.forEach((element) { |
||||
// collectCourse(element.id); |
||||
}); |
||||
}); |
||||
} |
||||
EasyLoading.dismiss(); |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Scaffold( |
||||
body: Container( |
||||
child: Column( |
||||
children: [ |
||||
Expanded( |
||||
child: SingleChildScrollView( |
||||
physics: BouncingScrollPhysics(), |
||||
child: Column( |
||||
children: [ |
||||
Stack( |
||||
alignment: Alignment.bottomCenter, |
||||
children: [ |
||||
Stack( |
||||
children: [ |
||||
Positioned(child: |
||||
MImage( |
||||
headlinesListDetails?.coverImg ?? "", |
||||
width:double.infinity, |
||||
height: 260.h, |
||||
fit: BoxFit.cover, |
||||
errorSrc: "assets/image/default_1.png", |
||||
fadeSrc: "assets/image/default_1.png", |
||||
), |
||||
), |
||||
Container( |
||||
margin: EdgeInsets.only( |
||||
top: 50.h, left: 16.w, right: 16.w), |
||||
decoration: BoxDecoration( |
||||
color: Colors.transparent, |
||||
), |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
||||
crossAxisAlignment: CrossAxisAlignment.center, |
||||
children: [ |
||||
GestureDetector( |
||||
child: Image.asset( |
||||
"assets/image/integral_return.png", |
||||
width: 24, |
||||
height: 24, |
||||
), |
||||
onTap: () { |
||||
Navigator.of(context).pop(); |
||||
}, |
||||
), |
||||
], |
||||
), |
||||
), |
||||
], |
||||
), |
||||
Container( |
||||
child: Column( |
||||
children: [ |
||||
Padding(padding:EdgeInsets.only(left: 16), |
||||
child:Row( |
||||
children: [ |
||||
Container( |
||||
margin: EdgeInsets.only(right:4), |
||||
padding:EdgeInsets.only(left:2,right:2), |
||||
height:20.h, |
||||
alignment: Alignment.center, |
||||
decoration: BoxDecoration( |
||||
borderRadius: |
||||
BorderRadius.circular(2), |
||||
color: Color(0xFF32A060), |
||||
), |
||||
child: Text( |
||||
"专栏", |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Colors.white, |
||||
), |
||||
), |
||||
), |
||||
SizedBox( |
||||
width: 6.w, |
||||
), |
||||
Expanded( |
||||
child: Text( |
||||
headlinesListDetails?.name ?? "", |
||||
overflow: TextOverflow.ellipsis, |
||||
maxLines: 2, |
||||
style: TextStyle( |
||||
fontSize: 18.sp, |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
color: Colors.white, |
||||
), |
||||
), |
||||
flex: 1, |
||||
) |
||||
], |
||||
),), |
||||
Container( |
||||
width: double.infinity, |
||||
decoration: BoxDecoration( |
||||
border: Border.all( |
||||
width: 0, |
||||
color: Colors.white, |
||||
), |
||||
color: Colors.white, |
||||
borderRadius: new BorderRadius.only( |
||||
topLeft: Radius.circular(8.0), |
||||
topRight: Radius.circular(8.0), |
||||
), |
||||
), |
||||
margin: EdgeInsets.only(top: 16), |
||||
// padding: EdgeInsets.all(16), |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.start, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Padding(padding:EdgeInsets.all(16), |
||||
child: Text( |
||||
"简介:${headlinesListDetails?.introduce ?? ""}", |
||||
overflow: TextOverflow.ellipsis, |
||||
maxLines: 2, |
||||
style: TextStyle( |
||||
fontSize: 14.sp, |
||||
fontWeight: MyFontWeight.medium , |
||||
color: Colors.black, |
||||
), |
||||
)), |
||||
], |
||||
), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
], |
||||
), |
||||
ListView.builder( |
||||
padding: EdgeInsets.zero, |
||||
itemCount:headlines == null ? 0 : headlines.length, |
||||
scrollDirection: Axis.vertical, |
||||
shrinkWrap: true, |
||||
physics: NeverScrollableScrollPhysics(), |
||||
itemBuilder: (context, position) { |
||||
return GestureDetector( |
||||
onTap: () { |
||||
Navigator.of(context).pushNamed( |
||||
'/router/web_page', |
||||
arguments: {"articleId": articles[position].id}); |
||||
articles[position].viewers = (articles[position].viewers + 1); |
||||
setState(() {} |
||||
); |
||||
}, |
||||
child: articleColumnItem(articles[position]), |
||||
); |
||||
}, |
||||
), |
||||
], |
||||
), |
||||
), |
||||
flex: 1, |
||||
), |
||||
], |
||||
), |
||||
), |
||||
); |
||||
} |
||||
|
||||
Widget articleColumnItem(Article articles) { |
||||
return Container( |
||||
width: double.infinity, |
||||
// padding: EdgeInsets.all(16), |
||||
color: Colors.white, |
||||
child:Column( |
||||
children: [ |
||||
Container( |
||||
// margin: EdgeInsets.only(top: 16,bottom: 16), |
||||
width: double.infinity, |
||||
height: 0.5.h, |
||||
color: Color(0xFFF5F5F5), |
||||
), |
||||
Padding(padding: EdgeInsets.all(16), |
||||
child:Row( |
||||
children: [ |
||||
Expanded(child: Column( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
mainAxisAlignment: MainAxisAlignment.spaceAround, |
||||
children: [ |
||||
Text( |
||||
articles?.mainTitle ?? "", |
||||
overflow: TextOverflow.ellipsis, |
||||
maxLines: 1, |
||||
style: TextStyle( |
||||
fontSize: 14.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Colors.black, |
||||
), |
||||
), |
||||
SizedBox(height:5), |
||||
Text( |
||||
articles?.viceTitle ?? "", |
||||
// overflow: TextOverflow.ellipsis, |
||||
// maxLines: 1, |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
color: Color(0xFF353535), |
||||
), |
||||
), |
||||
SizedBox(height: 10), |
||||
Row( |
||||
children: [ |
||||
Text( |
||||
(articles != null && |
||||
articles.author != null) |
||||
? articles.author.name |
||||
: "", |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Color(0xFF8E8E8E), |
||||
), |
||||
), |
||||
SizedBox(width:8), |
||||
Image.asset( |
||||
"assets/image/browse.png", |
||||
width: 14, |
||||
height: 14, |
||||
color: Color(0xFF808080), |
||||
), |
||||
Expanded(child: Text( |
||||
"${articles?.viewers}" |
||||
?? "", |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
color: Color(0xFF8D8D8D), |
||||
), |
||||
)), |
||||
Text( |
||||
articles?.createTime ?? "", |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
color: Color(0xFF8D8D8D), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
], |
||||
),), |
||||
SizedBox(width:12), |
||||
MImage( |
||||
articles?.coverImg ?? "", |
||||
fit: BoxFit.cover, |
||||
radius: BorderRadius.all(Radius.circular(2)), |
||||
width:96, |
||||
height:96, |
||||
), |
||||
], |
||||
)), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,99 @@
|
||||
/// id : "1463790611994771456" |
||||
/// createTime : "2021-11-25 16:44:12" |
||||
/// createUser : "1" |
||||
/// updateTime : "2021-11-25 16:45:55" |
||||
/// updateUser : "1" |
||||
/// name : "一心回乡" |
||||
/// introduce : "22" |
||||
/// coverImg : "https://pos.upload.gznl.top/0000/2021/11/899b578b-f594-42f7-91e1-cebc5dbc39da.png" |
||||
/// bannerImg : "https://pos.upload.gznl.top/0000/2021/11/7a41ebe2-d3b1-44ea-9cda-2e952b58d54c.png" |
||||
/// sort : 0 |
||||
/// isDelete : 0 |
||||
/// tenantCode : "admin" |
||||
|
||||
class HeadlinesList { |
||||
HeadlinesList({ |
||||
String id, |
||||
String createTime, |
||||
String createUser, |
||||
String updateTime, |
||||
String updateUser, |
||||
String name, |
||||
String introduce, |
||||
String coverImg, |
||||
String bannerImg, |
||||
int sort, |
||||
int isDelete, |
||||
String tenantCode,}){ |
||||
_id = id; |
||||
_createTime = createTime; |
||||
_createUser = createUser; |
||||
_updateTime = updateTime; |
||||
_updateUser = updateUser; |
||||
_name = name; |
||||
_introduce = introduce; |
||||
_coverImg = coverImg; |
||||
_bannerImg = bannerImg; |
||||
_sort = sort; |
||||
_isDelete = isDelete; |
||||
_tenantCode = tenantCode; |
||||
} |
||||
|
||||
HeadlinesList.fromJson(dynamic json) { |
||||
_id = json['id']; |
||||
_createTime = json['createTime']; |
||||
_createUser = json['createUser']; |
||||
_updateTime = json['updateTime']; |
||||
_updateUser = json['updateUser']; |
||||
_name = json['name']; |
||||
_introduce = json['introduce']; |
||||
_coverImg = json['coverImg']; |
||||
_bannerImg = json['bannerImg']; |
||||
_sort = json['sort']; |
||||
_isDelete = json['isDelete']; |
||||
_tenantCode = json['tenantCode']; |
||||
} |
||||
String _id; |
||||
String _createTime; |
||||
String _createUser; |
||||
String _updateTime; |
||||
String _updateUser; |
||||
String _name; |
||||
String _introduce; |
||||
String _coverImg; |
||||
String _bannerImg; |
||||
int _sort; |
||||
int _isDelete; |
||||
String _tenantCode; |
||||
|
||||
String get id => _id; |
||||
String get createTime => _createTime; |
||||
String get createUser => _createUser; |
||||
String get updateTime => _updateTime; |
||||
String get updateUser => _updateUser; |
||||
String get name => _name; |
||||
String get introduce => _introduce; |
||||
String get coverImg => _coverImg; |
||||
String get bannerImg => _bannerImg; |
||||
int get sort => _sort; |
||||
int get isDelete => _isDelete; |
||||
String get tenantCode => _tenantCode; |
||||
|
||||
Map<String, dynamic> toJson() { |
||||
final map = <String, dynamic>{}; |
||||
map['id'] = _id; |
||||
map['createTime'] = _createTime; |
||||
map['createUser'] = _createUser; |
||||
map['updateTime'] = _updateTime; |
||||
map['updateUser'] = _updateUser; |
||||
map['name'] = _name; |
||||
map['introduce'] = _introduce; |
||||
map['coverImg'] = _coverImg; |
||||
map['bannerImg'] = _bannerImg; |
||||
map['sort'] = _sort; |
||||
map['isDelete'] = _isDelete; |
||||
map['tenantCode'] = _tenantCode; |
||||
return map; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,99 @@
|
||||
/// id : "1463790611994771456" |
||||
/// createTime : "2021-11-25 16:44:12" |
||||
/// createUser : "1" |
||||
/// updateTime : "2021-11-25 16:45:55" |
||||
/// updateUser : "1" |
||||
/// name : "一心回乡" |
||||
/// introduce : "22" |
||||
/// coverImg : "https://pos.upload.gznl.top/0000/2021/11/899b578b-f594-42f7-91e1-cebc5dbc39da.png" |
||||
/// bannerImg : "https://pos.upload.gznl.top/0000/2021/11/7a41ebe2-d3b1-44ea-9cda-2e952b58d54c.png" |
||||
/// sort : 0 |
||||
/// isDelete : 0 |
||||
/// tenantCode : "admin" |
||||
|
||||
class HeadlinesListDetails { |
||||
HeadlinesListDetails({ |
||||
String id, |
||||
String createTime, |
||||
String createUser, |
||||
String updateTime, |
||||
String updateUser, |
||||
String name, |
||||
String introduce, |
||||
String coverImg, |
||||
String bannerImg, |
||||
int sort, |
||||
int isDelete, |
||||
String tenantCode,}){ |
||||
_id = id; |
||||
_createTime = createTime; |
||||
_createUser = createUser; |
||||
_updateTime = updateTime; |
||||
_updateUser = updateUser; |
||||
_name = name; |
||||
_introduce = introduce; |
||||
_coverImg = coverImg; |
||||
_bannerImg = bannerImg; |
||||
_sort = sort; |
||||
_isDelete = isDelete; |
||||
_tenantCode = tenantCode; |
||||
} |
||||
|
||||
HeadlinesListDetails.fromJson(dynamic json) { |
||||
_id = json['id']; |
||||
_createTime = json['createTime']; |
||||
_createUser = json['createUser']; |
||||
_updateTime = json['updateTime']; |
||||
_updateUser = json['updateUser']; |
||||
_name = json['name']; |
||||
_introduce = json['introduce']; |
||||
_coverImg = json['coverImg']; |
||||
_bannerImg = json['bannerImg']; |
||||
_sort = json['sort']; |
||||
_isDelete = json['isDelete']; |
||||
_tenantCode = json['tenantCode']; |
||||
} |
||||
String _id; |
||||
String _createTime; |
||||
String _createUser; |
||||
String _updateTime; |
||||
String _updateUser; |
||||
String _name; |
||||
String _introduce; |
||||
String _coverImg; |
||||
String _bannerImg; |
||||
int _sort; |
||||
int _isDelete; |
||||
String _tenantCode; |
||||
|
||||
String get id => _id; |
||||
String get createTime => _createTime; |
||||
String get createUser => _createUser; |
||||
String get updateTime => _updateTime; |
||||
String get updateUser => _updateUser; |
||||
String get name => _name; |
||||
String get introduce => _introduce; |
||||
String get coverImg => _coverImg; |
||||
String get bannerImg => _bannerImg; |
||||
int get sort => _sort; |
||||
int get isDelete => _isDelete; |
||||
String get tenantCode => _tenantCode; |
||||
|
||||
Map<String, dynamic> toJson() { |
||||
final map = <String, dynamic>{}; |
||||
map['id'] = _id; |
||||
map['createTime'] = _createTime; |
||||
map['createUser'] = _createUser; |
||||
map['updateTime'] = _updateTime; |
||||
map['updateUser'] = _updateUser; |
||||
map['name'] = _name; |
||||
map['introduce'] = _introduce; |
||||
map['coverImg'] = _coverImg; |
||||
map['bannerImg'] = _bannerImg; |
||||
map['sort'] = _sort; |
||||
map['isDelete'] = _isDelete; |
||||
map['tenantCode'] = _tenantCode; |
||||
return map; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,131 @@
|
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
||||
import 'package:huixiang/generated/l10n.dart'; |
||||
import 'package:huixiang/utils/flutter_utils.dart'; |
||||
import 'package:huixiang/utils/font_weight.dart'; |
||||
import 'package:huixiang/view_widget/round_button.dart'; |
||||
|
||||
import 'custom_image.dart'; |
||||
import 'my_appbar.dart'; |
||||
|
||||
class ReceivingMethodDialog extends StatefulWidget { |
||||
final int takeType; |
||||
final Function changeTakeType; |
||||
|
||||
ReceivingMethodDialog(this.takeType,this.changeTakeType); |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _ReceivingMethodDialog(); |
||||
} |
||||
|
||||
} |
||||
|
||||
class _ReceivingMethodDialog extends State<ReceivingMethodDialog> { |
||||
|
||||
|
||||
Widget build(BuildContext context) { |
||||
return Container( |
||||
alignment:Alignment.bottomCenter, |
||||
child: Column( |
||||
crossAxisAlignment: CrossAxisAlignment.end, |
||||
mainAxisAlignment: MainAxisAlignment.end, |
||||
children: [ |
||||
Container( |
||||
margin: |
||||
EdgeInsets.only(top: 26, bottom: 8), |
||||
// alignment: Alignment.center, |
||||
padding: EdgeInsets.only(top: 20,bottom:20), |
||||
decoration: BoxDecoration( |
||||
color: Colors.white, |
||||
boxShadow: [ |
||||
BoxShadow( |
||||
color: Colors.black.withAlpha(12), |
||||
offset: Offset(0, 3), |
||||
blurRadius: 14, |
||||
spreadRadius: 0, |
||||
) |
||||
], |
||||
borderRadius: BorderRadius.all(Radius.circular(8)), |
||||
), |
||||
child: Column( |
||||
children: [ |
||||
Text( |
||||
"请选择商品的领取方式", |
||||
style: TextStyle( |
||||
fontSize: 14.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
color: Color(0xFFA29E9E), |
||||
), |
||||
), |
||||
Container( |
||||
margin: EdgeInsets.only(top:20,bottom: 20), |
||||
height:1, |
||||
color:Color(0xFFF4F4F4), |
||||
), |
||||
GestureDetector( |
||||
onTap:(){ |
||||
widget.changeTakeType(1); |
||||
Navigator.of(context).pop(); |
||||
}, |
||||
child: Text( |
||||
S.of(context).ziti, |
||||
style: TextStyle( |
||||
fontSize: 16.sp, |
||||
fontWeight: widget.takeType == 1 ? MyFontWeight.semi_bold : MyFontWeight.medium, |
||||
color: widget.takeType == 1 ? Color(0xFF32A060):Color(0xFFA29E9E), |
||||
), |
||||
), |
||||
), |
||||
Container( |
||||
margin: EdgeInsets.only(top: 20,bottom: 20), |
||||
height:1, |
||||
color:Color(0xFFF4F4F4), |
||||
), |
||||
GestureDetector( |
||||
onTap:(){ |
||||
widget.changeTakeType(2); |
||||
Navigator.of(context).pop(); |
||||
}, |
||||
child:Text( |
||||
"物流配送", |
||||
style: TextStyle( |
||||
fontSize: 16.sp, |
||||
fontWeight: widget.takeType == 2 ? MyFontWeight.semi_bold : MyFontWeight.medium, |
||||
color: widget.takeType == 2 ? Color(0xFF32A060):Color(0xFFA29E9E), |
||||
), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
GestureDetector( |
||||
onTap: (){ |
||||
Navigator.of(context).pop(); |
||||
}, |
||||
child:Container( |
||||
margin: EdgeInsets.only(top:16), |
||||
height:68.h, |
||||
alignment: Alignment.center, |
||||
decoration: BoxDecoration( |
||||
borderRadius: |
||||
BorderRadius.circular(18), |
||||
color: Color(0xFF32A060), |
||||
), |
||||
child: |
||||
Text( |
||||
S.of(context).quxiao, |
||||
style: TextStyle( |
||||
fontSize: 18.sp, |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
color: Colors.white, |
||||
), |
||||
) |
||||
), |
||||
), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
} |
Loading…
Reference in new issue