repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/movie/movie_list_item_view.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show AppSize, AppColors; import 'package:cached_network_image/cached_network_image.dart'; import 'package:it_resource_exchange_app/model/movie_info.dart'; class MovieListItemView extends StatelessWidget { const MovieListItemView({Key key, this.moive, this.onPressed}) : assert(moive != null), super(key: key); final MovieInfo moive; final VoidCallback onPressed; @override Widget build(BuildContext context) { return GestureDetector( onTap: this.onPressed, child: Container( height: 100.0, padding: EdgeInsets.only(left: 10.0, right: 10.0), decoration: BoxDecoration( border: Border( bottom: BorderSide( width: AppSize.DividerWidth, color: AppColors.DividerColor, ))), child: Row( children: <Widget>[ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( padding: EdgeInsets.only(top: 10.0), child: Text( moive.movieName ?? "", style: TextStyle(fontSize: 15.0, color: AppColors.DarkTextColor), ), ), Container( padding: EdgeInsets.only(bottom: 10.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text('上映日期:${moive.releaseYear}', style: TextStyle( color: AppColors.LightTextColor, fontSize: 12.0)), Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ // Text( // '0', // style: TextStyle( // color: AppColors.LightTextColor, // fontSize: 12.0), // ), // SizedBox(width: 5.0), Image.asset('./assets/imgs/ic_comment.png', width: 16.0, height: 16.0), ], ), ], ), ) ], ), ), Container( padding: EdgeInsets.only(left: 6.0), width: 120.0, height: 80.0, child: CachedNetworkImage( imageUrl: moive.coverUrl, placeholder: (context, url) => Image.asset('./assets/imgs/img_default.png'), fit: BoxFit.cover, ), ), ], )), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/detail/goods_detail_content_view.dart
import 'package:flutter/material.dart'; import '../../model/product_detail.dart'; import 'package:flutter/services.dart'; import 'package:intl/intl.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; import 'package:oktoast/oktoast.dart'; class GoodsDetailContentView extends StatelessWidget { GoodsDetailContentView({Key key, this.productDetail}) : super(key: key); final ProductDetail productDetail; Widget _buildTagView(String text) { return Container( padding: EdgeInsets.symmetric(horizontal: 8, vertical: 2), margin: EdgeInsets.only(left: 8), child: Text(text, style: TextStyle(fontSize: 10)), decoration: BoxDecoration( color: Colors.grey, borderRadius: BorderRadius.circular(3)), ); } Widget _buildPriceView() { // 保留两位小数 String price = productDetail?.price?.toStringAsFixed(2) ?? ""; Row priceRow = Row( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Text("¥", style: TextStyle( color: Colors.red, fontSize: 16, fontWeight: FontWeight.bold)), Text(price, style: TextStyle( color: Colors.red, fontSize: 24, fontWeight: FontWeight.bold)), ], ); List<Widget> widgets = [priceRow]; if (productDetail?.keywords != null && productDetail.keywords.isNotEmpty) { List<String> tags = productDetail.keywords.split(','); List<Widget> tagWidgets = tags.map((tag) => _buildTagView(tag)).toList(); widgets.addAll(tagWidgets); } return Padding( padding: EdgeInsets.only(top: 8), child: Row( children: widgets, ), ); } Widget _buildTopInfoView() { var createDateStr = "未知"; if (productDetail?.createdTime != null) { var format = new DateFormat('yyyy-MM-dd HH:mm'); var date = DateTime.fromMillisecondsSinceEpoch(productDetail.createdTime); createDateStr = format.format(date); } return Container( padding: EdgeInsets.fromLTRB(8, 16, 8, 4), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text(productDetail?.productTitle ?? "", maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18)), SizedBox(height: 5), Text("发布时间: $createDateStr", maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(color: Colors.grey, fontSize: 12)), Divider(color: AppColors.DividerColor), _buildPriceView() ], ), ); } Widget _buildGoodsDescTextView() { return Container( padding: EdgeInsets.symmetric(horizontal: 8), child: Padding( padding: EdgeInsets.only(bottom: 8), child: Text( productDetail?.productDesc?.trim() ?? "", textAlign: TextAlign.left, style: TextStyle(fontSize: 16), ), ), ); } Widget _buildImgsView() { List<Widget> imgWidgets = []; if (productDetail?.imgUrls != null) { List<String> imgUrls = productDetail.imgUrls.split(','); imgWidgets = imgUrls.map((imgUrl) { return Container( alignment: Alignment.center, margin: EdgeInsets.only(top: 8, left: 8, right: 8), child: GestureDetector( onTap: () { print("URL = $imgUrl"); }, child: CachedNetworkImage( width: double.infinity, fit: BoxFit.fill, placeholder: (context, url) { return Container( decoration: BoxDecoration( border: Border.all( color: AppColors.BackgroundColor, width: AppSize.DividerWidth), borderRadius: BorderRadius.circular(2), ), width: double.infinity, height: 250, child: Center( child: Icon( APPIcons.AddImgData, color: AppColors.PrimaryColor, size: 40, ), ), ); }, imageUrl: imgUrl, errorWidget: (context, url, error) => Icon(Icons.error), ), ), ); }).toList(); } return new Column( children: imgWidgets, ); } Widget _buildResourceItemView(String title, String value) { var descWidget = Column(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text(title, style: TextStyle(color: Colors.black, fontSize: 16)), Text(value ?? "", style: TextStyle( color: Colors.grey, fontSize: 14, fontWeight: FontWeight.bold)), ]); return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Expanded(child: descWidget), SizedBox(width: 12), IconButton( icon: Icon(IconData( 0xe6e6, fontFamily: Constant.IconFontFamily, )), onPressed: () { Clipboard.setData(ClipboardData(text: value)); showToast("已复制到系统剪贴板"); }, ) ], ); } Widget _buildResourceView() { List<Widget> itemWidgets = [Divider(color: AppColors.DividerColor)]; if (productDetail?.productAddressUrl != null) { itemWidgets.add(_buildResourceItemView( "资源地址:", productDetail?.productAddressUrl ?? "")); itemWidgets.add(SizedBox(height: 10)); } if (productDetail?.productAddressPassword != null) { itemWidgets.add(_buildResourceItemView( "资源密码:", productDetail?.productAddressPassword ?? "")); itemWidgets.add(SizedBox(height: 6)); } return Container( margin: EdgeInsets.fromLTRB(8, 8, 8, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: itemWidgets, ), ); } @override Widget build(BuildContext context) { return Column( children: <Widget>[ _buildTopInfoView(), _buildGoodsDescTextView(), _buildImgsView(), _buildResourceView(), Container( color: AppColors.DividerColor, height: 5, ) ], ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/detail/goods_detail_page.dart
import 'dart:collection'; import 'package:flutter/material.dart'; import 'dart:async'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:it_resource_exchange_app/model/base_result.dart'; import 'package:it_resource_exchange_app/model/comment_model.dart'; import 'package:it_resource_exchange_app/net/network_utils.dart'; import 'package:it_resource_exchange_app/utils/user_utils.dart'; import 'package:it_resource_exchange_app/vo/comment_vo.dart'; import 'package:it_resource_exchange_app/widgets/indicator_factory.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import '../../model/product_detail.dart'; import 'package:oktoast/oktoast.dart'; import 'package:it_resource_exchange_app/widgets/load_state_layout_widget.dart'; import 'comment_view/goods_comment_content_view.dart'; import 'goods_detail_bottom_bar.dart'; import 'goods_detail_content_view.dart'; import 'comment_view/goods_comment_header_view.dart'; import 'input_dialog/bottom_input_dialog.dart'; import 'input_dialog/pop_bottom_input_dialog_route.dart'; class GoodsDetailPage extends StatefulWidget { GoodsDetailPage({Key key, this.productId}) : super(key: key); final int productId; @override _GoodsDetailPageState createState() => _GoodsDetailPageState(); } class _GoodsDetailPageState extends State<GoodsDetailPage> { //页面加载状态,默认为加载中 LoadState _layoutState = LoadState.State_Loading; ProductDetail productDetail; List<CommentModel> commentList = []; CommentVO _commentVO; RefreshController _refreshController; void initState() { super.initState(); _refreshController = RefreshController(); loadData(); } loadData() async { Future.wait([ NetworkUtils.requestProductDetailByProductId(this.widget.productId), NetworkUtils.requstProductCommentList(this.widget.productId, 0) ]).then((res) { BaseResult productDetailRes = res[0]; BaseResult commentListRes = res[1]; if (productDetailRes.status == 200 && commentListRes.status == 200) { productDetail = ProductDetail.fromJson(productDetailRes.data); commentList = (commentListRes.data as List) .map((m) => CommentModel.fromJson(m)) .toList(); if (commentList.length < 20) { this._refreshController.loadNoData(); } else { this._refreshController.loadComplete(); } setState(() { _layoutState = LoadState.State_Success; }); } else { BaseResult res = productDetailRes.status != 200 ? productDetailRes : commentListRes; setState(() { _layoutState = loadStateByErrorCode(res.status); }); } }).catchError((error) { print('${error.toString()}'); }); } loadProductCommentListData() async { int startCommentId = this.commentList.last?.commentList ?? 0; NetworkUtils.requstProductCommentList(this.widget.productId, startCommentId) .then((res) { if (res.status == 200) { var tempList = (res.data as List).map((m) => CommentModel.fromJson(m)).toList(); if (tempList.length < 20) { this._refreshController.loadNoData(); } else { this._refreshController.loadComplete(); } if (tempList.length > 0) { this.commentList.addAll(tempList); } setState(() {}); } }); } remarkProduct(String content) async { var parentCommentId; var parentUserId; // 点击的是评论 if (_commentVO != null && _commentVO.index == -1) { CommentModel parentComment = _commentVO.commentModel; parentCommentId = parentComment.commentId; parentUserId = parentComment.createUserId; } if (_commentVO != null && _commentVO.index != -1) { CommentModel parentComment = _commentVO.commentModel.commentList[_commentVO.index]; parentCommentId = parentComment.parentCommentId; parentUserId = parentComment.createUserId; } NetworkUtils.remarkProduct(this.widget.productId, content, parentCommentId: parentCommentId, parentUserId: parentUserId) .then((res) { if (res.status == 200) { CommentModel temp = CommentModel.fromJson(res.data); // 构建一个评论模型 if (parentCommentId == null) { //添加评论 showToast('评论成功', duration: Duration(milliseconds: 1500)); this.commentList.add(temp); this.productDetail.commentCount += 1; } else { showToast('回复成功', duration: Duration(milliseconds: 1500)); this._commentVO.commentModel.commentList.add(temp); } setState(() {}); } else { showToast('发送失败'); } }); } addCollectProduct() { int cateId = int.parse(this.productDetail.cateId); NetworkUtils.addCollectProduct(cateId, this.productDetail.productId).then((res) { if (res.status == 200) { var collectId = (res.data as Map)['collectId']; setState(() { this.productDetail.collectId = collectId; }); showToast('收藏成功'); }else { showToast('收藏失败'); } }); } deleteCollect() { NetworkUtils.deleteCollectProcut(this.productDetail.collectId)..then((res) { if (res.status == 200) { setState(() { this.productDetail.collectId = null; }); showToast('取消收藏成功'); }else { showToast('取消收藏失败'); } }); } showCommentDialog() { Navigator.push( context, PopBottomInputDialogRoute( child: BottomInputDialog( callback: (text) { this.remarkProduct(text); }, ), ), ); } _buildBodyView() { return SmartRefresher( controller: _refreshController, enablePullUp: true, enablePullDown: false, footer: buildDefaultFooter(), onLoading: () { this.loadProductCommentListData(); }, child: CustomScrollView( slivers: <Widget>[ SliverToBoxAdapter( child: GoodsDetailContentView( productDetail: productDetail, ), ), SliverToBoxAdapter( child: GoodsCommentHeaderView(commentCount: this.productDetail?.commentCount ?? 0,), ), SliverList( delegate: SliverChildBuilderDelegate( (context, int index) { return GoodsCommentContentView( commentModel: this.commentList[index], tapCallback: ((commentVO) { this._commentVO = commentVO; //评论 this.showCommentDialog(); }), ); }, childCount: this.commentList.length, ), ), ], ), ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( title: Text( "教程详情", style: TextStyle(color: Colors.white), ), elevation: 0.0, iconTheme: IconThemeData( color: Colors.white, ), ), body: LoadStateLayout( state: _layoutState, errorRetry: () { setState(() { _layoutState = LoadState.State_Loading; }); this.loadData(); }, successWidget: _buildBodyView()), bottomNavigationBar: GoodsCommentBottomBar( isCollect: this.productDetail?.collectId == null ? false : true, btnActionCallback: ((tag) { if (tag == 100) { //收藏 if (this.productDetail.collectId == null) { this.addCollectProduct(); } else { this.deleteCollect(); } } else if (tag == 200) { this._commentVO = null; //评论 this.showCommentDialog(); } }), ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/detail/goods_detail_bottom_bar.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; class GoodsCommentBottomBar extends StatelessWidget { final ValueChanged<int> btnActionCallback; final isCollect; const GoodsCommentBottomBar({Key key, this.isCollect, this.btnActionCallback}) : super(key: key); @override Widget build(BuildContext context) { var collectIcon; if (isCollect) { collectIcon = Icon( APPIcons.CollectSelectData, color: AppColors.PrimaryColor, ); } else { collectIcon = Icon( APPIcons.CollectionData, color: AppColors.ArrowNormalColor, ); } IconButton favoriteBtn = IconButton( icon: collectIcon, onPressed: () { this.btnActionCallback(100); }, ); Widget commentBtn = GestureDetector( onTap: () { this.btnActionCallback(200); }, child: ClipRRect( borderRadius: BorderRadius.circular(20), child: Container( width: 220, height: 40, color: AppColors.DividerColor, child: Row( children: <Widget>[ SizedBox( width: 20, ), Text('说点什么吧', style: TextStyle(fontSize: 13, color: AppColors.LightTextColor)), ], ), ), ), ); return Container( decoration: BoxDecoration( border: Border( top: BorderSide( width: AppSize.DividerWidth, color: AppColors.DividerColor, ), ), ), width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).padding.bottom + 50, padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ favoriteBtn, Expanded(child: SizedBox()), commentBtn ], ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages/detail
mirrored_repositories/it_resource_exchange_app/lib/pages/detail/input_dialog/pop_bottom_input_dialog_route.dart
import 'package:flutter/material.dart'; class PopBottomInputDialogRoute extends PopupRoute{ final Duration _duration = Duration(milliseconds: 300); Widget child; PopBottomInputDialogRoute({@required this.child}); @override Color get barrierColor => null; @override bool get barrierDismissible => true; @override String get barrierLabel => null; @override Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) { return child; } @override Duration get transitionDuration => _duration; }
0
mirrored_repositories/it_resource_exchange_app/lib/pages/detail
mirrored_repositories/it_resource_exchange_app/lib/pages/detail/input_dialog/bottom_input_dialog.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; import 'package:oktoast/oktoast.dart'; class BottomInputDialog extends StatelessWidget { TextEditingController inputController = TextEditingController(); ValueChanged<String> callback; BottomInputDialog({this.callback}); @override Widget build(BuildContext context) { return new Scaffold( backgroundColor: Colors.transparent, body: new Column( children: <Widget>[ Expanded( child: new GestureDetector( child: new Container(color: Colors.black38), onTap: () { Navigator.pop(context); }, )), new Container( height: 80, color: AppColors.MidTextColor, child: Padding( padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10), child: Row( children: <Widget>[ Expanded( child: TextField( controller: inputController, decoration: InputDecoration( filled: true, fillColor: Colors.white, hintText: '留下你的精彩吧!', border: InputBorder.none, ), maxLines: 100, autofocus: true, textInputAction: TextInputAction.newline, ), ), SizedBox(width: 10,), MaterialButton( color: AppColors.PrimaryColor, textColor: Colors.white, clipBehavior:Clip.antiAlias, child: Text('发布', style:TextStyle(fontSize:14)), onPressed: () { String content = inputController.text; if (content == null || content.isEmpty) { showToast('评论内容不能为空'); }else { this.callback(content); Navigator.of(context).pop(); } }, ) ], ), )) ], ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages/detail
mirrored_repositories/it_resource_exchange_app/lib/pages/detail/comment_view/goods_comment_item_view.dart
import 'package:flutter/material.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:intl/intl.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; import 'package:it_resource_exchange_app/model/comment_model.dart'; class GoodsCommentItemView extends StatelessWidget { final CommentModel commentModel; const GoodsCommentItemView({Key key, this.commentModel}) : super(key: key); @override Widget build(BuildContext context) { String avatarUrl; Widget avatar; if (avatarUrl != null) { avatar = CachedNetworkImage( imageUrl: avatarUrl, placeholder: (context, url) => APPIcons.PlaceHolderAvatar, fit: BoxFit.cover, height: 35.0, width: 35.0, errorWidget: (context, url, error) => new Icon(Icons.error), ); } else { avatar = Icon( APPIcons.AvatarData, size: 35.0, color: AppColors.ArrowNormalColor, ); } var createDateStr = "未知"; if (commentModel?.createdTime != null) { var format = new DateFormat('yyyy-MM-dd HH:mm'); var date = DateTime.fromMillisecondsSinceEpoch(commentModel.createdTime); createDateStr = format.format(date); } return Container( decoration: BoxDecoration( border: Border( top: BorderSide( width: AppSize.DividerWidth, color: AppColors.DividerColor, ), ), ), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding(padding: const EdgeInsets.all(10.0), child: avatar), Expanded( child: Container( margin: EdgeInsets.symmetric(vertical: 10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ Expanded( child: Text( commentModel.createUserName ?? "未知", style: TextStyle(color: const Color(0xFF63CA6C)), ), ), Padding( padding: const EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0), child: Text( createDateStr, style: TextStyle( fontSize: 12.0, color: const Color(0xFFB5BDC0)), ), ), ], ), SizedBox( height: 5, ), Padding( padding: const EdgeInsets.only(right: 10.0), child: Text( commentModel.content ?? '', style: TextStyle(fontSize: 15.0, color: Colors.black), ), ), ], ), )) ], ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages/detail
mirrored_repositories/it_resource_exchange_app/lib/pages/detail/comment_view/goods_comment_reply_view.dart
import 'package:flutter/material.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:intl/intl.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; import 'package:it_resource_exchange_app/model/comment_model.dart'; class GoodsCommentReplyView extends StatelessWidget { final CommentModel commentModel; const GoodsCommentReplyView({Key key, this.commentModel}) : super(key: key); @override Widget build(BuildContext context) { String avatarUrl; Widget avatar; if (avatarUrl != null) { avatar = CachedNetworkImage( imageUrl: avatarUrl, placeholder: (context, url) => APPIcons.PlaceHolderAvatar, fit: BoxFit.cover, height: 20.0, width: 20.0, errorWidget: (context, url, error) => new Icon(Icons.error), ); } else { avatar = Icon( APPIcons.AvatarData, size: 20.0, color: AppColors.ArrowNormalColor, ); } var createDateStr = "未知"; if (commentModel?.createdTime != null) { var format = new DateFormat('yyyy-MM-dd HH:mm'); var date = DateTime.fromMillisecondsSinceEpoch(commentModel.createdTime); createDateStr = format.format(date); } return Container( margin: EdgeInsets.fromLTRB(55.0, 0, 0, 10), decoration: BoxDecoration( border: Border( top: BorderSide( width: AppSize.DividerWidth, color: AppColors.DividerColor, ), ), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ SizedBox( height: 10, ), Row( children: <Widget>[ avatar, SizedBox( width: 5, ), Expanded( child: Text( this.commentModel?.createUserName ?? "未知", style: TextStyle(color: const Color(0xFF63CA6C)), ), ), Padding( padding: EdgeInsets.only(right: 10.0), child: Text( createDateStr, style: TextStyle(fontSize: 12.0, color: const Color(0xFFB5BDC0)), ), ) ], ), Padding( padding: const EdgeInsets.fromLTRB(25.0, 5.0, 10.0, 0.0), child: Text( this.commentModel.content ?? '', style: TextStyle(fontSize: 15.0, color: Colors.black), ), ) ], ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages/detail
mirrored_repositories/it_resource_exchange_app/lib/pages/detail/comment_view/goods_comment_content_view.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/model/comment_model.dart'; import 'package:it_resource_exchange_app/utils/user_utils.dart'; import 'package:it_resource_exchange_app/vo/comment_vo.dart'; import 'goods_comment_item_view.dart'; import 'goods_comment_reply_view.dart'; class GoodsCommentContentView extends StatelessWidget { final CommentModel commentModel; final ValueChanged<CommentVO> tapCallback; const GoodsCommentContentView({Key key, this.commentModel, this.tapCallback}) : super(key: key); @override Widget build(BuildContext context) { return CustomScrollView( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), slivers: <Widget>[ SliverToBoxAdapter( child: GestureDetector( child: GoodsCommentItemView( commentModel: commentModel, ), onTap: UserUtils.getUserInfo().userId != this.commentModel.createUserId ? () { this.tapCallback(CommentVO(index: -1, commentModel: commentModel)); } : null, ), ), SliverList( delegate: SliverChildBuilderDelegate( (context, int index) { return GestureDetector( child: GoodsCommentReplyView(commentModel: this.commentModel.commentList[index],), onTap: UserUtils.getUserInfo().userId != this.commentModel.commentList[index].createUserId ? () { this.tapCallback(CommentVO(index: index, commentModel: commentModel)); } : null, ); }, childCount: commentModel.commentList?.length ?? 0, ), ) ], ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages/detail
mirrored_repositories/it_resource_exchange_app/lib/pages/detail/comment_view/goods_comment_header_view.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; class GoodsCommentHeaderView extends StatelessWidget { final int commentCount; const GoodsCommentHeaderView({Key key, this.commentCount}) : super(key: key); @override Widget build(BuildContext context) { return Container( height: 45, child: Padding( padding: EdgeInsets.only(left: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( '共 $commentCount 条评论', style: TextStyle( color: AppColors.DarkTextColor, fontWeight: FontWeight.w700), ) ], ), ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/player/video_player_page.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; import 'package:it_resource_exchange_app/model/movie_info.dart'; import 'package:it_resource_exchange_app/net/network_utils.dart'; import 'package:it_resource_exchange_app/widgets/load_state_layout_widget.dart'; import 'package:video_player/video_player.dart'; import 'video_player_widget.dart'; class VideoPlayerPage extends StatefulWidget { final int movieId; const VideoPlayerPage({Key key, this.movieId}) : super(key: key); @override _VideoPlayerPageState createState() => _VideoPlayerPageState(); } class _VideoPlayerPageState extends State<VideoPlayerPage> { VideoPlayerController _videoPlayerController; MovieInfo movieInfo; //页面加载状态,默认为加载中 LoadState _layoutState = LoadState.State_Loading; @override void initState() { super.initState(); loadData(); } @override void dispose() { super.dispose(); } loadData() { NetworkUtils.requstMovieDetailData(this.widget.movieId).then((res) { if (res.status == 200) { movieInfo = MovieInfo.fromJson(res.data); _videoPlayerController = VideoPlayerController.network(this.movieInfo.playUrl ?? ""); setState(() { _layoutState = LoadState.State_Success; }); } else { setState(() { _layoutState = loadStateByErrorCode(res.status); }); } }); } Column _buildPlayerView() { return Column( children: <Widget>[ VideoPlayerWidget(videoPlayerController: _videoPlayerController,), ListView( shrinkWrap: true, padding: EdgeInsets.fromLTRB(10, 10, 10, 10), children: <Widget>[ Text('导演:${this.movieInfo?.director ?? ""}', style: TextStyle(color: AppColors.DarkTextColor, fontSize: 16)), Text('演员:${this.movieInfo?.rolesNames ?? ""}', style: TextStyle(color: AppColors.DarkTextColor, fontSize: 16)), Text('上映时间:${this.movieInfo?.releaseYear ?? ""}', style: TextStyle(color: AppColors.DarkTextColor, fontSize: 16)), SizedBox(height: 20,), Text('剧情描述:', style: TextStyle(color: AppColors.DarkTextColor, fontSize: 16)), Text(this.movieInfo?.desc ?? "", style: TextStyle(color: AppColors.MidTextColor, fontSize: 14)) , ], ), ], ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(this.movieInfo?.movieName ?? "电影详情"), ), body: LoadStateLayout( state: _layoutState, errorRetry: () { setState(() { _layoutState = LoadState.State_Loading; }); this.loadData(); }, successWidget: _buildPlayerView(), ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/player/video_player_widget.dart
import 'package:auto_orientation/auto_orientation.dart'; import 'package:chewie/chewie.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:video_player/video_player.dart'; class VideoPlayerWidget extends StatefulWidget { // This will contain the URL/asset path which we want to play final VideoPlayerController videoPlayerController; const VideoPlayerWidget({Key key, this.videoPlayerController}) : super(key: key); @override _VideoPlayerWidgetState createState() => _VideoPlayerWidgetState(); } class _VideoPlayerWidgetState extends State<VideoPlayerWidget> { Container loadingView = Container( constraints: BoxConstraints.expand(), color: Colors.black, child: Center( child: Opacity( opacity: 0.8, child: SpinKitThreeBounce( color: Colors.white, size: 20.0, ), ), ), ); ChewieController _chewieController; @override void initState() { super.initState(); _chewieController = ChewieController( videoPlayerController: widget.videoPlayerController, aspectRatio: 16 / 9, autoPlay: true, placeholder: loadingView, autoInitialize: true, errorBuilder: (BuildContext context, String errorMessage) { return Center( child: Text( errorMessage, style: TextStyle(color: Colors.white), ), ); }, routePageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondAnimation, provider) { return AnimatedBuilder( animation: animation, builder: (BuildContext context, Widget child) { return VideoScaffold( child: Scaffold( resizeToAvoidBottomPadding: false, body: Container( alignment: Alignment.center, color: Colors.black, child: provider, ), ), ); }, ); }, ); } @override void dispose() { super.dispose(); // IMPORTANT to dispose of all the used resources widget.videoPlayerController.dispose(); _chewieController.dispose(); } @override Widget build(BuildContext context) { return Chewie( controller: _chewieController, ); } } class VideoScaffold extends StatefulWidget { const VideoScaffold({Key key, this.child}) : super(key: key); final Widget child; @override State<StatefulWidget> createState() => _VideoScaffoldState(); } class _VideoScaffoldState extends State<VideoScaffold> { @override void initState() { SystemChrome.setPreferredOrientations([ DeviceOrientation.landscapeRight, DeviceOrientation.landscapeLeft, ]); AutoOrientation.landscapeMode(); super.initState(); } @override dispose() { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); AutoOrientation.portraitMode(); super.dispose(); } @override Widget build(BuildContext context) { return widget.child; } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/login/user_verify_code_page.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; import 'package:it_resource_exchange_app/routes/it_router.dart'; import 'package:it_resource_exchange_app/routes/routes.dart'; import 'package:it_resource_exchange_app/utils/regex_utils.dart'; import '../../net/network_utils.dart'; import 'package:oktoast/oktoast.dart'; import 'dart:async'; class UserVerifyCodePage extends StatefulWidget { @override _UserVerifyCodePageState createState() => _UserVerifyCodePageState(); } class _UserVerifyCodePageState extends State<UserVerifyCodePage> with SingleTickerProviderStateMixin { AnimationController _controller; String _accountNum = ''; String _verifyCode = ''; bool isVeriftyBtnEnable = false; //按钮状态 是否可点击 String buttonText = '发送验证码'; //初始文本 int count = 60; //初始倒计时时间 Timer timer; //倒计时的计时器 @override void initState() { super.initState(); _controller = AnimationController(vsync: this); } @override void dispose() { timer?.cancel(); //销毁计时器 timer = null; super.dispose(); _controller.dispose(); } sendVerityCode() { NetworkUtils.sendCodeForReset(this._accountNum).then((res) { if (res.status == 200) { // 注册成功,跳转回登录页面 showToast("验证码发送成功", duration: Duration(milliseconds: 1500)); //开始倒计时 setState(() { if (isVeriftyBtnEnable) { //当按钮可点击时 isVeriftyBtnEnable = false; //按钮状态标记 _initTimer(); } }); } else { showToast(res.message, duration: Duration(milliseconds: 1500)); } }); } void _initTimer() { timer = new Timer.periodic(Duration(seconds: 1), (Timer timer) { count--; setState(() { if (count == 0) { timer.cancel(); //倒计时结束取消定时器 isVeriftyBtnEnable = true; //按钮可点击 count = 60; //重置时间 buttonText = '发送验证码'; //重置按钮文本 } else { buttonText = '重新发送($count)'; //更新文本内容 } }); }); } Widget _buildTipIcon() { return new Padding( padding: const EdgeInsets.only( left: 40.0, right: 40.0, top: 30.0, bottom: 50.0), child: new Row( mainAxisAlignment: MainAxisAlignment.center, //子组件的排列方式为主轴两端对齐 children: <Widget>[ new Image.asset( './assets/imgs/app_icon.png', width: 88.0, height: 88.0, ), ], ), ); } Widget _buldAccountEdit() { var node = FocusNode(); return Padding( padding: EdgeInsets.symmetric(horizontal: 40.0), child: TextField( onChanged: (value) { _accountNum = value; if (this.count == 60) { setState(() { this.isVeriftyBtnEnable = RegexUtils.isEmail(value); }); } }, decoration: InputDecoration( hintText: '请输入邮箱地址作为用户名', labelText: '账号', hintStyle: TextStyle(fontSize: 12.0, color: AppColors.ArrowNormalColor), ), maxLines: 1, maxLength: 30, keyboardType: TextInputType.emailAddress, onSubmitted: (value) { FocusScope.of(context).requestFocus(node); }, ), ); } Widget _buildVerifyCodeBtn() { var node = new FocusNode(); Widget passwordEdit = new TextField( onChanged: (str) { _verifyCode = str; setState(() {}); }, decoration: new InputDecoration( hintText: '请输入验证码', labelText: '验证码', hintStyle: new TextStyle(fontSize: 12.0, color: Colors.grey), ), maxLines: 1, maxLength: 6, //键盘展示为数字 keyboardType: TextInputType.number, //只能输入数字 inputFormatters: <TextInputFormatter>[ WhitelistingTextInputFormatter.digitsOnly, ], onSubmitted: (text) { FocusScope.of(context).requestFocus(node); }, ); return Padding( padding: const EdgeInsets.only(left: 40.0, right: 40.0, top: 0.0), child: Row( children: <Widget>[ Expanded( child: passwordEdit, ), SizedBox( width: 25, ), Container( width: 120, child: OutlineButton( borderSide: BorderSide( color: AppColors.PrimaryColor, width: 1, ), disabledBorderColor: AppColors.ArrowNormalColor, disabledTextColor: AppColors.ArrowNormalColor, textColor: AppColors.PrimaryColor, child: Text( '$buttonText', style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w400), ), onPressed: this.isVeriftyBtnEnable ? () { this.sendVerityCode(); } : null, ), ) ], ), ); } Widget _buildSubmitBtn() { return new Padding( padding: EdgeInsets.only(top: 30.0, bottom: 30.0), child: new RaisedButton( padding: new EdgeInsets.fromLTRB(150.0, 15.0, 150.0, 15.0), color: AppColors.PrimaryColor, textColor: Colors.white, disabledColor: AppColors.DisableTextColor, onPressed: (_accountNum.isEmpty || _verifyCode.isEmpty) ? null : () { ITRouter.push(context, Routes.resetPasswordPage, { 'account': this._accountNum, 'verityCode': this._verifyCode }); }, child: new Text( '确 定', style: new TextStyle(fontSize: 16.0, color: Colors.white), ), ), ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( title: Text("重置密码", style: TextStyle(color: Colors.white)), elevation: 0.0, iconTheme: IconThemeData( color: Colors.white, )), body: GestureDetector( behavior: HitTestBehavior.translucent, //解决透明区域不响应事件 onTap: () { FocusScope.of(context).requestFocus(FocusNode()); }, child: SingleChildScrollView( child: Column( children: <Widget>[ _buildTipIcon(), _buldAccountEdit(), _buildVerifyCodeBtn(), _buildSubmitBtn() ], ), ), ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/login/reset_password_page.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; import 'package:it_resource_exchange_app/net/network_utils.dart'; import 'package:it_resource_exchange_app/routes/it_router.dart'; import 'package:it_resource_exchange_app/routes/routes.dart'; import 'package:oktoast/oktoast.dart'; import 'dart:async'; class RestPasswordPage extends StatefulWidget { RestPasswordPage({Key key, this.account, this.verityCode}) : super(key: key); final String account; final String verityCode; @override _RestPasswordPageState createState() => _RestPasswordPageState(); } class _RestPasswordPageState extends State<RestPasswordPage> { String _password = ''; String _password2 = ''; @override void dispose() { super.dispose(); } resetPassword() { NetworkUtils.resetPassword(this.widget.account, this._password, this.widget.verityCode).then((res) { if (res.status == 200) { // 注册成功,跳转回登录页面 showToast("密码重置成功", duration: Duration(milliseconds: 1500)); Future.delayed(Duration(milliseconds: 1500), () { // 保存成功,跳转到登录页面 ITRouter.push(context, Routes.loginPage, {}, clearStack: true); }); } else { showToast(res.message, duration: Duration(milliseconds: 1500)); } }); } Widget _buildTipIcon() { return new Padding( padding: const EdgeInsets.only( left: 40.0, right: 40.0, top: 30.0, bottom: 50.0), child: new Row( mainAxisAlignment: MainAxisAlignment.center, //子组件的排列方式为主轴两端对齐 children: <Widget>[ new Image.asset( './assets/imgs/app_icon.png', width: 88.0, height: 88.0, ), ], ), ); } Widget _bulidPasswordEdit() { var node = new FocusNode(); Widget passwordEdit = new TextField( onChanged: (str) { _password = str; setState(() {}); }, decoration: new InputDecoration( hintText: '请输入至少6位密码', labelText: '输入新密码', hintStyle: new TextStyle(fontSize: 12.0, color: Colors.grey)), maxLines: 1, maxLength: 6, obscureText: true, //键盘展示为数字 keyboardType: TextInputType.number, //只能输入数字 inputFormatters: <TextInputFormatter>[ WhitelistingTextInputFormatter.digitsOnly, ], onSubmitted: (text) { FocusScope.of(context).requestFocus(node); }, ); return new Padding( padding: const EdgeInsets.only(left: 40.0, right: 40.0, top: 0.0), child: new Stack( children: <Widget>[ passwordEdit, ], ), ); } Widget _bulidPasswordEdit2() { var node = new FocusNode(); Widget passwordEdit = new TextField( onChanged: (str) { _password2 = str; setState(() {}); }, decoration: new InputDecoration( hintText: '请再次输入至少6位密码', labelText: '确认新密码', hintStyle: new TextStyle(fontSize: 12.0, color: Colors.grey)), maxLines: 1, maxLength: 6, obscureText: true, //键盘展示为数字 keyboardType: TextInputType.number, //只能输入数字 inputFormatters: <TextInputFormatter>[ WhitelistingTextInputFormatter.digitsOnly, ], onSubmitted: (text) { FocusScope.of(context).requestFocus(node); }, ); return new Padding( padding: const EdgeInsets.only(left: 40.0, right: 40.0, top: 0.0), child: new Stack( children: <Widget>[ passwordEdit, ], ), ); } Widget _buildSubmitBtn() { return new Padding( padding: EdgeInsets.only(top: 30.0, bottom: 30.0), child: new RaisedButton( padding: new EdgeInsets.fromLTRB(150.0, 15.0, 150.0, 15.0), color: AppColors.PrimaryColor, textColor: Colors.white, disabledColor: AppColors.DisableTextColor, onPressed: (_password.isEmpty || _password2.isEmpty) ? null : () { if (_password != _password2) { showToast("密码输入不一致"); return; } resetPassword(); }, child: new Text( '确 定', style: new TextStyle(fontSize: 16.0, color: Colors.white), ), ), ); } @override Widget build(BuildContext context) { return Material( child: Scaffold( backgroundColor: Colors.white, appBar: AppBar( title: Text("重置密码", style: TextStyle(color: Colors.white)), elevation: 0.0, iconTheme: IconThemeData( color: Colors.white, )), body: GestureDetector( behavior: HitTestBehavior.translucent, //解决透明区域不响应事件 onTap: () { FocusScope.of(context).requestFocus(FocusNode()); }, child: SingleChildScrollView( child: Column( children: <Widget>[ _buildTipIcon(), _bulidPasswordEdit(), _bulidPasswordEdit2(), _buildSubmitBtn() ], ), ), ), ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/login/register_page.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; import 'package:it_resource_exchange_app/utils/regex_utils.dart'; import '../../net/network_utils.dart'; import 'package:oktoast/oktoast.dart'; import 'dart:async'; class RegisterPage extends StatefulWidget { @override _RegisterPageState createState() => _RegisterPageState(); } class _RegisterPageState extends State<RegisterPage> { String _accountNum = ''; String _password = ''; String _password2 = ''; String _verityCode = ''; bool isVerifyBtnEnable = false; //按钮状态 是否可点击 String buttonText = '发送验证码'; //初始文本 int count = 60; //初始倒计时时间 Timer timer; //倒计时的计时器 void _initTimer() { timer = new Timer.periodic(Duration(seconds: 1), (Timer timer) { count--; setState(() { if (count == 0) { timer.cancel(); //倒计时结束取消定时器 isVerifyBtnEnable = true; //按钮可点击 count = 60; //重置时间 buttonText = '发送验证码'; //重置按钮文本 } else { buttonText = '重新发送($count)'; //更新文本内容 } }); }); } @override void dispose() { timer?.cancel(); //销毁计时器 timer = null; super.dispose(); } register() { NetworkUtils.register(this._accountNum, this._password, this._verityCode).then((res) { if (res.status == 200) { // 注册成功,跳转回登录页面 showToast("注册成功", duration: Duration(milliseconds: 1500)); Future.delayed(Duration(milliseconds: 1500), () { Navigator.pop(this.context, this._accountNum); }); } else { showToast(res.message, duration: Duration(milliseconds: 1500)); } }); } sendVerityCode() { NetworkUtils.sendCodeForRegister(this._accountNum).then((res) { if (res.status == 200) { // 注册成功,跳转回登录页面 showToast("验证码发送成功", duration: Duration(milliseconds: 1500)); //开始倒计时 setState(() { if (isVerifyBtnEnable) { //当按钮可点击时 isVerifyBtnEnable = false; //按钮状态标记 _initTimer(); } }); } else { showToast(res.message, duration: Duration(milliseconds: 1500)); } }); } Widget _buildTipIcon() { return new Padding( padding: const EdgeInsets.only( left: 40.0, right: 40.0, top: 30.0, bottom: 50.0), child: new Row( mainAxisAlignment: MainAxisAlignment.center, //子组件的排列方式为主轴两端对齐 children: <Widget>[ new Image.asset( './assets/imgs/app_icon.png', width: 88.0, height: 88.0, ), ], ), ); } Widget _buldAccountEdit() { var node = FocusNode(); return Padding( padding: EdgeInsets.symmetric(horizontal: 40.0), child: TextField( onChanged: (value) { _accountNum = value; if (this.count == 60) { setState(() { this.isVerifyBtnEnable = RegexUtils.isEmail(value); }); } }, decoration: InputDecoration( hintText: '请输入邮箱地址作为用户名', labelText: '账号', hintStyle: TextStyle(fontSize: 12.0, color: AppColors.ArrowNormalColor), ), maxLines: 1, maxLength: 30, keyboardType: TextInputType.emailAddress, autofocus: true, onSubmitted: (value) { FocusScope.of(context).requestFocus(node); }, ), ); } Widget _bulidPasswordEdit() { var node = new FocusNode(); Widget passwordEdit = new TextField( onChanged: (str) { _password = str; setState(() {}); }, decoration: new InputDecoration( hintText: '请输入至少6位密码', labelText: '输入密码', hintStyle: new TextStyle(fontSize: 12.0, color: Colors.grey)), maxLines: 1, maxLength: 6, obscureText: true, //键盘展示为数字 keyboardType: TextInputType.number, //只能输入数字 inputFormatters: <TextInputFormatter>[ WhitelistingTextInputFormatter.digitsOnly, ], onSubmitted: (text) { FocusScope.of(context).requestFocus(node); }, ); return new Padding( padding: const EdgeInsets.only(left: 40.0, right: 40.0, top: 0.0), child: new Stack( children: <Widget>[ passwordEdit, ], ), ); } Widget _bulidPasswordEdit2() { var node = new FocusNode(); Widget passwordEdit = new TextField( onChanged: (str) { _password2 = str; setState(() {}); }, decoration: new InputDecoration( hintText: '请再次输入至少6位密码', labelText: '确认密码', hintStyle: new TextStyle(fontSize: 12.0, color: Colors.grey)), maxLines: 1, maxLength: 6, obscureText: true, //键盘展示为数字 keyboardType: TextInputType.number, //只能输入数字 inputFormatters: <TextInputFormatter>[ WhitelistingTextInputFormatter.digitsOnly, ], onSubmitted: (text) { FocusScope.of(context).requestFocus(node); }, ); return new Padding( padding: const EdgeInsets.only(left: 40.0, right: 40.0, top: 0.0), child: new Stack( children: <Widget>[ passwordEdit, ], ), ); } Widget _buildVerifyCodeBtn() { var node = new FocusNode(); Widget passwordEdit = new TextField( onChanged: (str) { _verityCode = str; setState(() {}); }, decoration: new InputDecoration( hintText: '请输入验证码', labelText: '验证码', hintStyle: new TextStyle(fontSize: 12.0, color: Colors.grey), ), maxLines: 1, maxLength: 6, //键盘展示为数字 keyboardType: TextInputType.number, //只能输入数字 inputFormatters: <TextInputFormatter>[ WhitelistingTextInputFormatter.digitsOnly, ], onSubmitted: (text) { FocusScope.of(context).requestFocus(node); }, ); return Padding( padding: const EdgeInsets.only(left: 40.0, right: 40.0, top: 0.0), child: Row( children: <Widget>[ Expanded( child: passwordEdit, ), SizedBox( width: 25, ), Container( width: 120, child: OutlineButton( borderSide: BorderSide( color: AppColors.PrimaryColor, width: 1, ), disabledBorderColor: AppColors.ArrowNormalColor, disabledTextColor: AppColors.ArrowNormalColor, textColor: AppColors.PrimaryColor, child: Text( '$buttonText', style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w400), ), onPressed: this.isVerifyBtnEnable ? () { this.sendVerityCode(); } : null, ), ) ], ), ); } Widget _buildSubmitBtn() { return new Padding( padding: EdgeInsets.only(top: 30.0, bottom: 30.0), child: new RaisedButton( padding: new EdgeInsets.fromLTRB(150.0, 15.0, 150.0, 15.0), color: AppColors.PrimaryColor, textColor: Colors.white, disabledColor: AppColors.DisableTextColor, onPressed: (_accountNum.isEmpty || _password.isEmpty || _password2.isEmpty || _verityCode.isEmpty) ? null : () { if (_password != _password2) { showToast("密码输入不一致"); return; } register(); }, child: new Text( '注册', style: new TextStyle(fontSize: 16.0, color: Colors.white), ), ), ); } @override Widget build(BuildContext context) { return Material( child: Scaffold( backgroundColor: Colors.white, appBar: AppBar( title: Text("账号注册", style: TextStyle(color: Colors.white)), elevation: 0.0, iconTheme: IconThemeData( color: Colors.white, )), body: GestureDetector( behavior: HitTestBehavior.translucent, //解决透明区域不响应事件 onTap: () { FocusScope.of(context).requestFocus(FocusNode()); }, child: SingleChildScrollView( child: Column( children: <Widget>[ _buildTipIcon(), _buldAccountEdit(), _bulidPasswordEdit(), _bulidPasswordEdit2(), _buildVerifyCodeBtn(), _buildSubmitBtn() ], ), ), ), ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/login/perfect_info_page.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; class PerfectInfoPage extends StatefulWidget { @override _PerfectInfoPageState createState() => _PerfectInfoPageState(); } class _PerfectInfoPageState extends State<PerfectInfoPage> { String _avatarURL; String _nickName; _buildIconView() { Widget avatar; if (_avatarURL != null) { avatar = CachedNetworkImage( imageUrl: _avatarURL, placeholder: (context, url) => APPIcons.PlaceHolderAvatar, fit: BoxFit.cover, height: 80.0, width: 80.0, errorWidget: (context, url, error) => new Icon(Icons.error), ); } else { avatar = Icon( APPIcons.AvatarData, size: 80.0, color: AppColors.ArrowNormalColor, ); } return GestureDetector( child: ClipOval( child: avatar, ), onTap: () { }, ); } _buildNickNameFieldView() { var node = FocusNode(); return Padding( padding: EdgeInsets.symmetric(horizontal: 40.0), child: TextField( controller: TextEditingController(text: _nickName), onChanged: (value) { _nickName = value; }, decoration: InputDecoration( hintText: '请输入昵称', labelText: '昵称', hintStyle: TextStyle(fontSize: 12.0, color: AppColors.ArrowNormalColor), ), maxLines: 1, maxLength: 30, keyboardType: TextInputType.emailAddress, autofocus: true, onSubmitted: (value) { FocusScope.of(context).requestFocus(node); }, ), ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: new AppBar( title: new Text('完善信息', style: TextStyle(color: Colors.white)), elevation: 0.0, iconTheme: IconThemeData( color: Colors.white, )), body: GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { FocusScope.of(context).requestFocus(FocusNode()); }, child: SingleChildScrollView( child: Column( children: <Widget>[ SizedBox(height: 100), _buildIconView(), SizedBox(height: 80), _buildNickNameFieldView() ], ), ), ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/login/login_page.dart
import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; import 'package:it_resource_exchange_app/routes/it_router.dart'; import 'package:it_resource_exchange_app/routes/routes.dart'; import '../../net/network_utils.dart'; import '../../model/user_info.dart'; import '../../utils/user_utils.dart'; import 'package:oktoast/oktoast.dart'; class LoginPage extends StatefulWidget { @override _LoginPageState createState() => _LoginPageState(); } class _LoginPageState extends State<LoginPage> { GlobalKey<ScaffoldState> registKey = new GlobalKey(); String _accountNum = UserUtils.getUserName().isEmpty ? "" : UserUtils.getUserName(); String _password = ''; login() { NetworkUtils.login(this._accountNum, this._password).then((res) { if (res.status == 200) { UserInfo userInfo = UserInfo.fromJson(res.data); UserUtils.saveUserInfo(userInfo); // 保存用户名 UserUtils.saveUserName(this._accountNum); // 保存成功,跳转到首页 ITRouter.push(context, Routes.mainPage, {}, clearStack: true, transition: TransitionType.fadeIn); } else { showToast(res.message, duration: Duration(milliseconds: 1500)); } }); } Widget _buldAccountEdit() { var node = FocusNode(); return Padding( padding: EdgeInsets.symmetric(horizontal: 40.0), child: TextField( controller: TextEditingController(text: _accountNum), onChanged: (value) { _accountNum = value; }, decoration: InputDecoration( hintText: '请输入邮箱地址作为用户名', labelText: '账号', hintStyle: TextStyle(fontSize: 12.0, color: AppColors.ArrowNormalColor), ), maxLines: 1, maxLength: 30, keyboardType: TextInputType.emailAddress, autofocus: true, onSubmitted: (value) { FocusScope.of(context).requestFocus(node); }, ), ); } Widget _bulidPasswordEdit() { var node = new FocusNode(); Widget passwordEdit = new TextField( onChanged: (str) { _password = str; setState(() {}); }, decoration: new InputDecoration( hintText: '请输入至少6位密码', labelText: '密码', hintStyle: new TextStyle(fontSize: 12.0, color: Colors.grey)), maxLines: 1, maxLength: 6, //键盘展示为数字 keyboardType: TextInputType.number, obscureText: true, //只能输入数字 inputFormatters: <TextInputFormatter>[ WhitelistingTextInputFormatter.digitsOnly, ], onSubmitted: (text) { FocusScope.of(context).requestFocus(node); }, ); return new Padding( padding: const EdgeInsets.only(left: 40.0, right: 40.0, top: 0.0), child: new Stack( children: <Widget>[ passwordEdit, ], ), ); } Widget _buildLoginBtn() { return new Padding( padding: EdgeInsets.only(top: 30.0, bottom: 30.0), child: new RaisedButton( padding: new EdgeInsets.fromLTRB(150.0, 15.0, 150.0, 15.0), color: AppColors.PrimaryColor, textColor: Colors.white, disabledColor: AppColors.DisableTextColor, onPressed: (_accountNum.isEmpty || _password.isEmpty) ? null : () { login(); }, child: new Text( '登 录', style: new TextStyle(fontSize: 16.0, color: Colors.white), ), ), ); } Widget _buildRegisterBtn() { return Padding( padding: EdgeInsets.only(top: 0.0, bottom: 30.0), child: OutlineButton( padding: EdgeInsets.fromLTRB(150.0, 15.0, 150.0, 15.0), borderSide: BorderSide( color: AppColors.PrimaryColor, width: 1, ), child: Text("注册", style: TextStyle(fontSize: 16.0, color: AppColors.PrimaryColor)), onPressed: () { ITRouter.push(context, Routes.registerPage, {}).then((res) { if (res != null) { setState(() { this._accountNum = res; }); } }); }, ), ); } Widget _buildTipIcon() { return new Padding( padding: const EdgeInsets.only( left: 40.0, right: 40.0, top: 50.0, bottom: 50.0), child: new Row( mainAxisAlignment: MainAxisAlignment.center, //子组件的排列方式为主轴两端对齐 children: <Widget>[ new Image.asset( './assets/imgs/app_icon.png', width: 88.0, height: 88.0, ), ], ), ); } Widget _forgetPasswordTipBtn() { return Padding( padding: EdgeInsets.only(top: 20, left: 40, right: 40), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ GestureDetector( onTap: () { ITRouter.push(context, Routes.resetPasswordVerityPage, {'account': this._accountNum}); }, child: Stack( alignment: AlignmentDirectional.centerEnd, children: <Widget>[ Container( color: Colors.white, width: 100, height: 40, ), Text( '忘记密码', style: TextStyle( color: AppColors.PrimaryColor, fontSize: 15, decoration: TextDecoration.underline), ) ], ), ), ], ), ); } @override Widget build(BuildContext context) { return new Material( child: new Scaffold( key: registKey, backgroundColor: Colors.white, appBar: new AppBar( title: new Text('账号登录', style: TextStyle(color: Colors.white)), elevation: 0.0, iconTheme: IconThemeData( color: Colors.white, )), body: GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { FocusScope.of(context).requestFocus(FocusNode()); }, child: SingleChildScrollView( child: Column( children: <Widget>[ _buildTipIcon(), _buldAccountEdit(), _bulidPasswordEdit(), _forgetPasswordTipBtn(), _buildLoginBtn(), _buildRegisterBtn() ], ), ), ), ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/classify/classify_item_view.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show AppSize, AppColors; import 'package:cached_network_image/cached_network_image.dart'; import '../../model/home_info.dart'; import 'package:intl/intl.dart'; class ClassifyItemView extends StatelessWidget { const ClassifyItemView({Key key, this.recomendProduct, this.onPressed}) : assert(recomendProduct != null), super(key: key); final RecommendProductList recomendProduct; final VoidCallback onPressed; @override Widget build(BuildContext context) { var format = new DateFormat('yyyy-MM-dd HH:mm'); var date = DateTime.fromMillisecondsSinceEpoch(recomendProduct.createdTime); var createDateStr = format.format(date); return GestureDetector( onTap: this.onPressed, child: Container( height: 100.0, padding: EdgeInsets.only(left: 10.0, right: 10.0), decoration: BoxDecoration( border: Border( bottom: BorderSide( width: AppSize.DividerWidth, color: AppColors.DividerColor, ))), child: Row( children: <Widget>[ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( padding: EdgeInsets.only(top: 10.0), child: Text( recomendProduct.productTitle, style: TextStyle(fontSize: 15.0, color: AppColors.DarkTextColor), ), ), Container( padding: EdgeInsets.only(bottom: 10.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text(createDateStr, style: TextStyle( color: AppColors.LightTextColor, fontSize: 12.0)), Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ // Text( // '0', // style: TextStyle( // color: AppColors.LightTextColor, // fontSize: 12.0), // ), // SizedBox(width: 5.0), Image.asset('./assets/imgs/ic_comment.png', width: 16.0, height: 16.0), ], ), ], ), ) ], ), ), Container( padding: EdgeInsets.only(left: 6.0), width: 120.0, height: 80.0, child: CachedNetworkImage( imageUrl: recomendProduct.coverUrl, placeholder: (context, url) => Image.asset('./assets/imgs/img_default.png'), fit: BoxFit.cover, ), ), ], )), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/classify/classify_list_view.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:it_resource_exchange_app/routes/it_router.dart'; import 'package:it_resource_exchange_app/routes/routes.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:it_resource_exchange_app/widgets/indicator_factory.dart'; import 'package:it_resource_exchange_app/pages/classify/classify_item_view.dart'; import 'package:it_resource_exchange_app/model/cate_info.dart'; import 'package:it_resource_exchange_app/net/network_utils.dart'; import 'package:it_resource_exchange_app/model/page_result.dart'; import "package:it_resource_exchange_app/model/home_info.dart"; import 'package:it_resource_exchange_app/widgets/load_state_layout_widget.dart'; class ClassifyListView extends StatefulWidget { final CateInfo cate; ClassifyListView(this.cate); @override _ClassifyListViewState createState() => _ClassifyListViewState(); } class _ClassifyListViewState extends State<ClassifyListView> with AutomaticKeepAliveClientMixin { //页面加载状态,默认为加载中 LoadState _layoutState = LoadState.State_Loading; RefreshController _refreshController; PageResult pageResult; List<RecommendProductList> productList = []; @override void initState() { super.initState(); _refreshController = RefreshController(); loadData(); } @override bool get wantKeepAlive => true; SmartRefresher _buildRefreshListView() { return SmartRefresher( controller: _refreshController, enablePullUp: true, enablePullDown: true, header: buildDefaultHeader(), footer: buildDefaultFooter(), onRefresh: () { loadData(loadMore: false); }, onLoading: () { loadData(loadMore: true); }, child: ListView.builder( itemCount: productList.length, itemBuilder: (context, index) { return ClassifyItemView( recomendProduct: productList[index], onPressed: () { int productId = productList[index].productId; ITRouter.push(context, Routes.productDetailPage, {'productId': productId}); }, ); }, ), ); } @override Widget build(BuildContext context) { super.build(context); return Container( color: Colors.white, child: LoadStateLayout( state: _layoutState, errorRetry: () { setState(() { _layoutState = LoadState.State_Loading; }); this.loadData(); }, successWidget: _buildRefreshListView(), ), ); } void loadData({bool loadMore = false}) { int page = (pageResult == null || loadMore == false) ? 1 : pageResult.currentPage + 1; NetworkUtils.requestProductListByCateId(this.widget.cate.cateId, page) .then((res) { if (res.status == 200) { pageResult = PageResult.fromJson(res.data); if (!this.mounted) { return; } if (loadMore) { if (pageResult.items.length > 0) { var tempList = pageResult.items .map((m) => RecommendProductList.fromJson(m)) .toList(); productList.addAll(tempList); _refreshController.loadComplete(); } else { _refreshController.loadNoData(); } setState(() {}); } else { if (pageResult.items.length == 0) { setState(() { _layoutState = LoadState.State_Empty; }); } else { productList = pageResult.items .map((m) => RecommendProductList.fromJson(m)) .toList(); _refreshController.refreshCompleted(); setState(() { _layoutState = LoadState.State_Success; }); } } } else { //请求失败 if (loadMore) { _refreshController.loadComplete(); setState(() {}); } else { _refreshController.refreshFailed(); setState(() { _layoutState = loadStateByErrorCode(res.status); }); } } }); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/classify/classify_page.dart
import 'package:flutter/material.dart'; import 'classify_list_view.dart'; import 'package:it_resource_exchange_app/net/network_utils.dart'; import 'package:it_resource_exchange_app/model/cate_info.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show AppColors; import 'package:it_resource_exchange_app/widgets/load_state_layout_widget.dart'; class ClassifyPage extends StatefulWidget { @override _ClassifyPageState createState() => _ClassifyPageState(); } class _ClassifyPageState extends State<ClassifyPage> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin{ TabController _tabController; List<CateInfo> cateList = []; //页面加载状态,默认为加载中 LoadState _layoutState = LoadState.State_Loading; @override void initState() { super.initState(); loadData(); } @override void dispose() { _tabController.dispose(); super.dispose(); } @override bool get wantKeepAlive => true; loadData() { NetworkUtils.requestCategoryListData().then((res) { if (res.status == 200) { cateList = (res.data as List).map((m) =>CateInfo.fromJson(m)).toList(); //添加全部分类 cateList.insert(0, CateInfo(null, 0, "全部", 0)); _tabController = TabController(vsync: this, length: cateList.length); setState(() { _layoutState = LoadState.State_Success; }); }else { setState(() { _layoutState = loadStateByErrorCode(res.status); }); } }); } Widget _buildTabPageView() { return Column( children: <Widget>[ Container( decoration: BoxDecoration( color: Theme.of(context).canvasColor, border: Border( bottom: BorderSide( width: 0.0, color: AppColors.DividerColor, ) ) ), child: TabBar( controller: _tabController, isScrollable: true, labelColor: AppColors.PrimaryColor, indicatorColor: AppColors.PrimaryColor, tabs: cateList.map<Widget>((cate){ return Tab(text: cate.cateTitle); }).toList() ), ), Expanded( child: TabBarView( controller: _tabController, children: cateList.map<Widget>((CateInfo cate) { return ClassifyListView(cate); }).toList() ), ) ], ); } @override Widget build(BuildContext context) { super.build(context); return LoadStateLayout( state: _layoutState, errorRetry: () { setState(() { _layoutState = LoadState.State_Loading; }); this.loadData(); }, successWidget: _buildTabPageView(), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/collection/my_collection_list_page.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/model/collect_product_info.dart'; import 'package:it_resource_exchange_app/net/network_utils.dart'; import 'package:it_resource_exchange_app/routes/it_router.dart'; import 'package:it_resource_exchange_app/routes/routes.dart'; import 'package:it_resource_exchange_app/model/product_detail.dart'; import '../my_product_list/my_product_item_view.dart'; import 'package:it_resource_exchange_app/widgets/load_state_layout_widget.dart'; import 'my_collection_item_view.dart'; class MyCollectionListPage extends StatefulWidget { @override _MyCollectionListPageState createState() => _MyCollectionListPageState(); } class _MyCollectionListPageState extends State<MyCollectionListPage> { //页面加载状态,默认为加载中 LoadState _layoutState = LoadState.State_Loading; List<CollectProductInfo> productList = []; void initState() { super.initState(); loadData(); } loadData() { NetworkUtils.requestMyCollectionListData().then((res) { if (res.status == 200) { productList = (res.data as List) .map((m) => CollectProductInfo.fromJson(m)) .toList(); setState(() { _layoutState = LoadState.State_Success; }); } else { setState(() { _layoutState = loadStateByErrorCode(res.status); }); } }); } _buildListView() { return ListView.builder( itemCount: productList.length, itemBuilder: (context, index) { return MyCollectionItemView( product: productList[index], onPressed: () { CollectProductInfo product = productList[index]; int productId = product.productId; ITRouter.push( context, Routes.productDetailPage, {'productId': productId}); }, ); }, ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( title: Text( "我的收藏", style: TextStyle(color: Colors.white), ), elevation: 0.0, iconTheme: IconThemeData( color: Colors.white, ), ), body: LoadStateLayout( state: _layoutState, errorRetry: () { setState(() { _layoutState = LoadState.State_Loading; }); this.loadData(); }, successWidget: _buildListView(), ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/collection/my_collection_item_view.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show AppSize, AppColors; import 'package:cached_network_image/cached_network_image.dart'; import '../../model/collect_product_info.dart'; import 'package:intl/intl.dart'; class MyCollectionItemView extends StatelessWidget { const MyCollectionItemView({Key key, this.product, this.onPressed}) : assert(product != null), super(key: key); final CollectProductInfo product; final VoidCallback onPressed; @override Widget build(BuildContext context) { var format = new DateFormat('yyyy-MM-dd HH:mm'); var date = DateTime.fromMillisecondsSinceEpoch(product.createdTime); var createDateStr = format.format(date); return GestureDetector( onTap: this.onPressed, child: Container( height: 100.0, padding: EdgeInsets.only(left: 10.0, right: 10.0), decoration: BoxDecoration( border: Border( bottom: BorderSide( width: AppSize.DividerWidth, color: AppColors.DividerColor, ))), child: Row( children: <Widget>[ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( padding: EdgeInsets.only(top: 10.0), child: Text( product.productTitle, style: TextStyle( fontSize: 15.0, color: AppColors.DarkTextColor), ), ), Container( padding: EdgeInsets.only(bottom: 10.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text(product?.cateTitle ?? '', style: TextStyle( color: AppColors.LightTextColor, fontSize: 12.0)), Text(createDateStr, style: TextStyle( color: AppColors.LightTextColor, fontSize: 12.0)), ], ), ) ], ), ), Container( padding: EdgeInsets.only(left: 6.0), width: 120.0, height: 80.0, child: CachedNetworkImage( imageUrl: product.coverUrl, placeholder: (context, url) => Image.asset('./assets/imgs/img_default.png'), fit: BoxFit.cover, ), ), ], )), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/profile/profile_page.dart
import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:it_resource_exchange_app/routes/it_router.dart'; import 'package:it_resource_exchange_app/routes/routes.dart'; import './full_width_button.dart'; import './profile_header_info.dart'; import 'package:it_resource_exchange_app/common/constant.dart'; import '../../net/network_utils.dart'; import '../../model/user_info.dart'; import '../../utils/user_utils.dart'; import 'package:oktoast/oktoast.dart'; import 'package:it_resource_exchange_app/pages/create/new_goods_page.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show APPIcons; class ProfilePage extends StatefulWidget { @override _ProfilePageState createState() => _ProfilePageState(); } class _ProfilePageState extends State<ProfilePage> { static const SEPARATE_SIZE = 20.0; logout() { UserInfo userInfo = UserUtils.getUserInfo(); NetworkUtils.logout(userInfo.userId.toString()).then((res) { if (res.status == 200) { UserUtils.removeUserInfo(); // 保存成功,跳转到登录页面 ITRouter.push(context, Routes.loginPage, {}, clearStack: true, transition: TransitionType.nativeModal); } else { showToast(res.message, duration: Duration(milliseconds: 1500)); } }); } Widget _buildLogoutBtn() { return Padding( padding: EdgeInsets.only(left: 30.0, right: 30.0), child: RaisedButton( padding: EdgeInsets.symmetric(vertical: 12), color: AppColors.PrimaryColor, textColor: Colors.white, disabledColor: AppColors.DisableTextColor, onPressed: () { showDialog<Null>( context: context, barrierDismissible: false, builder: (BuildContext context) { return CupertinoAlertDialog( title: Text('提示'), content: SingleChildScrollView( child: ListBody( children: <Widget>[ Text('确定要退出登录吗?'), ], ), ), actions: <Widget>[ CupertinoDialogAction( child: Text('确定'), onPressed: () { Navigator.of(context).pop(); logout(); }, ), CupertinoDialogAction( child: Text('取消'), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); }, child: Text( '退出登录', style: TextStyle(fontSize: 16.0, color: Colors.white), ), ), ); } @override Widget build(BuildContext context) { return ListView(children: <Widget>[ ProfileHeaderInfoView(onPressed: () { //跳转到个人信息页面 }), SizedBox(height: SEPARATE_SIZE), FullWidthButton( iconData: APPIcons.CollectionData, title: '我的收藏', showDivider: false, onPressed: () { ITRouter.push(context, Routes.myCollectionListPage, {}); }, ), SizedBox(height: SEPARATE_SIZE), FullWidthButton( iconData: APPIcons.ProfileListImgData, title: '资源列表', showDivider: true, onPressed: () { ITRouter.push(context, Routes.myProductListPage, {}); }, ), FullWidthButton( iconData: APPIcons.ProfileAddImgData, title: '发布资源', showDivider: false, onPressed: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) => NewGoodsPage())); }, ), // SizedBox(height: SEPARATE_SIZE), // FullWidthButton( // iconData: APPIcons.ProfileSettingImgData, // title: '设置', // showDivider: false, // onPressed: () {}, // ), SizedBox(height: 100), _buildLogoutBtn() ]); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/profile/profile_header_info.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show APPIcons; import 'package:it_resource_exchange_app/common/constant.dart'; import 'package:it_resource_exchange_app/model/user_info.dart'; import 'package:it_resource_exchange_app/utils/user_utils.dart'; import 'package:cached_network_image/cached_network_image.dart'; class ProfileHeaderInfoView extends StatelessWidget { const ProfileHeaderInfoView({this.onPressed}); final VoidCallback onPressed; @override Widget build(BuildContext context) { UserInfo userInfo = UserUtils.getUserInfo(); Widget avatar; if (userInfo.avatar != null) { avatar = CachedNetworkImage( imageUrl: userInfo.avatar, placeholder: (context, url) => APPIcons.PlaceHolderAvatar, fit: BoxFit.cover, height: 60.0, width: 60.0, errorWidget: (context, url, error) => new Icon(Icons.error), ); } else { avatar = APPIcons.PlaceHolderAvatar; } return Container( height: 150, color: Colors.white, child: FlatButton( onPressed: this.onPressed, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ SizedBox(height: 20), Expanded( child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ ClipOval( child: avatar, ), SizedBox(height: 5,), Text( userInfo.account, style: TextStyle(color: AppColors.DarkTextColor, fontSize: 15), ), Padding( padding: EdgeInsets.only(top: 6.0), child: Text( userInfo.intro ?? '此人很懒,什么都没写~', style: Theme.of(context) .textTheme .body1 .copyWith(fontSize: 12, color: Color(0xff818181)), ), ) ], ), ) ], ), ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/profile/full_width_button.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show AppColors, AppSize, Constant; class FullWidthButton extends StatelessWidget { static const HORIZONTAL_PADDING= 20.0; static const VERTICAL_PADDING = 13.0; const FullWidthButton({ @required this.title, @required this.iconData, @required this.onPressed, this.showDivider: false, }) : assert(iconData != null), assert(title != null), assert(onPressed != null); final String title; final IconData iconData; final bool showDivider; final VoidCallback onPressed; @override Widget build(BuildContext context) { final pureButton = Row( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Icon( iconData, size: 24.0, color: AppColors.PrimaryColor, ), SizedBox(width: HORIZONTAL_PADDING), Expanded( child: Text(title, style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.normal),), ), Icon( IconData( 0xe664, fontFamily: Constant.IconFontFamily, ), size: 22.0, color: AppColors.ArrowNormalColor, ), ], ); final borderButton = Container( decoration: BoxDecoration( border: Border( bottom: BorderSide(color: AppColors.DividerColor, width: AppSize.DividerWidth) ), ), padding: EdgeInsets.only(bottom: VERTICAL_PADDING), child: pureButton, ); return FlatButton( onPressed: this.onPressed, padding: EdgeInsets.only( left: HORIZONTAL_PADDING, right: HORIZONTAL_PADDING, top: VERTICAL_PADDING, bottom: showDivider ? 0.0 : VERTICAL_PADDING), color: Colors.white, child: showDivider ? borderButton : pureButton, ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/my_product_list/my_product_list_page.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/net/network_utils.dart'; import 'package:it_resource_exchange_app/routes/it_router.dart'; import 'package:it_resource_exchange_app/routes/routes.dart'; import 'package:it_resource_exchange_app/utils/user_utils.dart'; import 'package:it_resource_exchange_app/model/product_detail.dart'; import './my_product_item_view.dart'; import 'package:it_resource_exchange_app/widgets/load_state_layout_widget.dart'; class MyProductListPage extends StatefulWidget { @override _MyProductListPageState createState() => _MyProductListPageState(); } class _MyProductListPageState extends State<MyProductListPage> { //页面加载状态,默认为加载中 LoadState _layoutState = LoadState.State_Loading; List<ProductDetail> productList = []; void initState() { super.initState(); loadData(); } loadData() { var userId = UserUtils.getUserInfo().userId; NetworkUtils.requestMyProductListData(userId).then((res) { if (res.status == 200) { productList = (res.data as List).map((m) => ProductDetail.fromJson(m)).toList(); setState(() { _layoutState = LoadState.State_Success; }); } else { setState(() { _layoutState = loadStateByErrorCode(res.status); }); } }); } _buildListView() { return ListView.builder( itemCount: productList.length, itemBuilder: (context, index) { return MyProductItemView( product: productList[index], onPressed: () { ProductDetail product = productList[index]; ITRouter.push(context, Routes.newProductPage,{'productId': product.productId}).then((res) { if (res) { this.loadData(); setState(() { _layoutState = LoadState.State_Loading; }); } }); }, ); }, ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( title: Text( "我的资源", style: TextStyle(color: Colors.white), ), elevation: 0.0, iconTheme: IconThemeData( color: Colors.white, ), ), body: LoadStateLayout( state: _layoutState, errorRetry: () { setState(() { _layoutState = LoadState.State_Loading; }); this.loadData(); }, successWidget: _buildListView(), ), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/my_product_list/my_product_item_view.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show AppSize, AppColors; import 'package:cached_network_image/cached_network_image.dart'; import '../../model/product_detail.dart'; class MyProductItemView extends StatelessWidget { const MyProductItemView({Key key, this.product, this.onPressed}) : assert(product != null), super(key: key); final ProductDetail product; final VoidCallback onPressed; String productStatusDesc(int status) { var desc; switch (status) { case 1000: desc = '待审核'; break; case 1001: desc = '已拒绝'; break; case 1002: case 2000: desc = '已通过'; break; case 2001: desc = '已下架'; break; default: desc = '未知'; } return desc; } Color productStatusColor(int status) { var color; switch (status) { case 1000: color = Colors.yellow; break; case 1001: color = Colors.red; break; case 1002: case 2000: color = Colors.green; break; case 2001: color = Colors.grey; break; default: color = null; } return color; } @override Widget build(BuildContext context) { return GestureDetector( onTap: this.onPressed, child: Container( height: 100.0, padding: EdgeInsets.only(left: 10.0, right: 10.0), decoration: BoxDecoration( border: Border( bottom: BorderSide( width: AppSize.DividerWidth, color: AppColors.DividerColor, ))), child: Row( children: <Widget>[ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( padding: EdgeInsets.only(top: 10.0), child: Text( product.productTitle, style: TextStyle(fontSize: 15.0, color: AppColors.DarkTextColor), ), ), Container( padding: EdgeInsets.only(bottom: 10.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text(product.cateTitle, style: TextStyle( color: AppColors.LightTextColor, fontSize: 14.0)), Text(productStatusDesc(product.productStatus), style: TextStyle( color: productStatusColor(product.productStatus), fontSize: 14.0)), ], ), ) ], ), ), Container( padding: EdgeInsets.only(left: 6.0), width: 120.0, height: 80.0, child: CachedNetworkImage( imageUrl: product.coverUrl, placeholder: (context, url) => Image.asset('./assets/imgs/img_default.png'), fit: BoxFit.cover, ), ), ], )), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/home/home_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:it_resource_exchange_app/routes/it_router.dart'; import 'package:it_resource_exchange_app/routes/routes.dart'; import './goods_item_view.dart'; import 'package:it_resource_exchange_app/net/network_utils.dart'; import 'package:it_resource_exchange_app/model/home_info.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show AppColors, AppSize, APPIcons; import 'package:cached_network_image/cached_network_image.dart'; import 'package:it_resource_exchange_app/widgets/load_state_layout_widget.dart'; class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin { HomeInfo homeInfo; List<AdvertiseList> bannerInfoList = []; //页面加载状态,默认为加载中 LoadState _layoutState = LoadState.State_Loading; void initState() { super.initState(); loadData(); } @override bool get wantKeepAlive => true; loadData() async { NetworkUtils.requestHomeAdvertisementsAndRecommendProductsData() .then((res) { if (res.status == 200) { homeInfo = HomeInfo.fromJson(res.data); setState(() { _layoutState = LoadState.State_Success; }); } else { setState(() { _layoutState = loadStateByErrorCode(res.status); }); } }); } Widget _buildListView() { return ListView.builder( physics: AlwaysScrollableScrollPhysics(), padding: EdgeInsets.all(1.0), itemCount: homeInfo == null ? 0 : (1 + homeInfo.recommendProductList.length), itemBuilder: (context, i) { if (i == 0) { return Container( height: 220, child: Swiper( itemBuilder: (BuildContext context, int index) { return CachedNetworkImage( imageUrl: homeInfo.advertiseList[index].adCoverUrl, placeholder: (context, url) { return Container( decoration: BoxDecoration( border: Border.all( color: AppColors.BackgroundColor, width: AppSize.DividerWidth), borderRadius: BorderRadius.circular(2), ), width: double.infinity, height: double.infinity, child: Center( child: Icon( APPIcons.AddImgData, color: AppColors.PrimaryColor, size: 40, ), ), ); }, fit: BoxFit.cover, ); }, autoplay: true, itemCount: homeInfo.advertiseList.length, pagination: SwiperPagination(builder: SwiperPagination.dots), control: null, onTap: (index) { AdvertiseList advertise = homeInfo.advertiseList[index]; if (advertise.adType == 1) { String productId = homeInfo.advertiseList[index].adProductId; ITRouter.push(context, Routes.productDetailPage, {'productId': productId}); } else { ITRouter.push(context, Routes.webPage, {'title': advertise.adTitle, 'url': advertise.adDetailUrl}); } }, ), ); } else { return GoodsItemView( recomendProduct: homeInfo.recommendProductList[i - 1], onPressed: () { int productId = homeInfo.recommendProductList[i - 1].productId; ITRouter.push(context, Routes.productDetailPage, {'productId': productId}); }, ); } }, ); } @override Widget build(BuildContext context) { super.build(context); return LoadStateLayout( state: _layoutState, errorRetry: () { setState(() { _layoutState = LoadState.State_Loading; }); this.loadData(); }, successWidget: _buildListView(), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/home/goods_item_view.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show AppSize, AppColors; import 'package:cached_network_image/cached_network_image.dart'; import '../../model/home_info.dart'; import 'package:intl/intl.dart'; class GoodsItemView extends StatelessWidget { const GoodsItemView({Key key, this.recomendProduct, this.onPressed}) : assert(recomendProduct != null), super(key: key); final RecommendProductList recomendProduct; final VoidCallback onPressed; @override Widget build(BuildContext context) { var format = new DateFormat('yyyy-MM-dd HH:mm'); var date = DateTime.fromMillisecondsSinceEpoch(recomendProduct.createdTime); var createDateStr = format.format(date); return GestureDetector( onTap: this.onPressed, child: Container( height: 100.0, padding: EdgeInsets.only(left: 10.0, right: 10.0), decoration: BoxDecoration( border: Border( bottom: BorderSide( width: AppSize.DividerWidth, color: AppColors.DividerColor, ))), child: Row( children: <Widget>[ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( padding: EdgeInsets.only(top: 10.0), child: Text( recomendProduct.productTitle, style: TextStyle( fontSize: 15.0, color: AppColors.DarkTextColor), ), ), Container( padding: EdgeInsets.only(bottom: 10.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text(recomendProduct?.cateTitle ?? '', style: TextStyle( color: AppColors.LightTextColor, fontSize: 12.0)), Text(createDateStr, style: TextStyle( color: AppColors.LightTextColor, fontSize: 12.0)), ], ), ) ], ), ), Container( padding: EdgeInsets.only(left: 6.0), width: 120.0, height: 80.0, child: CachedNetworkImage( imageUrl: recomendProduct.coverUrl, placeholder: (context, url) => Image.asset('./assets/imgs/img_default.png'), fit: BoxFit.cover, ), ), ], )), ); } }
0
mirrored_repositories/it_resource_exchange_app/lib/pages
mirrored_repositories/it_resource_exchange_app/lib/pages/web/webview_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show AppColors; class WebviewPage extends StatefulWidget { final String title; final String url; WebviewPage({Key key, @required this.title, @required this.url}) : super(key: key); @override _WebviewPageState createState() => _WebviewPageState(); } class _WebviewPageState extends State<WebviewPage> { final _loadingContainer = Container( color: Colors.white, constraints: BoxConstraints.expand(), child: Center( child: Opacity( opacity: 0.9, child: SpinKitRing( color: AppColors.PrimaryColor, size: 50.0, ), ), ), ); @override Widget build(BuildContext context) { return WebviewScaffold( url: this.widget.url, appBar: AppBar( title: Text(this.widget.title, style: TextStyle(color: Colors.white)), elevation: 0.0, iconTheme: IconThemeData( color: Colors.white, ), ), withZoom: true, withLocalStorage: true, hidden: true, initialChild: _loadingContainer, ); } }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/user_info.dart
import 'package:json_annotation/json_annotation.dart'; part 'user_info.g.dart'; @JsonSerializable() class UserInfo extends Object { @JsonKey(name: 'userId') int userId; @JsonKey(name: 'nickname') String nickname; @JsonKey(name: 'account') String account; @JsonKey(name: 'intro') String intro; @JsonKey(name: 'token') String token; @JsonKey(name: 'expireTime') int expireTime; @JsonKey(name: 'userRole') int userRole; @JsonKey(name: 'avatar') String avatar; UserInfo(this.userId,this.nickname,this.account,this.intro,this.token,this.expireTime,this.userRole,this.avatar,); factory UserInfo.fromJson(Map<String, dynamic> srcJson) => _$UserInfoFromJson(srcJson); Map<String, dynamic> toJson() => _$UserInfoToJson(this); }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/user_info.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'user_info.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** UserInfo _$UserInfoFromJson(Map<String, dynamic> json) { return UserInfo( json['userId'] as int, json['nickname'] as String, json['account'] as String, json['intro'] as String, json['token'] as String, json['expireTime'] as int, json['userRole'] as int, json['avatar'] as String); } Map<String, dynamic> _$UserInfoToJson(UserInfo instance) => <String, dynamic>{ 'userId': instance.userId, 'nickname': instance.nickname, 'account': instance.account, 'intro': instance.intro, 'token': instance.token, 'expireTime': instance.expireTime, 'userRole': instance.userRole, 'avatar': instance.avatar };
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/page_result.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'page_result.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** PageResult _$PageResultFromJson(Map<String, dynamic> json) { return PageResult( json['currentPage'] as int, json['pageSize'] as int, json['totalNum'] as int, json['isMore'] as int, json['totalPage'] as int, json['startIndex'] as int, (json['items'] as List)?.map((e) => e as Map<String, dynamic>)?.toList()); } Map<String, dynamic> _$PageResultToJson(PageResult instance) => <String, dynamic>{ 'currentPage': instance.currentPage, 'pageSize': instance.pageSize, 'totalNum': instance.totalNum, 'isMore': instance.isMore, 'totalPage': instance.totalPage, 'startIndex': instance.startIndex, 'items': instance.items };
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/base_result.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'base_result.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** BaseResult _$BaseResultFromJson(Map<String, dynamic> json) { return BaseResult( json['data'], json['status'] as int, json['message'] as String); } Map<String, dynamic> _$BaseResultToJson(BaseResult instance) => <String, dynamic>{ 'data': instance.data, 'status': instance.status, 'message': instance.message };
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/comment_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'comment_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** CommentModel _$CommentModelFromJson(Map<String, dynamic> json) { return CommentModel( json['content'] as String, json['createdTime'] as int, json['createUserId'] as int, json['createUserName'] as String, json['createUserAvatar'] as String, json['parentUserId'] as int, json['parentUserName'] as String, json['parentUserAvatar'] as String, json['productId'] as int, (json['commentList'] as List) ?.map((e) => e == null ? null : CommentModel.fromJson(e as Map<String, dynamic>)) ?.toList(), json['commentId'] as int, json['parentCommentId'] as int); } Map<String, dynamic> _$CommentModelToJson(CommentModel instance) => <String, dynamic>{ 'content': instance.content, 'createdTime': instance.createdTime, 'createUserId': instance.createUserId, 'createUserName': instance.createUserName, 'createUserAvatar': instance.createUserAvatar, 'parentUserId': instance.parentUserId, 'parentUserName': instance.parentUserName, 'parentUserAvatar': instance.parentUserAvatar, 'productId': instance.productId, 'commentList': instance.commentList, 'commentId': instance.commentId, 'parentCommentId': instance.parentCommentId };
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/page_result.dart
import 'package:json_annotation/json_annotation.dart'; part 'page_result.g.dart'; @JsonSerializable() class PageResult extends Object { @JsonKey(name: 'currentPage') int currentPage; @JsonKey(name: 'pageSize') int pageSize; @JsonKey(name: 'totalNum') int totalNum; @JsonKey(name: 'isMore') int isMore; @JsonKey(name: 'totalPage') int totalPage; @JsonKey(name: 'startIndex') int startIndex; @JsonKey(name: 'items') List<Map> items; PageResult(this.currentPage,this.pageSize,this.totalNum,this.isMore,this.totalPage,this.startIndex,this.items,); factory PageResult.fromJson(Map<String, dynamic> srcJson) => _$PageResultFromJson(srcJson); Map<String, dynamic> toJson() => _$PageResultToJson(this); }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/movie_info.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'movie_info.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** MovieInfo _$MovieInfoFromJson(Map<String, dynamic> json) { return MovieInfo( json['director'] as String, json['movieId'] as int, json['movieArea'] as int, json['score'] as int, json['status'] as int, json['tradeCount'] as int, json['movieName'] as String, json['language'] as int, json['quality'] as int, json['coverUrl'] as String, json['isDelete'] as bool, json['desc'] as String, json['rolesNames'] as String, json['releaseYear'] as String, json['playUrl'] as String, json['cateId'] as String, json['price'] as double); } Map<String, dynamic> _$MovieInfoToJson(MovieInfo instance) => <String, dynamic>{ 'director': instance.director, 'movieId': instance.movieId, 'movieArea': instance.movieArea, 'score': instance.score, 'status': instance.status, 'tradeCount': instance.tradeCount, 'movieName': instance.movieName, 'language': instance.language, 'quality': instance.quality, 'coverUrl': instance.coverUrl, 'isDelete': instance.isDelete, 'desc': instance.desc, 'rolesNames': instance.rolesNames, 'releaseYear': instance.releaseYear, 'playUrl': instance.playUrl, 'cateId': instance.cateId, 'price': instance.price };
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/product_detail.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'product_detail.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** ProductDetail _$ProductDetailFromJson(Map<String, dynamic> json) { return ProductDetail( json['commentCount'] as int, json['productDesc'] as String, json['tradeCount'] as int, json['productTitle'] as String, json['productStatus'] as int, json['coverUrl'] as String, json['productAddressUrl'] as String, json['updateTime'] as int, json['productAddressPassword'] as String, json['keywords'] as String, (json['price'] as num)?.toDouble(), json['cateTitle'] as String, json['isDelete'] as bool, json['imgUrls'] as String, json['createdTime'] as int, json['createdBy'] as String, json['productId'] as int, json['cateId'] as String, json['collectId'] as int); } Map<String, dynamic> _$ProductDetailToJson(ProductDetail instance) => <String, dynamic>{ 'commentCount': instance.commentCount, 'productDesc': instance.productDesc, 'tradeCount': instance.tradeCount, 'productTitle': instance.productTitle, 'productStatus': instance.productStatus, 'coverUrl': instance.coverUrl, 'productAddressUrl': instance.productAddressUrl, 'updateTime': instance.updateTime, 'productAddressPassword': instance.productAddressPassword, 'keywords': instance.keywords, 'price': instance.price, 'cateTitle': instance.cateTitle, 'isDelete': instance.isDelete, 'imgUrls': instance.imgUrls, 'createdTime': instance.createdTime, 'createdBy': instance.createdBy, 'productId': instance.productId, 'cateId': instance.cateId, 'collectId': instance.collectId };
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/upload_info.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'upload_info.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** UploadInfo _$UploadInfoFromJson(Map<String, dynamic> json) { return UploadInfo(json['fileName'] as String, json['downloadUrl'] as String, json['token'] as String); } Map<String, dynamic> _$UploadInfoToJson(UploadInfo instance) => <String, dynamic>{ 'fileName': instance.fileName, 'downloadUrl': instance.downloadUrl, 'token': instance.token };
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/collect_product_info.dart
import 'package:json_annotation/json_annotation.dart'; part 'collect_product_info.g.dart'; @JsonSerializable() class CollectProductInfo extends Object { @JsonKey(name: 'price') double price; @JsonKey(name: 'cateId') String cateId; @JsonKey(name: 'coverUrl') String coverUrl; @JsonKey(name: 'updateTime') int updateTime; @JsonKey(name: 'productId') int productId; @JsonKey(name: 'productStatus') int productStatus; @JsonKey(name: 'collectId') int collectId; @JsonKey(name: 'createdBy') String createdBy; @JsonKey(name: 'productTitle') String productTitle; @JsonKey(name: 'imgUrls') String imgUrls; @JsonKey(name: 'productAddressUrl') String productAddressUrl; @JsonKey(name: 'keywords') String keywords; @JsonKey(name: 'createdTime') int createdTime; @JsonKey(name: 'productDesc') String productDesc; @JsonKey(name: 'tradeCount') int tradeCount; @JsonKey(name: 'isDelete') bool isDelete; @JsonKey(name: 'cateTitle') String cateTitle; CollectProductInfo(this.price,this.cateId,this.coverUrl,this.updateTime,this.productId,this.productStatus,this.collectId,this.createdBy,this.productTitle,this.imgUrls,this.productAddressUrl,this.keywords,this.createdTime,this.productDesc,this.tradeCount,this.isDelete,this.cateTitle,); factory CollectProductInfo.fromJson(Map<String, dynamic> srcJson) => _$CollectProductInfoFromJson(srcJson); Map<String, dynamic> toJson() => _$CollectProductInfoToJson(this); }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/home_info.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'home_info.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** HomeInfo _$HomeInfoFromJson(Map<String, dynamic> json) { return HomeInfo( (json['advertiseList'] as List) ?.map((e) => e == null ? null : AdvertiseList.fromJson(e as Map<String, dynamic>)) ?.toList(), (json['recommendProductList'] as List) ?.map((e) => e == null ? null : RecommendProductList.fromJson(e as Map<String, dynamic>)) ?.toList()); } Map<String, dynamic> _$HomeInfoToJson(HomeInfo instance) => <String, dynamic>{ 'advertiseList': instance.advertiseList, 'recommendProductList': instance.recommendProductList }; AdvertiseList _$AdvertiseListFromJson(Map<String, dynamic> json) { return AdvertiseList( json['adId'] as int, json['adTitle'] as String, json['adDetailUrl'] as String, json['adProductId'] as String, json['adType'] as int, json['adCoverUrl'] as String); } Map<String, dynamic> _$AdvertiseListToJson(AdvertiseList instance) => <String, dynamic>{ 'adId': instance.adId, 'adTitle': instance.adTitle, 'adDetailUrl': instance.adDetailUrl, 'adProductId': instance.adProductId, 'adType': instance.adType, 'adCoverUrl': instance.adCoverUrl }; RecommendProductList _$RecommendProductListFromJson(Map<String, dynamic> json) { return RecommendProductList( json['coverUrl'] as String, json['cateId'] as String, json['productAddressPassword'] as String, json['imgUrls'] as String, json['keywords'] as String, (json['price'] as num)?.toDouble(), json['productTitle'] as String, json['revision'] as String, json['productStatus'] as int, json['productDesc'] as String, json['recommendId'] as int, json['cateTitle'] as String, json['isDelete'] as bool, json['productId'] as int, json['productAddressUrl'] as String, json['updateBy'] as String, json['updateTime'] as int, json['tradeCount'] as int, json['createdBy'] as String, json['createdTime'] as int); } Map<String, dynamic> _$RecommendProductListToJson( RecommendProductList instance) => <String, dynamic>{ 'coverUrl': instance.coverUrl, 'cateId': instance.cateId, 'productAddressPassword': instance.productAddressPassword, 'imgUrls': instance.imgUrls, 'keywords': instance.keywords, 'price': instance.price, 'productTitle': instance.productTitle, 'revision': instance.revision, 'productStatus': instance.productStatus, 'productDesc': instance.productDesc, 'recommendId': instance.recommendId, 'cateTitle': instance.cateTitle, 'isDelete': instance.isDelete, 'productId': instance.productId, 'productAddressUrl': instance.productAddressUrl, 'updateBy': instance.updateBy, 'updateTime': instance.updateTime, 'tradeCount': instance.tradeCount, 'createdBy': instance.createdBy, 'createdTime': instance.createdTime };
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/home_info.dart
import 'package:json_annotation/json_annotation.dart'; part 'home_info.g.dart'; @JsonSerializable() class HomeInfo extends Object { @JsonKey(name: 'advertiseList') List<AdvertiseList> advertiseList; @JsonKey(name: 'recommendProductList') List<RecommendProductList> recommendProductList; HomeInfo(this.advertiseList,this.recommendProductList,); factory HomeInfo.fromJson(Map<String, dynamic> srcJson) => _$HomeInfoFromJson(srcJson); Map<String, dynamic> toJson() => _$HomeInfoToJson(this); } @JsonSerializable() class AdvertiseList extends Object { @JsonKey(name: 'adId') int adId; @JsonKey(name: 'adTitle') String adTitle; @JsonKey(name: 'adDetailUrl') String adDetailUrl; @JsonKey(name: 'adProductId') String adProductId; @JsonKey(name: 'adType') int adType; @JsonKey(name: 'adCoverUrl') String adCoverUrl; AdvertiseList(this.adId,this.adTitle,this.adDetailUrl,this.adProductId,this.adType,this.adCoverUrl,); factory AdvertiseList.fromJson(Map<String, dynamic> srcJson) => _$AdvertiseListFromJson(srcJson); Map<String, dynamic> toJson() => _$AdvertiseListToJson(this); } @JsonSerializable() class RecommendProductList extends Object { @JsonKey(name: 'coverUrl') String coverUrl; @JsonKey(name: 'cateId') String cateId; @JsonKey(name: 'productAddressPassword') String productAddressPassword; @JsonKey(name: 'imgUrls') String imgUrls; @JsonKey(name: 'keywords') String keywords; @JsonKey(name: 'price') double price; @JsonKey(name: 'productTitle') String productTitle; @JsonKey(name: 'revision') String revision; @JsonKey(name: 'productStatus') int productStatus; @JsonKey(name: 'productDesc') String productDesc; @JsonKey(name: 'recommendId') int recommendId; @JsonKey(name: 'cateTitle') String cateTitle; @JsonKey(name: 'isDelete') bool isDelete; @JsonKey(name: 'productId') int productId; @JsonKey(name: 'productAddressUrl') String productAddressUrl; @JsonKey(name: 'updateBy') String updateBy; @JsonKey(name: 'updateTime') int updateTime; @JsonKey(name: 'tradeCount') int tradeCount; @JsonKey(name: 'createdBy') String createdBy; @JsonKey(name: 'createdTime') int createdTime; RecommendProductList(this.coverUrl,this.cateId,this.productAddressPassword,this.imgUrls,this.keywords,this.price,this.productTitle,this.revision,this.productStatus,this.productDesc,this.recommendId,this.cateTitle,this.isDelete,this.productId,this.productAddressUrl,this.updateBy,this.updateTime,this.tradeCount,this.createdBy,this.createdTime,); factory RecommendProductList.fromJson(Map<String, dynamic> srcJson) => _$RecommendProductListFromJson(srcJson); Map<String, dynamic> toJson() => _$RecommendProductListToJson(this); }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/comment_model.dart
import 'package:json_annotation/json_annotation.dart'; part 'comment_model.g.dart'; @JsonSerializable() class CommentModel extends Object { @JsonKey(name: 'content') String content; @JsonKey(name: 'createdTime') int createdTime; @JsonKey(name: 'createUserId') int createUserId; @JsonKey(name: 'createUserName') String createUserName; @JsonKey(name: 'createUserAvatar') String createUserAvatar; @JsonKey(name: 'parentUserId') int parentUserId; @JsonKey(name: 'parentUserName') String parentUserName; @JsonKey(name: 'parentUserAvatar') String parentUserAvatar; @JsonKey(name: 'productId') int productId; @JsonKey(name: 'commentList') List<CommentModel> commentList; @JsonKey(name: 'commentId') int commentId; @JsonKey(name: 'parentCommentId') int parentCommentId; CommentModel(this.content,this.createdTime,this.createUserId,this.createUserName,this.createUserAvatar,this.parentUserId,this.parentUserName,this.parentUserAvatar,this.productId,this.commentList,this.commentId,this.parentCommentId,); factory CommentModel.fromJson(Map<String, dynamic> srcJson) => _$CommentModelFromJson(srcJson); Map<String, dynamic> toJson() => _$CommentModelToJson(this); }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/base_result.dart
import 'package:json_annotation/json_annotation.dart'; part 'base_result.g.dart'; @JsonSerializable() class BaseResult { var data; int status; String message; BaseResult(this.data, this.status, this.message); factory BaseResult.fromJson(Map<String,dynamic> json) => _$BaseResultFromJson(json); Map<String,dynamic> toJson() => _$BaseResultToJson(this); }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/cate_info.dart
import 'package:json_annotation/json_annotation.dart'; part 'cate_info.g.dart'; @JsonSerializable() class CateInfo extends Object { @JsonKey(name: 'cateId') int cateId; @JsonKey(name: 'orderIndex') int orderIndex; @JsonKey(name: 'cateTitle') String cateTitle; @JsonKey(name: 'cateStatus') int cateStatus; CateInfo(this.cateId,this.orderIndex,this.cateTitle,this.cateStatus,); factory CateInfo.fromJson(Map<String, dynamic> srcJson) => _$CateInfoFromJson(srcJson); Map<String, dynamic> toJson() => _$CateInfoToJson(this); }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/movie_info.dart
import 'package:json_annotation/json_annotation.dart'; part 'movie_info.g.dart'; @JsonSerializable() class MovieInfo extends Object { @JsonKey(name: 'director') String director; @JsonKey(name: 'movieId') int movieId; @JsonKey(name: 'movieArea') int movieArea; @JsonKey(name: 'score') int score; @JsonKey(name: 'status') int status; @JsonKey(name: 'tradeCount') int tradeCount; @JsonKey(name: 'movieName') String movieName; @JsonKey(name: 'language') int language; @JsonKey(name: 'quality') int quality; @JsonKey(name: 'coverUrl') String coverUrl; @JsonKey(name: 'isDelete') bool isDelete; @JsonKey(name: 'desc') String desc; @JsonKey(name: 'rolesNames') String rolesNames; @JsonKey(name: 'releaseYear') String releaseYear; @JsonKey(name: 'playUrl') String playUrl; @JsonKey(name: 'cateId') String cateId; @JsonKey(name: 'price') double price; MovieInfo(this.director,this.movieId,this.movieArea,this.score,this.status,this.tradeCount,this.movieName,this.language,this.quality,this.coverUrl,this.isDelete,this.desc,this.rolesNames,this.releaseYear,this.playUrl,this.cateId,this.price,); factory MovieInfo.fromJson(Map<String, dynamic> srcJson) => _$MovieInfoFromJson(srcJson); Map<String, dynamic> toJson() => _$MovieInfoToJson(this); }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/product_detail.dart
import 'package:json_annotation/json_annotation.dart'; part 'product_detail.g.dart'; @JsonSerializable() class ProductDetail extends Object { @JsonKey(name: 'commentCount') int commentCount; @JsonKey(name: 'productDesc') String productDesc; @JsonKey(name: 'tradeCount') int tradeCount; @JsonKey(name: 'productTitle') String productTitle; @JsonKey(name: 'productStatus') int productStatus; @JsonKey(name: 'coverUrl') String coverUrl; @JsonKey(name: 'productAddressUrl') String productAddressUrl; @JsonKey(name: 'updateTime') int updateTime; @JsonKey(name: 'productAddressPassword') String productAddressPassword; @JsonKey(name: 'keywords') String keywords; @JsonKey(name: 'price') double price; @JsonKey(name: 'cateTitle') String cateTitle; @JsonKey(name: 'isDelete') bool isDelete; @JsonKey(name: 'imgUrls') String imgUrls; @JsonKey(name: 'createdTime') int createdTime; @JsonKey(name: 'createdBy') String createdBy; @JsonKey(name: 'productId') int productId; @JsonKey(name: 'cateId') String cateId; @JsonKey(name: 'collectId') int collectId; ProductDetail(this.commentCount,this.productDesc,this.tradeCount,this.productTitle,this.productStatus,this.coverUrl,this.productAddressUrl,this.updateTime,this.productAddressPassword,this.keywords,this.price,this.cateTitle,this.isDelete,this.imgUrls,this.createdTime,this.createdBy,this.productId,this.cateId,this.collectId); factory ProductDetail.fromJson(Map<String, dynamic> srcJson) => _$ProductDetailFromJson(srcJson); Map<String, dynamic> toJson() => _$ProductDetailToJson(this); }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/collect_product_info.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'collect_product_info.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** CollectProductInfo _$CollectProductInfoFromJson(Map<String, dynamic> json) { return CollectProductInfo( (json['price'] as num)?.toDouble(), json['cateId'] as String, json['coverUrl'] as String, json['updateTime'] as int, json['productId'] as int, json['productStatus'] as int, json['collectId'] as int, json['createdBy'] as String, json['productTitle'] as String, json['imgUrls'] as String, json['productAddressUrl'] as String, json['keywords'] as String, json['createdTime'] as int, json['productDesc'] as String, json['tradeCount'] as int, json['isDelete'] as bool, json['cateTitle'] as String); } Map<String, dynamic> _$CollectProductInfoToJson(CollectProductInfo instance) => <String, dynamic>{ 'price': instance.price, 'cateId': instance.cateId, 'coverUrl': instance.coverUrl, 'updateTime': instance.updateTime, 'productId': instance.productId, 'productStatus': instance.productStatus, 'collectId': instance.collectId, 'createdBy': instance.createdBy, 'productTitle': instance.productTitle, 'imgUrls': instance.imgUrls, 'productAddressUrl': instance.productAddressUrl, 'keywords': instance.keywords, 'createdTime': instance.createdTime, 'productDesc': instance.productDesc, 'tradeCount': instance.tradeCount, 'isDelete': instance.isDelete, 'cateTitle': instance.cateTitle };
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/upload_info.dart
import 'package:json_annotation/json_annotation.dart'; part 'upload_info.g.dart'; @JsonSerializable() class UploadInfo extends Object { @JsonKey(name: 'fileName') String fileName; @JsonKey(name: 'downloadUrl') String downloadUrl; @JsonKey(name: 'token') String token; UploadInfo(this.fileName,this.downloadUrl,this.token,); factory UploadInfo.fromJson(Map<String, dynamic> srcJson) => _$UploadInfoFromJson(srcJson); Map<String, dynamic> toJson() => _$UploadInfoToJson(this); }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/model/cate_info.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'cate_info.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** CateInfo _$CateInfoFromJson(Map<String, dynamic> json) { return CateInfo(json['cateId'] as int, json['orderIndex'] as int, json['cateTitle'] as String, json['cateStatus'] as int); } Map<String, dynamic> _$CateInfoToJson(CateInfo instance) => <String, dynamic>{ 'cateId': instance.cateId, 'orderIndex': instance.orderIndex, 'cateTitle': instance.cateTitle, 'cateStatus': instance.cateStatus };
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/common/constant.dart
import 'package:flutter/material.dart'; import 'package:it_resource_exchange_app/model/cate_info.dart'; import 'dart:math'; /// 颜色 class AppColors { static const PrimaryColor = Color(0xff2944CC); static const DividerColor = Color(0xffd9d9d9); static const ArrowNormalColor = Color(0xff999999); static const BackgroundColor = Color(0xffebebeb); static const DarkTextColor = Color(0xFF333333); static const MidTextColor = Color(0xFF666666); static const LightTextColor = Color(0xFF999999); static const DisableTextColor = Color(0xFFDCDCDC); static randomColor() { return Color.fromARGB(255, Random.secure().nextInt(255), Random.secure().nextInt(255), Random.secure().nextInt(255)); } } class AppSize { static const DividerWidth = 0.5; } class Constant { static const IconFontFamily = "appIconFont"; static final movieCateInfoList = [ CateInfo(1, 0, '动作', 0), CateInfo(2, 0, '喜剧', 0), CateInfo(3, 0, '爱情', 0), CateInfo(4, 0, '科幻', 0), CateInfo(5, 0, '恐怖', 0), CateInfo(6, 0, '剧情', 0), CateInfo(7, 0, '战争', 0), CateInfo(8, 0, '伦理', 0), CateInfo(9, 0, '奇幻', 0) ]; } class APPConfig { static const DEBUG = false; static const Server = "http://47.107.231.54:8090"; // static const Server = "http://localhost:8090"; } class APPIcons { static const PlaceHolderAvatar = Icon( IconData( 0xe642, fontFamily: Constant.IconFontFamily, ), size: 60.0, color: AppColors.ArrowNormalColor, ); static const AvatarData = IconData( 0xe642, fontFamily: Constant.IconFontFamily, ); static const AddImgData = IconData( 0xe70a, fontFamily: Constant.IconFontFamily, ); static const ProfileListImgData = IconData( 0xe64d, fontFamily: Constant.IconFontFamily, ); static const ProfileAddImgData = IconData( 0xe60c, fontFamily: Constant.IconFontFamily, ); static const ProfileSettingImgData = IconData( 0xe615, fontFamily: Constant.IconFontFamily, ); static const EmptyData = IconData( 0xe643, fontFamily: Constant.IconFontFamily, ); static const NetworkErrorData = IconData( 0xe86e, fontFamily: Constant.IconFontFamily, ); static const CollectionData = IconData( 0xe616, fontFamily: Constant.IconFontFamily, ); static const CollectSelectData = IconData( 0xe600, fontFamily: Constant.IconFontFamily, ); static const VideoData = IconData( 0xe60d, fontFamily: Constant.IconFontFamily, ); }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/net/code.dart
class Code { //网络错误 static const NETWORK_ERROR = -1; //请求超时 static const NETWOEK_TIMEROUT = -2; //网络返回数据格式化一次 static const NETWORK_JSON_EXCEPTION = -3; static const SUCCESS = 200; }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/net/http_manager.dart
import 'dart:io'; import 'package:dio/dio.dart'; import 'package:it_resource_exchange_app/model/base_result.dart'; import 'package:it_resource_exchange_app/utils/user_utils.dart'; import 'interceptors/logs_interceptor.dart'; import 'interceptors/error_interceptor.dart'; import 'interceptors/response_Interceptor.dart'; import './code.dart'; import 'dart:typed_data'; enum HttpMethod { GET, POST } const HTTPMethodValues = ['GET', 'POST']; const ContentTypeURLEncoded = 'application/x-www-form-urlencoded'; class HttpManager { Dio _dio = Dio(); HttpManager() { _dio.interceptors.add(LogsInterceptor()); _dio.interceptors.add(ErrorInterceptor(_dio)); _dio.interceptors.add(ResponseInterceptor()); } request(HttpMethod method, String url, Map<String, dynamic> params, {ContentType contentType}) async { Options _options; Map<String, dynamic> header; var type = contentType == null ? ContentType.parse(ContentTypeURLEncoded) : contentType; if (UserUtils.isLogin()) { header = {'token': UserUtils.getUserInfo().token ?? ""}; } if (method == HttpMethod.GET) { _options = Options( method: HTTPMethodValues[method.index], contentType: type, headers: header); } else { _options = Options( method: HTTPMethodValues[method.index], contentType: type, headers: header); } Response response; try { if (method == HttpMethod.GET) { response = await _dio.get(url, queryParameters: params, options: _options); } else { response = await _dio.post(url, data: params, options: _options); } } on DioError catch (e) { if (e.response != null) { response = e.response; } else { response = Response(statusCode: 999, statusMessage: "请求失败,稍后再试!"); } if (e.type == DioErrorType.CONNECT_TIMEOUT || e.type == DioErrorType.RECEIVE_TIMEOUT) { response.statusCode = Code.NETWOEK_TIMEROUT; response.statusMessage = "请求超时,请稍后再试!"; } response.data = BaseResult(null, response.statusCode, response.statusMessage); } return response.data; } upload(String url, Uint8List data) async { UploadFileInfo file = UploadFileInfo.fromBytes(data, 'fileName'); FormData formData = FormData.from({'file': file}); Map<String, dynamic> header = { 'token': UserUtils.getUserInfo().token ?? "" }; Response response; try { response = await _dio.put(url, data: formData, options: Options(headers: header)); } on DioError catch (e) { if (e.response != null) { response = e.response; } else { response = Response(statusCode: 999, statusMessage: "请求失败,稍后再试!"); } if (e.type == DioErrorType.CONNECT_TIMEOUT || e.type == DioErrorType.RECEIVE_TIMEOUT) { response.statusCode = Code.NETWOEK_TIMEROUT; response.statusMessage = "请求超时,请稍后再试!"; } response.data = BaseResult(null, response.statusCode, response.data.message); } return response.data; } } final HttpManager httpManager = HttpManager();
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/net/network_utils.dart
import 'dart:io'; import 'dart:async'; import 'package:it_resource_exchange_app/common/constant.dart' show APPConfig; import 'http_manager.dart'; import 'package:it_resource_exchange_app/model/base_result.dart'; import 'dart:typed_data'; class NetworkUtils { static requestHomeAdvertisementsAndRecommendProductsData() async { String url = APPConfig.Server + "/home/index"; BaseResult result = await httpManager.request(HttpMethod.GET, url, null); return result; } static Future<BaseResult> requestCategoryListData() async { String url = APPConfig.Server + "/category/list"; BaseResult result = await httpManager.request(HttpMethod.GET, url, null); return result; } static requestProductListByCateId(int cateId, int currentPage) async { String url = APPConfig.Server + "/product/pageListByCateId"; var params = {"currentPage": currentPage, "pageSize": 20}; if (cateId != null) { params["cateId"] = cateId; } BaseResult result = await httpManager.request(HttpMethod.GET, url, params); return result; } static Future<BaseResult> requestProductDetailByProductId( int productId) async { String url = APPConfig.Server + "/product/detail"; var params = {"productId": productId}; BaseResult result = await httpManager.request(HttpMethod.GET, url, params); return result; } static login(String account, String password) async { String url = APPConfig.Server + "/user/login"; var params = {"account": account, "password": password}; BaseResult result = await httpManager.request(HttpMethod.POST, url, params); return result; } static register(String account, String password, String code) async { String url = APPConfig.Server + "/user/verifyRegister"; var params = {"account": account, "password": password, "code": code}; BaseResult result = await httpManager.request(HttpMethod.POST, url, params); return result; } static logout(String userId) async { String url = APPConfig.Server + "/user/logout"; var params = {"userId": userId}; BaseResult result = await httpManager.request(HttpMethod.POST, url, params); return result; } static Future<BaseResult> uploadToken() async { String url = APPConfig.Server + "/upload/token"; BaseResult result = await httpManager.request(HttpMethod.GET, url, null); return result; } static Future<BaseResult> onUpload(Uint8List data) async { String url = APPConfig.Server + "/upload/qiniu"; BaseResult result = await httpManager.upload(url, data); return result; } static submitProduct(Map<String, dynamic> params) async { String url = APPConfig.Server + "/product/submit"; BaseResult result = await httpManager.request(HttpMethod.POST, url, params, contentType: ContentType.json); return result; } static requestMyProductListData(int userId) async { String url = APPConfig.Server + "/product/pageListByCreateUserId"; var params = {"userId": userId}; BaseResult result = await httpManager.request(HttpMethod.GET, url, params); return result; } static requestMyCollectionListData() async { String url = APPConfig.Server + "/collectProduct/list"; BaseResult result = await httpManager.request(HttpMethod.GET, url, null); return result; } static addCollectProduct(int cateId, int productId) async { String url = APPConfig.Server + "/collectProduct/add"; var params = {"cateId": cateId, "productId": productId}; BaseResult result = await httpManager.request(HttpMethod.POST, url, params); return result; } static deleteCollectProcut(int collectId) async { String url = APPConfig.Server + "/collectProduct/delete"; var params = {"collectId": collectId}; BaseResult result = await httpManager.request(HttpMethod.POST, url, params); return result; } static sendCodeForRegister(String account) async { String url = APPConfig.Server + "/user/sendCodeForRegister"; var params = {"account": account}; BaseResult result = await httpManager.request(HttpMethod.POST, url, params); return result; } static sendCodeForReset(String account) async { String url = APPConfig.Server + "/user/sendCodeForReset"; var params = {"account": account}; BaseResult result = await httpManager.request(HttpMethod.POST, url, params); return result; } static resetPassword(String account, String password, String code) async { String url = APPConfig.Server + "/user/verifyReset"; var params = {"account": account, "password": password, "code": code}; BaseResult result = await httpManager.request(HttpMethod.POST, url, params); return result; } static remarkProduct(int productId, String content, {int parentCommentId, int parentUserId}) async { String url = APPConfig.Server + "/productComment/remark"; var params = {"productId": productId, "content": content}; if (parentCommentId != null && parentUserId != null) { params.addAll({"parentCommentId": parentCommentId, "parentUserId": parentUserId}); } BaseResult result = await httpManager.request(HttpMethod.POST, url, params); return result; } static Future<BaseResult> requstProductCommentList(int productId, int startCommentId) async { String url = APPConfig.Server + "/productComment/getList"; var params = {"productId": productId, "startCommentId": startCommentId, "count": 20}; BaseResult result = await httpManager.request(HttpMethod.GET, url, params); return result; } static requestMovieListByCateId(int cateId, int currentPage) async { String url = APPConfig.Server + "/movie/pageListByCateId"; var params = {"currentPage": currentPage, "pageSize": 20}; if (cateId != null) { params["cateId"] = cateId; } BaseResult result = await httpManager.request(HttpMethod.GET, url, params); return result; } static requstMovieDetailData(int movieId) async { String url = APPConfig.Server + "/movie/detail"; var params = {"movieId": movieId}; BaseResult result = await httpManager.request(HttpMethod.GET, url, params); return result; } static searchMovieListByKeywords(String keywords, int currentPage) async { String url = APPConfig.Server + "/movie/search"; var params = {"currentPage": currentPage, "pageSize": 20, "keywords": keywords}; BaseResult result = await httpManager.request(HttpMethod.GET, url, params); return result; } }
0
mirrored_repositories/it_resource_exchange_app/lib/net
mirrored_repositories/it_resource_exchange_app/lib/net/interceptors/response_Interceptor.dart
import 'package:dio/dio.dart'; import 'package:it_resource_exchange_app/model/base_result.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show APPConfig; class ResponseInterceptor extends InterceptorsWrapper { @override onResponse(Response response) { // RequestOptions options = response.request; try { if (response.statusCode == 200 || response.statusCode == 201) { //http code BaseResult result = BaseResult.fromJson(response.data); return result; }else { if (APPConfig.DEBUG) { print("ResponseInterceptor: $response.statusCode"); } } } catch(e) { if (APPConfig.DEBUG) { print("ResponseInterceptor: $e.toString() + options.path"); } return BaseResult(response.data, response.statusCode, e.toString()); } } }
0
mirrored_repositories/it_resource_exchange_app/lib/net
mirrored_repositories/it_resource_exchange_app/lib/net/interceptors/error_interceptor.dart
import 'package:dio/dio.dart'; import 'package:connectivity/connectivity.dart'; import 'package:it_resource_exchange_app/model/base_result.dart'; import '../code.dart'; class ErrorInterceptor extends InterceptorsWrapper { final Dio _dio; ErrorInterceptor(this._dio); @override onRequest(RequestOptions options) async { var connectivityResult = await (Connectivity().checkConnectivity()); if (connectivityResult == ConnectivityResult.none) { return _dio.resolve(BaseResult(null, Code.NETWORK_ERROR, "网络错误")); } return super.onRequest(options); } }
0
mirrored_repositories/it_resource_exchange_app/lib/net
mirrored_repositories/it_resource_exchange_app/lib/net/interceptors/logs_interceptor.dart
import 'package:dio/dio.dart'; import 'package:it_resource_exchange_app/common/constant.dart' show APPConfig; class LogsInterceptor extends InterceptorsWrapper { @override onRequest(RequestOptions options) { if (APPConfig.DEBUG) { print("请求url:${options.path}"); print('请求头: ' + options.headers.toString()); if (options.data != null) { print('请求参数: ' + options.data.toString()); } } return options; } @override onResponse(Response response) { if (APPConfig.DEBUG) { if (response != null) { print('返回参数: ' + response.toString()); } } return response; // continue } @override onError(DioError err) { if (APPConfig.DEBUG) { print('请求异常: ' + err.toString()); print('请求异常信息: ' + err.response?.toString() ?? ""); } return err; } }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/utils/local_storage_utils.dart
import 'package:shared_preferences/shared_preferences.dart'; import 'package:synchronized/synchronized.dart'; import 'dart:convert'; import 'dart:async'; ///SharedPreferences 本地存储 class LocalStorage { static LocalStorage _singleton; static SharedPreferences _prefs; static Lock _lock = Lock(); static Future<LocalStorage> getInstance() async { if (_singleton == null) { await _lock.synchronized(() async { if (_singleton == null) { // keep local instance till it is fully initialized. // 保持本地实例直到完全初始化。 var singleton = LocalStorage._(); await singleton._init(); _singleton = singleton; } }); } return _singleton; } LocalStorage._(); Future _init() async { _prefs = await SharedPreferences.getInstance(); } /// put object. static Future<bool> putObject(String key, Object value) { if (_prefs == null) return null; return _prefs.setString(key, value == null ? "" : json.encode(value)); } /// get obj. static T getObj<T>(String key, T f(Map v), {T defValue}) { Map map = getObject(key); return map == null ? defValue : f(map); } /// get object. static Map getObject(String key) { if (_prefs == null) return null; String _data = _prefs.getString(key); return (_data == null || _data.isEmpty) ? null : json.decode(_data); } /// put object list. static Future<bool> putObjectList(String key, List<Object> list) { if (_prefs == null) return null; List<String> _dataList = list?.map((value) { return json.encode(value); })?.toList(); return _prefs.setStringList(key, _dataList); } /// get obj list. static List<T> getObjList<T>(String key, T f(Map v), {List<T> defValue = const []}) { List<Map> dataList = getObjectList(key); List<T> list = dataList?.map((value) { return f(value); })?.toList(); return list ?? defValue; } /// get object list. static List<Map> getObjectList(String key) { if (_prefs == null) return null; List<String> dataLis = _prefs.getStringList(key); return dataLis?.map((value) { Map _dataMap = json.decode(value); return _dataMap; })?.toList(); } /// get string. static String getString(String key, {String defValue = ''}) { if (_prefs == null) return defValue; return _prefs.getString(key) ?? defValue; } /// put string. static Future<bool> putString(String key, String value) { if (_prefs == null) return null; return _prefs.setString(key, value); } /// get bool. static bool getBool(String key, {bool defValue = false}) { if (_prefs == null) return defValue; return _prefs.getBool(key) ?? defValue; } /// put bool. static Future<bool> putBool(String key, bool value) { if (_prefs == null) return null; return _prefs.setBool(key, value); } /// get int. static int getInt(String key, {int defValue = 0}) { if (_prefs == null) return defValue; return _prefs.getInt(key) ?? defValue; } /// put int. static Future<bool> putInt(String key, int value) { if (_prefs == null) return null; return _prefs.setInt(key, value); } /// get double. static double getDouble(String key, {double defValue = 0.0}) { if (_prefs == null) return defValue; return _prefs.getDouble(key) ?? defValue; } /// put double. static Future<bool> putDouble(String key, double value) { if (_prefs == null) return null; return _prefs.setDouble(key, value); } /// get string list. static List<String> getStringList(String key, {List<String> defValue = const []}) { if (_prefs == null) return defValue; return _prefs.getStringList(key) ?? defValue; } /// put string list. static Future<bool> putStringList(String key, List<String> value) { if (_prefs == null) return null; return _prefs.setStringList(key, value); } /// get dynamic. static dynamic getDynamic(String key, {Object defValue}) { if (_prefs == null) return defValue; return _prefs.get(key) ?? defValue; } /// have key. static bool haveKey(String key) { if (_prefs == null) return null; return _prefs.getKeys().contains(key); } /// get keys. static Set<String> getKeys() { if (_prefs == null) return null; return _prefs.getKeys(); } /// remove. static Future<bool> remove(String key) { if (_prefs == null) return null; return _prefs.remove(key); } /// clear. static Future<bool> clear() { if (_prefs == null) return null; return _prefs.clear(); } ///Sp is initialized. static bool isInitialized() { return _prefs != null; } }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/utils/regex_utils.dart
class RegexUtils { /// Regex of email. static final String regexEmail = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$"; /// Regex of url. static final String regexUrl = "[a-zA-z]+://[^\\s]*"; /// Regex of Chinese character. static final String regexZh = "[\\u4e00-\\u9fa5]"; /// Return whether input matches regex of email. static bool isEmail(String input) { return matches(regexEmail, input); } /// Return whether input matches regex of url. static bool isURL(String input) { return matches(regexUrl, input); } /// Return whether input matches regex of Chinese character. static bool isZh(String input) { return '〇' == input || matches(regexZh, input); } static bool matches(String regex, String input) { if (input == null || input.isEmpty) return false; return new RegExp(regex).hasMatch(input); } }
0
mirrored_repositories/it_resource_exchange_app/lib
mirrored_repositories/it_resource_exchange_app/lib/utils/user_utils.dart
import 'package:it_resource_exchange_app/utils/local_storage_utils.dart'; import './local_storage_utils.dart'; import '../model/user_info.dart'; class UserUtils { static const USER_INFO_KEY = "USER_INFO_KEY"; static const USER_NAME_KEY = "USER_NAME_KEY"; static saveUserInfo(UserInfo userInfo) { if (userInfo != null) { LocalStorage.putObject(USER_INFO_KEY, userInfo.toJson()); } } static saveUserName(String username) { if (username != null) { LocalStorage.putString(USER_NAME_KEY, username); } } static removeUserInfo() { LocalStorage.remove(USER_INFO_KEY); } static UserInfo getUserInfo() { Map userJson = LocalStorage.getObject(USER_INFO_KEY); return userJson == null ? null : UserInfo.fromJson(userJson); } static String getUserName() { return LocalStorage.getString(USER_NAME_KEY); } static bool isLogin() { var res = getUserInfo() == null ? false : true; return res; } }
0
mirrored_repositories/it_resource_exchange_app
mirrored_repositories/it_resource_exchange_app/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:it_resource_exchange_app/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/tsa_eventq
mirrored_repositories/tsa_eventq/lib/firebase_options.dart
// File generated by FlutterFire CLI. // ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; /// Default [FirebaseOptions] for use with your Firebase apps. /// /// Example: /// ```dart /// import 'firebase_options.dart'; /// // ... /// await Firebase.initializeApp( /// options: DefaultFirebaseOptions.currentPlatform, /// ); /// ``` class DefaultFirebaseOptions { static FirebaseOptions get currentPlatform { if (kIsWeb) { return web; } switch (defaultTargetPlatform) { case TargetPlatform.android: return android; case TargetPlatform.iOS: return ios; case TargetPlatform.macOS: return macos; case TargetPlatform.windows: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for windows - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.linux: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for linux - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); default: throw UnsupportedError( 'DefaultFirebaseOptions are not supported for this platform.', ); } } static const FirebaseOptions web = FirebaseOptions( apiKey: 'AIzaSyABCgHDlK1pyjaFIlZG6yr97c_cAN6VJ58', appId: '1:911994996001:web:15052c11b25d8b96502a60', messagingSenderId: '911994996001', projectId: 'hotelq-app', authDomain: 'hotelq-app.firebaseapp.com', storageBucket: 'hotelq-app.appspot.com', ); static const FirebaseOptions android = FirebaseOptions( apiKey: 'AIzaSyBIKKALXEDMTm9DsoEAtJ1aJThQB9KErRM', appId: '1:911994996001:android:4d226ecb0cd18e41502a60', messagingSenderId: '911994996001', projectId: 'hotelq-app', storageBucket: 'hotelq-app.appspot.com', ); static const FirebaseOptions ios = FirebaseOptions( apiKey: 'AIzaSyDXx08e9xTNO_1eIwQY2bKtaW_3td1f25M', appId: '1:911994996001:ios:ddbffc33fabd0cf5502a60', messagingSenderId: '911994996001', projectId: 'hotelq-app', storageBucket: 'hotelq-app.appspot.com', iosClientId: '911994996001-5dubo7uk49mhfcejqh8438rd03m7dk9g.apps.googleusercontent.com', iosBundleId: 'com.example.tsaEventq', ); static const FirebaseOptions macos = FirebaseOptions( apiKey: 'AIzaSyDXx08e9xTNO_1eIwQY2bKtaW_3td1f25M', appId: '1:911994996001:ios:ddbffc33fabd0cf5502a60', messagingSenderId: '911994996001', projectId: 'hotelq-app', storageBucket: 'hotelq-app.appspot.com', iosClientId: '911994996001-5dubo7uk49mhfcejqh8438rd03m7dk9g.apps.googleusercontent.com', iosBundleId: 'com.example.tsaEventq', ); }
0
mirrored_repositories/tsa_eventq
mirrored_repositories/tsa_eventq/lib/main.dart
import '../config/app_color.dart'; import '../config/app_route.dart'; import '../config/session.dart'; import '../page/checkout_page.dart'; import '../page/checkout_success_page.dart'; import '../page/detail_booking_page.dart'; import '../page/detail_page.dart'; import '../page/intro_page.dart'; import '../page/signin_page.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:intl/date_symbol_data_local.dart'; import 'firebase_options.dart'; import '../model/user.dart'; import '../page/home_page.dart'; import '../page/user_page.dart'; import '../page/signup_page.dart'; Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); initializeDateFormatting('en_US'); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return GetMaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( textTheme: GoogleFonts.poppinsTextTheme(), scaffoldBackgroundColor: AppColor.backgroundScaffold, primaryColor: AppColor.primary, colorScheme: const ColorScheme.light( primary: AppColor.primary, secondary: AppColor.secondary, ), ), routes: { '/': (context) { return FutureBuilder( future: Session.getUser(), builder: (context, AsyncSnapshot<User> snapshot) { if (snapshot.data == null || snapshot.data!.id == null) { return const IntroPage(); } else { return HomePage(); } }, ); }, AppRoute.intro: (context) => const IntroPage(), AppRoute.home: (context) => HomePage(), AppRoute.signin: (context) => SigninPage(), AppRoute.signup: (context) => SignupPage(), AppRoute.detail: (context) => DetailPage(), AppRoute.checkout: (context) => CheckoutPage(), AppRoute.checkoutSuccess: (context) => const CheckoutSuccessPage(), AppRoute.detailBooking: (context) => DetailBookingPage(), AppRoute.user: (context) => const UserPage(), }, ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/page/detail_page.dart
import '../config/app_asset.dart'; import '../config/app_format.dart'; import '../config/app_route.dart'; import '../source/booking_source.dart'; import '../widget/button_custom.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../config/app_color.dart'; import '../controller/c_user.dart'; import '../model/booking.dart'; import '../model/hotel.dart'; class DetailPage extends StatelessWidget { DetailPage({Key? key}) : super(key: key); final cUser = Get.put(CUser()); final Rx<Booking> _bookedData = initBooking.obs; Booking get bookedData => _bookedData.value; set bookedData(Booking n) => _bookedData.value = n; final List facilities = [ { 'icon': AppAsset.iconCoffee, 'label': 'Lounge', }, { 'icon': AppAsset.iconOffice, 'label': 'Office', }, { 'icon': AppAsset.iconWifi, 'label': 'Wi-Fi', }, { 'icon': AppAsset.iconStore, 'label': 'Store', }, ]; @override Widget build(BuildContext context) { Hotel hotel = ModalRoute.of(context)!.settings.arguments as Hotel; BookingSource.checkIsBooked(cUser.data.id!, hotel.id).then((bookingValue) { bookedData = bookingValue ?? initBooking; }); return Scaffold( appBar: AppBar( elevation: 0, backgroundColor: Colors.transparent, foregroundColor: Colors.black, title: const Text( 'Event Details', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, ), ), centerTitle: true, ), // bottomNavigationBar: bookingNow(hotel, context), bottomNavigationBar: Obx(() { if (bookedData.id == '') return bookingNow(hotel, context); return viewReceipt(context); }), body: Container( decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(24), topRight: Radius.circular(24), ), ), child: ListView( children: [ const SizedBox(height: 24), images(hotel), const SizedBox(height: 16), name(hotel, context), const SizedBox(height: 16), Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Text(hotel.description), ), // const SizedBox(height: 16), // Padding( // padding: const EdgeInsets.symmetric(horizontal: 16), // child: Text( // 'Facilities', // style: Theme.of(context).textTheme.titleMedium!.copyWith( // fontWeight: FontWeight.bold, // ), // ), // ), // gridFacilities(), // const SizedBox(height: 16), // Padding( // padding: const EdgeInsets.symmetric(horizontal: 16), // child: Text( // 'Activities', // style: Theme.of(context).textTheme.titleMedium!.copyWith( // fontWeight: FontWeight.bold, // ), // ), // ), // const SizedBox(height: 16), // activities(hotel), const SizedBox(height: 20), ], ), ), ); } Container viewReceipt(BuildContext context) { return Container( decoration: BoxDecoration( color: Colors.white, border: Border( top: BorderSide(color: Colors.grey[100]!, width: 1.5), ), ), height: 80, padding: const EdgeInsets.fromLTRB(16, 12, 16, 8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Text( 'You booked this.', style: TextStyle(color: Colors.grey), ), Material( color: AppColor.secondary, borderRadius: BorderRadius.circular(20), child: InkWell( borderRadius: BorderRadius.circular(20), onTap: () { Navigator.pushNamed( context, AppRoute.detailBooking, arguments: bookedData, ); }, child: const Padding( padding: EdgeInsets.symmetric( horizontal: 36, vertical: 14, ), child: Text( 'View Receipt', textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontSize: 16, fontWeight: FontWeight.w900, ), ), ), ), ), ], ), ); } Container bookingNow(Hotel hotel, BuildContext context) { return Container( decoration: BoxDecoration( color: Colors.white, border: Border( top: BorderSide(color: Colors.grey[100]!, width: 1.5), ), ), height: 80, padding: const EdgeInsets.fromLTRB(16, 12, 16, 8), child: Row( children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( AppFormat.currency(hotel.price.toDouble()), style: Theme.of(context).textTheme.titleLarge!.copyWith( color: AppColor.secondary, fontWeight: FontWeight.w900, ), ), const Text( 'per ticket', style: TextStyle(color: Colors.grey), ), ], ), ), ButtonCustom( label: 'Booking Now', onTap: () { Navigator.pushNamed(context, AppRoute.checkout, arguments: hotel); }, ), ], ), ); } SizedBox activities(Hotel hotel) { return SizedBox( height: 105, child: ListView.builder( itemCount: hotel.activities.length, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { Map activity = hotel.activities[index]; return Padding( padding: EdgeInsets.fromLTRB( index == 0 ? 16 : 8, 0, index == hotel.activities.length - 1 ? 16 : 8, 0, ), child: Column( children: [ Expanded( child: ClipRRect( borderRadius: BorderRadius.circular(20), child: Image.network( activity['image'], width: 100, fit: BoxFit.cover, ), ), ), const SizedBox(height: 6), Text(activity['name']), ], ), ); }, ), ); } GridView gridFacilities() { return GridView.builder( padding: const EdgeInsets.fromLTRB(16, 8, 16, 0), itemCount: facilities.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 4, crossAxisSpacing: 16, mainAxisSpacing: 16, ), itemBuilder: (context, index) { return Container( decoration: BoxDecoration( border: Border.all(color: Colors.grey[200]!), borderRadius: BorderRadius.circular(24), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ ImageIcon(AssetImage(facilities[index]['icon'])), const SizedBox(height: 4), Text( facilities[index]['label'], style: const TextStyle(fontSize: 13), ), ], ), ); }, ); } Padding name(Hotel hotel, BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Row( children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( hotel.name, style: Theme.of(context).textTheme.titleLarge!.copyWith( fontWeight: FontWeight.bold, ), ), Text( hotel.location, style: const TextStyle( color: Colors.grey, fontWeight: FontWeight.w300, ), ), ], ), ), const Icon(Icons.star, color: AppColor.starActive), const SizedBox(width: 4), Text( hotel.rate.toString(), style: const TextStyle( fontSize: 16, color: Colors.black, fontWeight: FontWeight.bold, ), ), ], ), ); } SizedBox images(Hotel hotel) { return SizedBox( height: 180, child: ListView.builder( itemCount: hotel.images.length, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { return Padding( padding: EdgeInsets.fromLTRB( index == 0 ? 16 : 8, 0, index == hotel.images.length - 1 ? 16 : 8, 0, ), child: ClipRRect( borderRadius: BorderRadius.circular(20), child: Image.network( hotel.images[index], fit: BoxFit.cover, height: 180, width: 240, ), ), ); }, ), ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/page/home_page.dart
import '../page/user_page.dart'; import '../page/history_page.dart'; import '../page/nearby_page.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../config/app_asset.dart'; import '../config/app_color.dart'; import '../controller/c_home.dart'; class HomePage extends StatelessWidget { HomePage({Key? key}) : super(key: key); final cHome = Get.put(CHome()); final List<Map> listNav = [ {'icon': AppAsset.iconNearby, 'label': 'Nearby'}, {'icon': AppAsset.iconHistory, 'label': 'History'}, // {'icon': AppAsset.iconPayment, 'label': 'Payment'}, // {'icon': AppAsset.iconReward, 'label': 'Reward'}, {'icon': AppAsset.iconUser, 'label': 'User'}, ]; @override Widget build(BuildContext context) { return Scaffold( body: Obx(() { // if (cHome.indexPage == 1) { // return const HistoryPage(); // } // return NearbyPage(); if (cHome.indexPage == 0) { return NearbyPage(); } else if (cHome.indexPage == 1) { return HistoryPage(); } else { return UserPage(); } }), bottomNavigationBar: Obx(() { return Material( elevation: 8, child: Container( color: Colors.white, padding: const EdgeInsets.only(top: 8, bottom: 6), child: BottomNavigationBar( currentIndex: cHome.indexPage, onTap: (value) => cHome.indexPage = value, elevation: 0, backgroundColor: Colors.transparent, type: BottomNavigationBarType.fixed, unselectedItemColor: Colors.grey, selectedItemColor: Colors.black, selectedIconTheme: const IconThemeData( color: AppColor.primary, ), selectedLabelStyle: const TextStyle( fontWeight: FontWeight.bold, ), selectedFontSize: 12, items: listNav.map((e) { return BottomNavigationBarItem( icon: ImageIcon(AssetImage(e['icon'])), label: e['label'], ); }).toList(), ), ), ); }), ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/page/history_page.dart
import '../model/booking.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:grouped_list/grouped_list.dart'; import 'package:intl/intl.dart'; import '../config/app_asset.dart'; import '../config/app_color.dart'; import '../config/app_format.dart'; import '../config/app_route.dart'; import '../controller/c_history.dart'; import '../controller/c_user.dart'; class HistoryPage extends StatefulWidget { const HistoryPage({Key? key}) : super(key: key); @override State<HistoryPage> createState() => _HistoryPageState(); } class _HistoryPageState extends State<HistoryPage> { final cHistory = Get.put(CHistory()); final cUser = Get.put(CUser()); @override void initState() { cHistory.getListBooking(cUser.data.id!); super.initState(); } @override Widget build(BuildContext context) { return ListView( children: [ const SizedBox(height: 24), header(context), const SizedBox(height: 24), GetBuilder<CHistory>(builder: (_) { return GroupedListView<Booking, String>( padding: const EdgeInsets.fromLTRB(16, 0, 16, 16), physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, elements: _.listBooking, groupBy: (element) => element.date, groupSeparatorBuilder: (String groupByValue) { String date = DateFormat('yyyy-MM-dd').format(DateTime.now()) == groupByValue ? 'Today New' : AppFormat.dateMonth(groupByValue); return Padding( padding: const EdgeInsets.only(top: 10, bottom: 10), child: Text( date, style: Theme.of(context).textTheme.titleMedium!.copyWith( fontWeight: FontWeight.bold, ), ), ); }, itemBuilder: (context, element) { return Padding( padding: const EdgeInsets.only(bottom: 16), child: GestureDetector( onTap: () { Navigator.pushNamed( context, AppRoute.detailBooking, arguments: element, ); }, child: item(context, element), ), ); }, itemComparator: (item1, item2) => item1.date.compareTo(item2.date), order: GroupedListOrder.DESC, ); }), ], ); } Widget item(BuildContext context, Booking booking) { return Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), ), padding: const EdgeInsets.all(16), child: Row( children: [ ClipRRect( borderRadius: BorderRadius.circular(12), child: Image.network( booking.cover, fit: BoxFit.cover, height: 70, width: 90, ), ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( booking.name, style: Theme.of(context).textTheme.titleMedium!.copyWith( fontWeight: FontWeight.bold, ), ), Text( AppFormat.date(booking.date), style: const TextStyle( color: Colors.grey, fontWeight: FontWeight.w300, ), ), ], ), ), const SizedBox(width: 16), Container( decoration: BoxDecoration( color: booking.status == 'PAID' ? AppColor.secondary : Colors.red, borderRadius: BorderRadius.circular(30), ), padding: const EdgeInsets.symmetric( horizontal: 10, vertical: 2, ), child: Text( booking.status, style: const TextStyle(color: Colors.white, fontSize: 12), ), ), ], ), ); } Padding header(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ ClipRRect( borderRadius: BorderRadius.circular(50), child: Image.asset( AppAsset.profile, width: 50, height: 50, fit: BoxFit.cover, ), ), Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( 'My Booking', style: Theme.of(context).textTheme.titleLarge!.copyWith( fontWeight: FontWeight.w900, ), ), Obx(() { return Text( '${cHistory.listBooking.length} transactions', style: const TextStyle(color: Colors.grey, fontSize: 12), ); }), ], ), ], ), ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/page/signup_page.dart
import '../config/app_route.dart'; import '../source/user_source.dart'; import 'package:d_info/d_info.dart'; import 'package:flutter/material.dart'; import '../config/app_asset.dart'; import '../config/app_color.dart'; import '../widget/button_custom.dart'; class SignupPage extends StatelessWidget { SignupPage({Key? key}) : super(key: key); final controllerEmail = TextEditingController(); final controllerPassword = TextEditingController(); final formKey = GlobalKey<FormState>(); register(BuildContext context) { if (formKey.currentState!.validate()) { UserSource.signUp(controllerEmail.text, controllerPassword.text) .then((response) { if (response['success']) { DInfo.dialogSuccess(response['message']); DInfo.closeDialog(actionAfterClose: () { Navigator.pushReplacementNamed(context, AppRoute.home); }); } else { DInfo.toastError(response['message']); } }); } } @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: LayoutBuilder(builder: (context, constraints) { return SingleChildScrollView( child: ConstrainedBox( constraints: BoxConstraints( minHeight: constraints.maxHeight, ), child: Form( key: formKey, child: Padding( padding: const EdgeInsets.all(16), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( AppAsset.logo, width: 180, fit: BoxFit.fitWidth, ), const SizedBox(height: 80), Align( alignment: Alignment.centerLeft, child: Text( 'Sign Up To\nCreate Account', style: Theme.of(context).textTheme.titleLarge!.copyWith( fontWeight: FontWeight.bold, ), ), ), const SizedBox(height: 20), TextFormField( controller: controllerEmail, validator: (value) => value == '' ? "Don't empty" : null, decoration: InputDecoration( isDense: true, filled: true, fillColor: Colors.white, contentPadding: const EdgeInsets.symmetric( horizontal: 16, vertical: 16), hintText: 'Email Address', border: OutlineInputBorder( borderRadius: BorderRadius.circular(30), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(30), borderSide: const BorderSide(color: AppColor.secondary), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(30), borderSide: BorderSide.none, ), ), ), const SizedBox(height: 20), TextFormField( controller: controllerPassword, obscureText: true, validator: (value) => value == '' ? "Don't empty" : null, decoration: InputDecoration( isDense: true, filled: true, fillColor: Colors.white, contentPadding: const EdgeInsets.symmetric( horizontal: 16, vertical: 16), hintText: 'Password', border: OutlineInputBorder( borderRadius: BorderRadius.circular(30), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(30), borderSide: const BorderSide(color: AppColor.secondary), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(30), borderSide: BorderSide.none, ), ), ), const SizedBox(height: 30), ButtonCustom( label: 'Sign Up', isExpand: true, onTap: () => register(context), ), const SizedBox(height: 24), InkWell( onTap: (() { Navigator.pushNamed(context, AppRoute.signin); }), child: const Text( 'I have an account', style: TextStyle(color: Colors.grey), ), ), ], ), ), ), ), ); }), ), ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/page/user_page.dart
import 'package:flutter/material.dart'; import '../config/app_asset.dart'; import '../config/app_route.dart'; import '../config/session.dart'; class UserPage extends StatelessWidget { const UserPage({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( elevation: 0, backgroundColor: Colors.transparent, foregroundColor: Colors.black, title: Text( 'User Detail', style: Theme.of(context).textTheme.titleLarge!.copyWith( fontWeight: FontWeight.w900, ), ), centerTitle: true, ), body: Container( padding: const EdgeInsets.all(16), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Container( child: Column( children: const [ CircleAvatar( radius: 50, backgroundImage: AssetImage(AppAsset.profile), ), SizedBox( height: 10, ), Text( 'Ferdy Febriyanto', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, ), ), SizedBox( height: 10, ), ], ), ), const SizedBox( height: 50, ), GestureDetector( onTap: () { Session.clearUser(); Navigator.pushReplacementNamed(context, AppRoute.signin); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.red, boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.5), spreadRadius: 1, blurRadius: 7, offset: const Offset(0, 3), // changes position of shadow ), ], ), width: double.infinity, height: 50, child: const Center( child: Text( 'Logout', style: TextStyle( color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold, ), ), ), ), ), ], ), ), ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/page/intro_page.dart
import '../config/app_asset.dart'; import '../config/app_route.dart'; import '../widget/button_custom.dart'; import 'package:flutter/material.dart'; import '../config/app_color.dart'; class IntroPage extends StatelessWidget { const IntroPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( body: Stack( fit: StackFit.expand, children: [ Image.asset( AppAsset.bgIntro, fit: BoxFit.cover, ), Container( height: MediaQuery.of(context).size.height * 0.4, decoration: const BoxDecoration( gradient: LinearGradient( begin: Alignment.bottomCenter, end: Alignment.topCenter, colors: [ Colors.black, Colors.transparent, ], ), ), ), Padding( padding: const EdgeInsets.fromLTRB(16, 0, 16, 40), child: Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Your Great Event\nStarts Here', style: Theme.of(context).textTheme.headline4!.copyWith( color: Colors.white, fontWeight: FontWeight.w900, ), ), const SizedBox(height: 8), Text( 'More than just a event', style: Theme.of(context).textTheme.titleMedium!.copyWith( color: Colors.white, fontWeight: FontWeight.w300, ), ), const SizedBox(height: 30), ButtonCustom( label: 'Get Started', onTap: () { Navigator.pushReplacementNamed(context, AppRoute.signin); }, isExpand: true, ), ], ), ), ], ), ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/page/checkout_success_page.dart
import '../page/home_page.dart'; import '../widget/button_custom.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../controller/c_home.dart'; import '../model/hotel.dart'; class CheckoutSuccessPage extends StatelessWidget { const CheckoutSuccessPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final cHome = Get.put(CHome()); Hotel hotel = ModalRoute.of(context)!.settings.arguments as Hotel; return Scaffold( body: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( decoration: BoxDecoration( border: Border.all(width: 6, color: Colors.white), borderRadius: BorderRadius.circular(20), color: Colors.white, ), child: ClipRRect( borderRadius: BorderRadius.circular(20), child: Image.network( hotel.cover, width: 190, height: 190, fit: BoxFit.cover, ), ), ), const SizedBox(height: 46), Text( 'Payment Success', style: Theme.of(context).textTheme.headline5!.copyWith( color: Colors.black, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 12), Text( 'Enjoy your a whole new experience\nin this beautiful world', textAlign: TextAlign.center, style: Theme.of(context).textTheme.titleMedium!.copyWith( color: Colors.black, ), ), const SizedBox(height: 46), ButtonCustom( label: 'View My Booking', onTap: () { cHome.indexPage = 1; Get.offAll(() => HomePage()); }, ), ], ), ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/page/signin_page.dart
import '../config/app_route.dart'; import '../source/user_source.dart'; import 'package:d_info/d_info.dart'; import 'package:flutter/material.dart'; import '../config/app_asset.dart'; import '../config/app_color.dart'; import '../widget/button_custom.dart'; class SigninPage extends StatelessWidget { SigninPage({Key? key}) : super(key: key); final controllerEmail = TextEditingController(); final controllerPassword = TextEditingController(); final formKey = GlobalKey<FormState>(); login(BuildContext context) { if (formKey.currentState!.validate()) { UserSource.signIn(controllerEmail.text, controllerPassword.text) .then((response) { if (response['success']) { DInfo.dialogSuccess(response['message']); DInfo.closeDialog(actionAfterClose: () { Navigator.pushReplacementNamed(context, AppRoute.home); }); } else { DInfo.toastError(response['message']); } }); } } @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: LayoutBuilder(builder: (context, constraints) { return SingleChildScrollView( child: ConstrainedBox( constraints: BoxConstraints( minHeight: constraints.maxHeight, ), child: Form( key: formKey, child: Padding( padding: const EdgeInsets.all(16), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( AppAsset.logo, width: 180, fit: BoxFit.fitWidth, ), const SizedBox(height: 80), Align( alignment: Alignment.centerLeft, child: Text( 'Sign In\nTo Your Account', style: Theme.of(context).textTheme.titleLarge!.copyWith( fontWeight: FontWeight.bold, ), ), ), const SizedBox(height: 20), TextFormField( controller: controllerEmail, validator: (value) => value == '' ? "Don't empty" : null, decoration: InputDecoration( isDense: true, filled: true, fillColor: Colors.white, contentPadding: const EdgeInsets.symmetric( horizontal: 16, vertical: 16), hintText: 'Email Address', border: OutlineInputBorder( borderRadius: BorderRadius.circular(30), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(30), borderSide: const BorderSide(color: AppColor.secondary), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(30), borderSide: BorderSide.none, ), ), ), const SizedBox(height: 20), TextFormField( controller: controllerPassword, obscureText: true, validator: (value) => value == '' ? "Don't empty" : null, decoration: InputDecoration( isDense: true, filled: true, fillColor: Colors.white, contentPadding: const EdgeInsets.symmetric( horizontal: 16, vertical: 16), hintText: 'Password', border: OutlineInputBorder( borderRadius: BorderRadius.circular(30), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(30), borderSide: const BorderSide(color: AppColor.secondary), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(30), borderSide: BorderSide.none, ), ), ), const SizedBox(height: 30), ButtonCustom( label: 'Sign In', isExpand: true, onTap: () => login(context), ), const SizedBox(height: 24), InkWell( onTap: () => Navigator.pushReplacementNamed( context, AppRoute.signup), child: const Text( 'Create new Account', style: TextStyle(color: Colors.grey), ), ), ], ), ), ), ), ); }), ), ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/page/checkout_page.dart
import '../config/app_format.dart'; import '../model/booking.dart'; import '../source/booking_source.dart'; import '../widget/button_custom.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; import '../config/app_asset.dart'; import '../config/app_color.dart'; import '../config/app_route.dart'; import '../controller/c_user.dart'; import '../model/hotel.dart'; class CheckoutPage extends StatelessWidget { CheckoutPage({Key? key}) : super(key: key); final cUser = Get.put(CUser()); @override Widget build(BuildContext context) { Hotel hotel = ModalRoute.of(context)!.settings.arguments as Hotel; return Scaffold( appBar: AppBar( elevation: 0, backgroundColor: Colors.transparent, foregroundColor: Colors.black, title: const Text( 'Checkout', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, ), ), centerTitle: true, ), body: ListView( padding: const EdgeInsets.all(16), children: [ header(hotel, context), const SizedBox(height: 16), roomDetails(hotel, context), const SizedBox(height: 16), paymentMethod(context), const SizedBox(height: 20), ButtonCustom( label: 'Procced to Payment', isExpand: true, onTap: () { BookingSource.addBooking( cUser.data.id!, Booking( id: '', idHotel: hotel.id, cover: hotel.cover, name: hotel.name, location: hotel.location, date: DateFormat('yyyy-MM-dd').format(DateTime.now()), guest: 1, // breakfast: 'Included', checkInTime: DateFormat('HH:mm').format(DateTime.now()), // night: 2, // serviceFee: 6, // activities: 40, // totalPayment: hotel.price + 2 + 6 + 40, totalPayment: hotel.price, status: 'PAID', isDone: false, ), ); Navigator.pushNamed( context, AppRoute.checkoutSuccess, arguments: hotel, ); }, ), ], ), ); } Container paymentMethod(BuildContext context) { return Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Payment Method', style: Theme.of(context).textTheme.titleMedium!.copyWith( fontWeight: FontWeight.bold, ), ), const SizedBox(height: 8), Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), border: Border.all(color: Colors.grey[300]!), ), padding: const EdgeInsets.all(16), child: Row( children: [ Image.asset( AppAsset.iconBBCA, width: 50, ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Bank BCA', style: Theme.of(context).textTheme.titleSmall!.copyWith( fontWeight: FontWeight.bold, ), ), Text( 'Balance ${AppFormat.currency(80000)}', style: const TextStyle( color: Colors.grey, fontWeight: FontWeight.w300, ), ), ], ), ), const Icon(Icons.check_circle, color: AppColor.secondary), ], ), ), ], ), ); } Container roomDetails(Hotel hotel, BuildContext context) { return Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Event Details', style: Theme.of(context).textTheme.titleMedium!.copyWith( fontWeight: FontWeight.bold, ), ), const SizedBox(height: 16), itemRoomDetail( context, 'Date', AppFormat.date(DateTime.now().toIso8601String()), ), const SizedBox(height: 8), itemRoomDetail(context, 'Guest', '1 Guest'), // const SizedBox(height: 8), // itemRoomDetail(context, 'Breakfast', 'Included'), const SizedBox(height: 8), itemRoomDetail( context, 'Check In Time', DateFormat('HH:mm').format(DateTime.now()), ), // const SizedBox(height: 8), // itemRoomDetail(context, '1 night', AppFormat.currency(12900)), // const SizedBox(height: 8), // itemRoomDetail(context, 'Service fee', AppFormat.currency(50)), // const SizedBox(height: 8), // itemRoomDetail(context, 'Activities', AppFormat.currency(350)), const SizedBox(height: 8), itemRoomDetail( context, 'Total Payment', AppFormat.currency(hotel.price.toDouble()), ), const SizedBox(height: 8), ], ), ); } Row itemRoomDetail(BuildContext context, String title, String data) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( title, style: Theme.of(context).textTheme.titleMedium, ), Text( data, style: Theme.of(context).textTheme.titleMedium!.copyWith( fontWeight: FontWeight.bold, ), ), ], ); } Container header(Hotel hotel, BuildContext context) { return Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), ), padding: const EdgeInsets.all(16), child: Row( children: [ ClipRRect( borderRadius: BorderRadius.circular(12), child: Image.network( hotel.cover, fit: BoxFit.cover, height: 70, width: 90, ), ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( hotel.name, style: Theme.of(context).textTheme.titleMedium!.copyWith( fontWeight: FontWeight.bold, ), ), Text( hotel.location, style: const TextStyle( color: Colors.grey, fontWeight: FontWeight.w300, ), ), ], ), ), ], ), ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/page/detail_booking_page.dart
import '../config/app_format.dart'; import '../model/booking.dart'; import '../source/booking_source.dart'; import '../widget/button_custom.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; import '../config/app_asset.dart'; import '../config/app_color.dart'; import '../config/app_route.dart'; import '../controller/c_user.dart'; import '../model/hotel.dart'; class DetailBookingPage extends StatelessWidget { DetailBookingPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { Booking booking = ModalRoute.of(context)!.settings.arguments as Booking; return Scaffold( appBar: AppBar( elevation: 0, backgroundColor: Colors.transparent, foregroundColor: Colors.black, title: const Text( 'Detail Booking', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, ), ), centerTitle: true, ), body: ListView( padding: const EdgeInsets.all(16), children: [ header(booking, context), const SizedBox(height: 16), roomDetails(booking, context), const SizedBox(height: 16), paymentMethod(context), const SizedBox(height: 16), myTicket(context), ], ), ); } Container myTicket(BuildContext context) { return Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'My Ticket', style: Theme.of(context).textTheme.titleMedium!.copyWith( fontWeight: FontWeight.bold, ), ), const SizedBox(height: 8), Container( child: Image.network( // booking.hotel!.image!, 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/QR_code_for_mobile_English_Wikipedia.svg/1200px-QR_code_for_mobile_English_Wikipedia.svg.png', fit: BoxFit.cover, ), ), ], ), ); } Container paymentMethod(BuildContext context) { return Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Payment Method', style: Theme.of(context).textTheme.titleMedium!.copyWith( fontWeight: FontWeight.bold, ), ), const SizedBox(height: 8), Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), border: Border.all(color: Colors.grey[300]!), ), padding: const EdgeInsets.all(16), child: Row( children: [ Image.asset( AppAsset.iconBBCA, width: 50, ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Bank BCA', style: Theme.of(context).textTheme.titleSmall!.copyWith( fontWeight: FontWeight.bold, ), ), Text( 'Balance ${AppFormat.currency(80000)}', style: const TextStyle( color: Colors.grey, fontWeight: FontWeight.w300, ), ), ], ), ), const Icon(Icons.check_circle, color: AppColor.secondary), ], ), ), ], ), ); } Container roomDetails(Booking booking, BuildContext context) { return Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Booking Details', style: Theme.of(context).textTheme.titleMedium!.copyWith( fontWeight: FontWeight.bold, ), ), const SizedBox(height: 16), itemRoomDetail( context, 'Date', AppFormat.date(booking.date), ), const SizedBox(height: 8), itemRoomDetail(context, 'Guest', '${booking.guest} Guest'), const SizedBox(height: 8), // itemRoomDetail(context, 'Breakfast', booking.breakfast), // const SizedBox(height: 8), itemRoomDetail(context, 'Check-in Time', booking.checkInTime), const SizedBox(height: 8), // itemRoomDetail( // context, '${booking.night} night', AppFormat.currency(12900)), // const SizedBox(height: 8), // itemRoomDetail( // context, // 'Service fee', // AppFormat.currency(booking.serviceFee.toDouble()), // ), // const SizedBox(height: 8), // itemRoomDetail( // context, // 'Activities', // AppFormat.currency(booking.activities.toDouble()), // ), // const SizedBox(height: 8), itemRoomDetail( context, 'Total Payment', AppFormat.currency(booking.totalPayment.toDouble()), ), const SizedBox(height: 8), ], ), ); } Row itemRoomDetail(BuildContext context, String title, String data) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( title, style: Theme.of(context).textTheme.titleMedium, ), Text( data, style: Theme.of(context).textTheme.titleMedium!.copyWith( fontWeight: FontWeight.bold, ), ), ], ); } Container header(Booking booking, BuildContext context) { return Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), ), padding: const EdgeInsets.all(16), child: Row( children: [ ClipRRect( borderRadius: BorderRadius.circular(12), child: Image.network( booking.cover, fit: BoxFit.cover, height: 70, width: 90, ), ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( booking.name, style: Theme.of(context).textTheme.titleMedium!.copyWith( fontWeight: FontWeight.bold, ), ), Text( booking.location, style: const TextStyle( color: Colors.grey, fontWeight: FontWeight.w300, ), ), ], ), ), ], ), ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/page/nearby_page.dart
import '../config/app_format.dart'; import '../config/app_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:get/get.dart'; import '../config/app_asset.dart'; import '../config/app_color.dart'; import '../config/session.dart'; import '../controller/c_nearby.dart'; import '../model/hotel.dart'; class NearbyPage extends StatelessWidget { NearbyPage({Key? key}) : super(key: key); final cNearby = Get.put(CNearby()); TextEditingController searchingController = TextEditingController(); // searchHotel() { // cNearby.category = searchingController.text; // cNearby.getSearchHotel(searchingController.text); // } @override Widget build(BuildContext context) { return ListView( children: [ const SizedBox(height: 24), header(context), const SizedBox(height: 20), searchField(), const SizedBox(height: 30), categories(), const SizedBox(height: 30), hotels(), ], ); } GetBuilder<CNearby> hotels() { return GetBuilder<CNearby>(builder: (_) { List<Hotel> list = _.category == 'All Event' ? _.listHotel : _.listHotel.where((e) => e.category == cNearby.category).toList(); if (list.isEmpty) return const Center(child: Text('Empty')); return ListView.builder( itemCount: list.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { Hotel hotel = list[index]; return GestureDetector( onTap: () { Navigator.pushNamed(context, AppRoute.detail, arguments: hotel); }, child: Container( margin: EdgeInsets.fromLTRB( 16, index == 0 ? 0 : 8, 16, index == list.length - 1 ? 16 : 8, ), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ClipRRect( borderRadius: const BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20), ), child: AspectRatio( aspectRatio: 16 / 9, child: Image.network( hotel.cover, fit: BoxFit.cover, ), ), ), Padding( padding: const EdgeInsets.symmetric( horizontal: 16, vertical: 12, ), child: Row( children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( hotel.name, style: Theme.of(context) .textTheme .titleMedium! .copyWith( fontWeight: FontWeight.bold, ), maxLines: 1, overflow: TextOverflow.ellipsis, ), Text( hotel.location, style: const TextStyle( color: Colors.grey, fontSize: 13, ), ), const SizedBox(height: 20), Row( children: [ Text( AppFormat.currency(hotel.price.toDouble()), style: const TextStyle( color: AppColor.secondary, fontSize: 16, fontWeight: FontWeight.bold, ), ), const Text( ' /ticket', style: TextStyle( color: Colors.grey, fontSize: 13, ), ), ], ), ], ), ), RatingBar.builder( initialRating: hotel.rate, minRating: 0, direction: Axis.horizontal, allowHalfRating: true, itemCount: 5, itemBuilder: (context, _) => const Icon( Icons.star_rate_rounded, color: AppColor.starActive, ), itemSize: 18, unratedColor: AppColor.starInActive, onRatingUpdate: (rating) {}, ignoreGestures: true, ), ], ), ), ], ), ), ); }, ); }); } GetBuilder<CNearby> categories() { return GetBuilder<CNearby>(builder: (_) { return SizedBox( height: 45, child: ListView.builder( itemCount: _.categories.length, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { String category = _.categories[index]; return Padding( padding: EdgeInsets.fromLTRB( index == 0 ? 16 : 8, 0, index == cNearby.categories.length - 1 ? 16 : 8, 0, ), child: Material( color: category == _.category ? AppColor.primary : Colors.white, borderRadius: BorderRadius.circular(20), child: InkWell( borderRadius: BorderRadius.circular(20), onTap: () { cNearby.category = category; }, child: Container( alignment: Alignment.center, padding: const EdgeInsets.symmetric(horizontal: 30), child: Text( category, style: Theme.of(context).textTheme.titleSmall!.copyWith( fontWeight: FontWeight.bold, color: category == _.category ? Colors.white : Colors.black, ), ), ), ), ), ); }, ), ); }); } Container searchField() { return Container( height: 45, padding: const EdgeInsets.symmetric(horizontal: 16), child: Stack( children: [ Container( height: 45, decoration: BoxDecoration( borderRadius: BorderRadius.circular(30), color: Colors.white, ), child: TextField( controller: searchingController, decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(30), borderSide: BorderSide.none, ), hintText: 'Search by name or city', hintStyle: const TextStyle(color: Colors.grey, fontSize: 14), contentPadding: const EdgeInsets.symmetric( horizontal: 16, vertical: 8, ), ), ), ), Align( alignment: Alignment.centerRight, child: Material( color: AppColor.secondary, borderRadius: BorderRadius.circular(45), child: InkWell( onTap: () {}, borderRadius: BorderRadius.circular(45), child: const SizedBox( height: 45, width: 45, child: Center( child: ImageIcon( AssetImage(AppAsset.iconSearch), color: Colors.white, ), ), ), ), ), ), ], ), ); } Padding header(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector( onTap: () { showMenu( context: context, position: RelativeRect.fromLTRB(16, 16, 0, 0), items: [ const PopupMenuItem(child: Text('Logout'), value: 'logout'), ], ).then((value) { if (value == 'logout') { Session.clearUser(); Navigator.pushReplacementNamed(context, AppRoute.signin); } }); }, child: ClipRRect( borderRadius: BorderRadius.circular(50), child: Image.asset( AppAsset.profile, width: 50, height: 50, fit: BoxFit.cover, ), ), ), Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( 'Near Me', style: Theme.of(context).textTheme.titleLarge!.copyWith( fontWeight: FontWeight.w900, ), ), Obx(() { return Text( '${cNearby.listHotel.length} events', style: const TextStyle(color: Colors.grey, fontSize: 12), ); }), ], ), ], ), ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/source/hotel_source.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import '../model/hotel.dart'; class HotelSource { static Future<List<Hotel>> getHotel() async { var result = await FirebaseFirestore.instance.collection('Hotel').get(); return result.docs.map((e) => Hotel.fromJson(e.data())).toList(); } static Future<List<Hotel>> findHotel(String name) async { var result = await FirebaseFirestore.instance .collection('Hotel') .where('name', isGreaterThanOrEqualTo: name) .get(); return result.docs.map((e) => Hotel.fromJson(e.data())).toList(); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/source/user_source.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import '../config/session.dart'; import 'package:firebase_auth/firebase_auth.dart' as auth; import '../model/user.dart'; class UserSource { static Future<Map<String, dynamic>> signIn( String email, String password, ) async { Map<String, dynamic> response = {}; try { final credential = await auth.FirebaseAuth.instance .signInWithEmailAndPassword(email: email, password: password); response['success'] = true; response['message'] = 'Sign In Success'; String uid = credential.user!.uid; User user = await getWhereId(uid); Session.saveUser(user); } on auth.FirebaseAuthException catch (e) { response['success'] = false; if (e.code == 'user-not-found') { response['message'] = 'No user found for that email'; } else if (e.code == 'wrong-password') { response['message'] = 'Wrong password provided for that user'; } else { response['message'] = 'Sign in failed'; } } return response; } static Future<Map<String, dynamic>> signUp( String email, String password, ) async { Map<String, dynamic> response = {}; try { final credential = await auth.FirebaseAuth.instance.createUserWithEmailAndPassword( email: email, password: password, ); response['success'] = true; response['message'] = 'Sign Up Success'; } on auth.FirebaseAuthException catch (e) { response['success'] = false; if (e.code == 'weak-password') { response['message'] = 'The password provided is too weak'; } else if (e.code == 'email-already-in-use') { response['message'] = 'The account already exists for that email'; } else { response['message'] = 'Sign up failed'; } } return response; } static Future<User> getWhereId(String id) async { DocumentReference<Map<String, dynamic>> ref = FirebaseFirestore.instance.collection('User').doc(id); DocumentSnapshot<Map<String, dynamic>> doc = await ref.get(); return User.fromJson(doc.data()!); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/source/booking_source.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import '../model/booking.dart'; class BookingSource { static Future<Booking?> checkIsBooked(String userId, String hotelId) async { var result = await FirebaseFirestore.instance .collection('User') .doc(userId) .collection('Booking') .where('id_hotel', isEqualTo: hotelId) .where('is_done', isEqualTo: false) .get(); if (result.size > 0) { return Booking.fromJson(result.docs.first.data()); } return null; } static Future<bool> addBooking(String userId, Booking booking) async { var ref = FirebaseFirestore.instance .collection('User') .doc(userId) .collection('Booking'); var docRef = await ref.add(booking.toJson()); docRef.update({'id': docRef.id}); return true; } static Future<List<Booking>> getHistory(String id) async { var result = await FirebaseFirestore.instance .collection('User') .doc(id) .collection('Booking') .get(); return result.docs.map((e) => Booking.fromJson(e.data())).toList(); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/config/app_asset.dart
class AppAsset { static const logo = 'asset/logo.png'; static const profile = 'asset/profile.png'; static const bgIntro = 'asset/bg_intro.png'; static const iconHistory = 'asset/icon_history.png'; static const iconMasterCard = 'asset/icon_master_card.png'; static const iconNearby = 'asset/icon_nearby.png'; static const iconPayment = 'asset/icon_payment.png'; static const iconReward = 'asset/icon_reward.png'; static const iconSearch = 'asset/icon_search.png'; static const iconCoffee = 'asset/icon_coffee.png'; static const iconOffice = 'asset/icon_office.png'; static const iconStore = 'asset/icon_store.png'; static const iconWifi = 'asset/icon_wifi.png'; static const iconBBCA = 'asset/icon_bbca.png'; static const iconUser = 'asset/icon_user.png'; }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/config/session.dart
import 'dart:convert'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../controller/c_user.dart'; import '../model/user.dart'; class Session { static Future<bool> saveUser(User user) async { final pref = await SharedPreferences.getInstance(); Map<String, dynamic> mapUser = user.toJson(); String stringUser = jsonEncode(mapUser); bool success = await pref.setString('user', stringUser); if (success) { final cUser = Get.put(CUser()); cUser.setData(user); } return success; } static Future<User> getUser() async { User user = User(); // default value final pref = await SharedPreferences.getInstance(); String? stringUser = pref.getString('user'); if (stringUser != null) { Map<String, dynamic> mapUser = jsonDecode(stringUser); user = User.fromJson(mapUser); } final cUser = Get.put(CUser()); cUser.setData(user); return user; } static Future<bool> clearUser() async { final pref = await SharedPreferences.getInstance(); bool success = await pref.remove('user'); final cUser = Get.put(CUser()); cUser.setData(User()); return success; } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/config/app_route.dart
class AppRoute { static const intro = '/intro'; static const home = '/home'; static const signin = '/signin'; static const signup = '/signup'; static const detail = '/detail'; static const checkout = '/checkout'; static const checkoutSuccess = '/checkout_success'; static const detailBooking = '/detail_booking'; static const user = '/user'; }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/config/app_format.dart
import 'package:intl/intl.dart'; class AppFormat { static String date(String stringDate) { // 2022-02-05 DateTime dateTime = DateTime.parse(stringDate); return DateFormat('d MMM yyyy', 'en_US').format(dateTime); // 5 Feb 2022 } static String dateMonth(String stringDate) { // 2022-02-05 DateTime dateTime = DateTime.parse(stringDate); return DateFormat('d MMM', 'en_US').format(dateTime); // 5 Feb } static String currency(double number) { return NumberFormat.currency( decimalDigits: 0, locale: 'en_US', symbol: '\IDR ', ).format(number); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/config/app_color.dart
import 'package:flutter/material.dart'; class AppColor { static const primary = Color(0xff0276FE); static const secondary = Color(0xff0276FE); static const backgroundScaffold = Color(0xffF5FAFF); static const starActive = Color(0xffFA8F29); static const starInActive = Color(0xffF6F6F6); }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/model/booking.dart
class Booking { Booking({ required this.id, required this.idHotel, required this.cover, required this.name, required this.location, required this.date, required this.guest, // required this.breakfast, required this.checkInTime, // required this.night, // required this.serviceFee, // required this.activities, required this.totalPayment, required this.status, required this.isDone, }); String id; String idHotel; String cover; String name; String location; String date; int guest; // String breakfast; String checkInTime; // int night; // int serviceFee; // int activities; int totalPayment; String status; bool isDone; factory Booking.fromJson(Map<String, dynamic> json) => Booking( id: json["id"], idHotel: json["id_hotel"], cover: json["cover"], name: json["name"], location: json["location"], date: json["date"], guest: json["guest"], // breakfast: json["breakfast"], checkInTime: json["check_in_time"], // night: json["night"], // serviceFee: json["service_fee"], // activities: json["activities"], totalPayment: json["total_payment"], status: json["status"], isDone: json["is_done"], ); Map<String, dynamic> toJson() => { "id": id, "id_hotel": idHotel, "cover": cover, "name": name, "location": location, "date": date, "guest": guest, // "breakfast": breakfast, "check_in_time": checkInTime, // "night": night, // "service_fee": serviceFee, // "activities": activities, "total_payment": totalPayment, "status": status, "is_done": isDone, }; } Booking get initBooking => Booking( id: '', idHotel: '', cover: '', name: '', location: '', date: '', guest: 0, // breakfast: '', checkInTime: '', // night: 0, // serviceFee: 0, // activities: 0, totalPayment: 0, status: '', isDone: false, );
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/model/hotel.dart
class Hotel { Hotel({ required this.id, required this.name, required this.cover, required this.images, required this.price, required this.location, required this.rate, required this.description, required this.activities, required this.category, // required this.date, }); String id; String name; String cover; List<String> images; int price; String location; double rate; String description; List<Map<String, dynamic>> activities; String category; // String date; factory Hotel.fromJson(Map<String, dynamic> json) => Hotel( id: json["id"], name: json["name"], cover: json["cover"], images: List<String>.from(json["images"].map((x) => x)), price: json["price"], location: json["location"], rate: json["rate"].toDouble(), description: json["description"], activities: List<Map<String, dynamic>>.from(json["activities"]), category: json["category"], // date: json["date"], ); Map<String, dynamic> toJson() => { "id": id, "name": name, "cover": cover, "images": List<dynamic>.from(images.map((x) => x)), "price": price, "location": location, "rate": rate, "description": description, "activities": activities, "category": category, // "date": date, }; }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/model/user.dart
class User { User({ this.id, this.name, this.email, this.password, }); String? id; String? name; String? email; String? password; factory User.fromJson(Map<String, dynamic> json) => User( id: json["id"], name: json["name"], email: json["email"], password: json["password"], ); Map<String, dynamic> toJson() => { "id": id, "name": name, "email": email, "password": password, }; }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/widget/button_custom.dart
import 'package:flutter/material.dart'; import '../config/app_color.dart'; class ButtonCustom extends StatelessWidget { const ButtonCustom( {Key? key, required this.label, required this.onTap, this.isExpand}) : super(key: key); final String label; final Function onTap; final bool? isExpand; @override Widget build(BuildContext context) { return SizedBox( height: 50, child: Stack( children: [ Align( alignment: const Alignment(0, 0.7), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), boxShadow: const [ BoxShadow( color: AppColor.primary, offset: Offset(0, 5), blurRadius: 20, ), ], ), width: isExpand == null ? null : isExpand! ? double.infinity : null, padding: const EdgeInsets.symmetric( horizontal: 16, vertical: 10, ), margin: const EdgeInsets.symmetric(horizontal: 20), child: Text(label), ), ), Align( child: Material( color: AppColor.primary, borderRadius: BorderRadius.circular(20), child: InkWell( borderRadius: BorderRadius.circular(20), onTap: () => onTap(), child: Container( width: isExpand == null ? null : isExpand! ? double.infinity : null, padding: const EdgeInsets.symmetric( horizontal: 36, vertical: 12, ), child: Text( label, textAlign: TextAlign.center, style: const TextStyle( color: Colors.white, fontSize: 16, fontWeight: FontWeight.w900, ), ), ), ), ), ), ], ), ); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/penyelenggara/create_event_page.dart
// import 'package:dio/dio.dart'; // import 'package:flutter/material.dart'; // import 'package:get/get.dart'; // import 'package:image_picker/image_picker.dart'; // class CreateEventPage extends StatefulWidget { // const CreateEventPage({super.key}); // @override // State<CreateEventPage> createState() => _CreateEventPageState(); // } // class _CreateEventPageState extends State<CreateEventPage> { // @override // Widget build(BuildContext context) { // /* // ------------------------ // https://capekngoding.com // ------------------------ // Starring: // Name: Deny Ocr // Youtube: https://www.youtube.com/c/CapekNgoding // ------------------------ // [1] Update pubspec.yaml // blur: // image_picker: // dio: // [2] Import // import 'package:image_picker/image_picker.dart'; // import 'package:dio/dio.dart'; // [2.a] If you are using Getx // import 'package:get/get.dart' hide Response, FormData, MultipartFile; // ------------------------ // Code generation with snippets can be a good solution for you or it can kill you. // A basic understanding of Dart and Flutter is required. // Keep it in mind, Our snippet can't generate many files yet. // So, all of our snippets are put in one file which is not best practice. // You need to do the optimization yourself, and at least you are familiar with using Flutter. // ------------------------ // */ // return Scaffold( // appBar: AppBar( // title: const Text("Create Post"), // actions: [ // Padding( // padding: const EdgeInsets.all(12.0), // child: ElevatedButton( // style: ElevatedButton.styleFrom( // backgroundColor: Colors.orange[600], // ), // onPressed: () {}, // child: const Text("Post"), // ), // ) // ], // ), // body: SafeArea( // child: Column( // children: [ // Container( // padding: const EdgeInsets.all(12.0), // child: ListTile( // leading: CircleAvatar( // backgroundColor: Colors.grey[200], // backgroundImage: const NetworkImage( // "https://i.ibb.co/QrTHd59/woman.jpg", // ), // ), // title: const Text("Jessica Doe"), // subtitle: Row( // children: [ // Card( // child: Container( // padding: const EdgeInsets.all(6.0), // child: Row( // children: const [ // Icon( // Icons.public, // size: 12.0, // ), // SizedBox( // width: 4.0, // ), // Text( // "Public", // style: TextStyle( // fontSize: 10.0, // ), // ), // ], // ), // ), // ) // ], // ), // ), // ), // const Expanded( // child: Padding( // padding: EdgeInsets.only(left: 20.0, right: 20.0), // child: TextField( // decoration: InputDecoration.collapsed( // hintText: "What's on your mind?", // ), // ), // ), // ), // Container( // height: 24 + 60.0, // padding: const EdgeInsets.all(12.0), // child: ListView.builder( // itemCount: 6, // scrollDirection: Axis.horizontal, // itemBuilder: (context, index) { // return Container( // height: 60.0, // width: 60.0, // margin: const EdgeInsets.only(right: 10.0), // decoration: BoxDecoration( // color: Colors.grey[200], // borderRadius: const BorderRadius.all( // Radius.circular( // 16.0, // ), // ), // ), // ); // }, // ), // ), // const Divider(), // Container( // width: MediaQuery.of(context).size.width, // padding: const EdgeInsets.symmetric(horizontal: 30.0), // child: Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, // children: [ // IconButton( // icon: const Icon( // Icons.camera_alt_outlined, // color: Colors.blueGrey, // ), // onPressed: () async { // final ImagePicker imagePicker = ImagePicker(); // var image = await imagePicker.pickImage( // source: ImageSource.camera, // maxWidth: 1024, // ); // if (image == null) return; // final formData = FormData.fromMap({ // 'image': MultipartFile.fromBytes( // await image.readAsBytes(), // filename: "upload.jpg", // ), // }); // var res = await Dio().post( // 'https://api.imgbb.com/1/upload?key=b55ef3fd02b80ab180f284e479acd7c4', // data: formData, // ); // var data = res.data["data"]; // var imageUrl = data["url"]; // // ignore: avoid_print // print("imageUrl: $imageUrl"); // }, // ), // IconButton( // icon: const Icon( // Icons.photo, // color: Colors.green, // ), // onPressed: () async { // final ImagePicker imagePicker = ImagePicker(); // var image = await imagePicker.pickImage( // source: ImageSource.gallery, // maxWidth: 1024, // ); // if (image == null) return; // final formData = FormData.fromMap({ // 'image': MultipartFile.fromBytes( // await image.readAsBytes(), // filename: "upload.jpg", // ), // }); // var res = await Dio().post( // 'https://api.imgbb.com/1/upload?key=b55ef3fd02b80ab180f284e479acd7c4', // data: formData, // ); // var data = res.data["data"]; // var imageUrl = data["url"]; // // ignore: avoid_print // print("imageUrl: $imageUrl"); // }, // ), // IconButton( // icon: const Icon( // Icons.pin_drop, // color: Colors.red, // ), // onPressed: () async {}, // ), // IconButton( // icon: Icon( // Icons.emoji_emotions, // color: Colors.yellow[700], // ), // onPressed: () async {}, // ), // IconButton( // icon: Icon( // Icons.tag, // color: Colors.grey[600], // ), // onPressed: () async {}, // ), // IconButton( // icon: Icon( // Icons.more_horiz, // color: Colors.grey[600], // ), // onPressed: () async {}, // ), // ], // ), // ), // ], // ), // ), // ); // } // }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/penyelenggara/list_event_page.dart
import 'package:flutter/material.dart'; class ListEventPage extends StatefulWidget { const ListEventPage({super.key}); @override State<ListEventPage> createState() => _ListEventPageState(); } class _ListEventPageState extends State<ListEventPage> { @override Widget build(BuildContext context) { return Container(); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/penyelenggara/detail_event_page.dart
import 'package:flutter/material.dart'; class DetailEventPage extends StatefulWidget { const DetailEventPage({super.key}); @override State<DetailEventPage> createState() => _DetailEventPageState(); } class _DetailEventPageState extends State<DetailEventPage> { @override Widget build(BuildContext context) { return Container(); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/penyelenggara/edit_event_page.dart
import 'package:flutter/material.dart'; class EditEventPage extends StatefulWidget { const EditEventPage({super.key}); @override State<EditEventPage> createState() => _EditEventPageState(); } class _EditEventPageState extends State<EditEventPage> { @override Widget build(BuildContext context) { return Container(); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/controller/c_home.dart
import 'package:get/get.dart'; class CHome extends GetxController { final _indexPage = 0.obs; int get indexPage => _indexPage.value; set indexPage(n) => _indexPage.value = n; }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/controller/c_user.dart
import 'package:get/get.dart'; import '../model/user.dart'; class CUser extends GetxController { final _data = User().obs; User get data => _data.value; setData(n) => _data.value = n; }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/controller/c_nearby.dart
import '../source/hotel_source.dart'; import 'package:get/get.dart'; import '../model/hotel.dart'; class CNearby extends GetxController { final _category = 'All Event'.obs; String get category => _category.value; set category(n) { _category.value = n; update(); } List<String> get categories => [ 'All Event', 'Concert', 'Seminar', 'Festival', ]; final _listHotel = <Hotel>[].obs; List<Hotel> get listHotel => _listHotel.value; getListHotel() async { _listHotel.value = await HotelSource.getHotel(); update(); } @override void onInit() { getListHotel(); super.onInit(); } getSearchHotel() async { _listHotel.value = await HotelSource.findHotel(category); update(); } }
0
mirrored_repositories/tsa_eventq/lib
mirrored_repositories/tsa_eventq/lib/controller/c_history.dart
import 'package:get/get.dart'; import '../model/booking.dart'; import '../source/booking_source.dart'; class CHistory extends GetxController { final _listBooking = <Booking>[].obs; List<Booking> get listBooking => _listBooking.value; getListBooking(String id) async { _listBooking.value = await BookingSource.getHistory(id); update(); } }
0
mirrored_repositories/tsa_eventq
mirrored_repositories/tsa_eventq/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:tsa_eventq/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/NASA-MobileApp
mirrored_repositories/NASA-MobileApp/lib/main.dart
import 'package:flutter/material.dart'; import 'package:nasa_mobileapp/themeData/theme_manager.dart'; import 'package:nasa_mobileapp/views/homePage.dart'; import 'package:provider/provider.dart'; void main() { return runApp(ChangeNotifierProvider<ThemeNotifier>( create: (_) => ThemeNotifier(), child: MyApp(), )); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return Consumer<ThemeNotifier>( builder: (context, theme, child) => MaterialApp( theme: theme.getTheme(), home: HomePage(), debugShowCheckedModeBanner: false, ), ); } }
0
mirrored_repositories/NASA-MobileApp/lib
mirrored_repositories/NASA-MobileApp/lib/views/viewList.dart
import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart'; import 'package:nasa_mobileapp/customWidgets/customFloatingActionButton.dart'; import 'package:nasa_mobileapp/customWidgets/detailsCard.dart'; import 'package:nasa_mobileapp/themeData/theme_manager.dart'; import 'package:nasa_mobileapp/utilities/sql.dart'; import 'package:nasa_mobileapp/utilities/background.dart'; import 'package:nasa_mobileapp/views/singleContentViewPage.dart'; import 'package:provider/provider.dart'; import 'package:http/http.dart' as http; class ViewList extends StatefulWidget { late var url, data, pageNumber; ViewList({ required this.url, required this.data, required this.pageNumber, }); @override _ViewListState createState() => _ViewListState(); } class _ViewListState extends State<ViewList> { bool isLoading = false; @override Widget build(BuildContext context) { List list = widget.data['collection']['items']; API api = new API(); return WillPopScope( onWillPop: () async => false, child: Consumer<ThemeNotifier>( builder: (context, theme, child) => Scaffold( appBar: AppBar(toolbarHeight: 0), backgroundColor: Theme.of(context).primaryColor, body: ModalProgressHUD( inAsyncCall: isLoading, child: Scaffold( backgroundColor: Theme.of(context).primaryColor, body: BackgroundBody( theme: theme, child: buildBody(api, list), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, floatingActionButton: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.only(left: 10), child: ChangePageFloatingActionButton( data: widget.data['collection']['links'], pageNumber: widget.pageNumber, isLoading: (value) { setState(() { isLoading = value; }); }, ), ), Padding( padding: const EdgeInsets.only(right: 10), child: GoHomeFloatingActionButton(), ), ], ), ), ), ), ), ); } FutureBuilder buildBody(api, list) { return FutureBuilder( future: api.getData(widget.url), builder: (BuildContext context, snapshot) { return ListView.builder( itemBuilder: (context, index) => MaterialButton( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 0), onPressed: () { changePage(index, list[index]); }, child: CustomDetailCard( title: list[index]['data'][0]['title'], description: list[index]['data'][0]['description'], image: list[index]['links'][0]['href'], ), ), itemCount: list.length, ); }, ); } void changePage(index, data) async { setState(() { isLoading = true; }); http.Response response = await http.get(Uri.parse(data['href'])); if (response.statusCode == 200) { setState(() { isLoading = false; }); var imageURL = jsonDecode(response.body)[0]; //print(imageURL); Navigator.push( context, MaterialPageRoute( builder: (context) => SingleContentViewPage( data: data, imageURL: imageURL, ))); } } }
0
mirrored_repositories/NASA-MobileApp/lib
mirrored_repositories/NASA-MobileApp/lib/views/homePage.dart
import 'dart:convert'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart'; import 'package:nasa_mobileapp/customWidgets/customElevatedButton.dart'; import 'package:nasa_mobileapp/customWidgets/homePageTopIcons.dart'; import 'package:nasa_mobileapp/customWidgets/singleContentView/customSnackBar.dart'; import 'package:nasa_mobileapp/customWidgets/yearTestField.dart'; import 'package:nasa_mobileapp/themeData/theme_manager.dart'; import 'package:nasa_mobileapp/utilities/background.dart'; import 'package:nasa_mobileapp/views/viewList.dart'; import 'package:provider/provider.dart'; import 'package:http/http.dart' as http; class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { String searchKey = ''; String year_start = ''; String year_end = ''; bool isValidate = false; bool isLoading = false; bool showFilters = false; TextEditingController searchKeyTEC = TextEditingController(); TextEditingController year_startTEC = TextEditingController(); TextEditingController year_endTEC = TextEditingController(); @override Widget build(BuildContext context) { return Consumer<ThemeNotifier>( builder: (context, theme, child) => Scaffold( appBar: AppBar(toolbarHeight: 0), backgroundColor: Theme.of(context).primaryColor, body: ModalProgressHUD( inAsyncCall: isLoading, child: Scaffold( backgroundColor: Theme.of(context).primaryColor, body: BackgroundBody( theme: theme, child: buildBody(theme), ), ), ), ), ); } Column buildBody(theme) { return Column( children: [ HomePageTopIconsRow(theme: theme), Flexible( child: SingleChildScrollView( child: Column( children: [ Center( child: Padding( padding: const EdgeInsets.all(8.0), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( mainAxisSize: MainAxisSize.min, children: [ const Padding( padding: EdgeInsets.all(50), child: Image( image: AssetImage('images/logo.png'), ), ), TextField( onChanged: (value) { setState(() { searchKey = value; }); }, autofocus: false, style: TextStyle(color: Theme.of(context).canvasColor), controller: searchKeyTEC, decoration: InputDecoration( hintText: 'Search', errorText: isValidate ? 'Cannot Search Empty' : null, border: const OutlineInputBorder(), focusedBorder: OutlineInputBorder( borderSide: BorderSide( color: Theme.of(context).canvasColor, ), ), suffixIcon: Visibility( visible: searchKey != '', child: IconButton( onPressed: () { searchKeyTEC.clear(); setState(() { searchKey = ''; }); }, icon: Icon( Icons.clear, color: Theme.of(context).canvasColor, ), ), ), ), ), const SizedBox(height: 15), Visibility( visible: !showFilters, child: searchButton()), Visibility( visible: !showFilters, child: const SizedBox(height: 20)), showFilters ? buildFilter() : TextButton( onPressed: () { setState(() { showFilters = true; }); }, child: const Text('Show Filters'), ), Visibility( visible: showFilters, child: const SizedBox(height: 20)), Visibility( visible: showFilters, child: searchButton()), ], ), ), ), ), ], ), ), ), ], ); } CustomElevatedButton searchButton() { return CustomElevatedButton( onPressed: () { setState(() { isValidate = searchKeyTEC.text.isEmpty ? true : false; }); if (searchKeyTEC.text.isNotEmpty) { changePage(searchKey); } }, text: 'SEARCH'); } Visibility buildFilter() { return Visibility( visible: showFilters, child: Row( children: [ CustomYearTextField( hintText: 'Start Year', controller: year_startTEC, onChanged: (value) { setState(() { year_start = value; }); }, visible: year_start != '', onPressed: () { year_startTEC.clear(); setState(() { year_start = ''; }); }, ), const SizedBox(width: 10), CustomYearTextField( hintText: 'End Year', controller: year_endTEC, onChanged: (value) { setState(() { year_end = value; }); }, visible: year_end != '', onPressed: () { year_endTEC.clear(); setState(() { year_end = ''; }); }, ), ], ), ); } Future<void> changePage(searchKey) async { setState(() { isLoading = true; }); var url; if (year_startTEC.text.isNotEmpty && year_endTEC.text.isNotEmpty) { url = Uri.https( 'images-api.nasa.gov', '/search', { "q": searchKey, "year_start": year_start, "year_end": year_end, "media_type": "image", }, ); } else if (year_startTEC.text.isNotEmpty && year_endTEC.text.isEmpty) { url = Uri.https( 'images-api.nasa.gov', '/search', { "q": searchKey, "year_start": year_start, "media_type": "image", }, ); } else if (year_startTEC.text.isEmpty && year_endTEC.text.isNotEmpty) { url = Uri.https( 'images-api.nasa.gov', '/search', { "q": searchKey, "year_end": year_end, "media_type": "image", }, ); } else { url = Uri.https( 'images-api.nasa.gov', '/search', { "q": searchKey, "media_type": "image", }, ); } http.Response response = await http.get(url); if (response.statusCode == 200) { setState(() { isLoading = false; }); var data = jsonDecode(response.body); if(data['collection']['items'].toString() == '[]'){ ScaffoldMessenger.of(context).showSnackBar(noDataSnackBar()); } else{ Navigator.push( context, MaterialPageRoute( builder: (context) => ViewList( url: url, data: data, pageNumber: 1, ), ), ); } } } }
0
mirrored_repositories/NASA-MobileApp/lib
mirrored_repositories/NASA-MobileApp/lib/views/singleContentViewPage.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:image_downloader/image_downloader.dart'; import 'package:nasa_mobileapp/customWidgets/customElevatedButton.dart'; import 'package:nasa_mobileapp/customWidgets/customFloatingActionButton.dart'; import 'package:nasa_mobileapp/customWidgets/singleContentView/customSnackBar.dart'; import 'package:nasa_mobileapp/customWidgets/singleContentView/imageView.dart'; import 'package:nasa_mobileapp/customWidgets/singleContentView/showDownloading.dart'; import 'package:nasa_mobileapp/customWidgets/singleContentView/textView.dart'; import 'package:nasa_mobileapp/themeData/theme_manager.dart'; import 'package:nasa_mobileapp/utilities/background.dart'; import 'package:provider/provider.dart'; class SingleContentViewPage extends StatefulWidget { String imageURL; var data; SingleContentViewPage({ required this.data, required this.imageURL, }); @override _SingleContentViewPageState createState() => _SingleContentViewPageState(); } GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey(); class _SingleContentViewPageState extends State<SingleContentViewPage> { bool isDownloading = false; @override Widget build(BuildContext context) { return Consumer<ThemeNotifier>( builder: (context, theme, child) => Scaffold( appBar: AppBar(toolbarHeight: 0), backgroundColor: Theme.of(context).primaryColor, body: Scaffold( key: _scaffoldKey, backgroundColor: Theme.of(context).primaryColor, body: BackgroundBody( theme: theme, child: buildBody(), ), floatingActionButton: GoBackFloatingActionButton(), ), ), ); } ListView buildBody() { return ListView( children: [ TextView( title: widget.data['data'][0]['title'], description: widget.data['data'][0]['description'], date_created: widget.data['data'][0]['date_created'], textColor: Theme.of(context).canvasColor, ), ImageView( url: widget.imageURL, ), Padding( padding: const EdgeInsets.all(15), child: isDownloading ? ShowDownloading() : CustomElevatedButton( text: 'DOWNLOAD IMAGE', onPressed: () { downloadImage(widget.imageURL); }, ), ), ], ); } downloadImage(url) async { try { setState(() { isDownloading = true; }); String s = url; int idx = s.indexOf(":"); String downloadURL = 'https:${s.substring(idx + 1).trim()}'; /// Download image var imageId = await ImageDownloader.downloadImage(downloadURL); if (imageId == null) { setState(() { isDownloading = false; }); ScaffoldMessenger.of(context).showSnackBar(failedSnackBar()); return; } /// if success setState(() { isDownloading = false; }); ScaffoldMessenger.of(context).showSnackBar(successfulSnackBar()); } on PlatformException catch (error) { setState(() { isDownloading = false; }); ScaffoldMessenger.of(context).showSnackBar(failedSnackBar()); print(error); } } }
0
mirrored_repositories/NASA-MobileApp/lib
mirrored_repositories/NASA-MobileApp/lib/utilities/sql.dart
import 'dart:convert'; import 'package:http/http.dart' as http; class API { getData(url) async { http.Response response = await http.get(url); return jsonDecode(response.body); } }
0