public override Widget build(BuildContext context) { base.build(context: context); return(new Container( padding: EdgeInsets.only(top: CCommonUtils.getSafeAreaTopPadding(context: context)), color: CColors.White, child: new Column( children: new List <Widget> { new CustomNavigationBar( new Text("活动", style: CTextStyle.H2) ), new Expanded( child: new CustomSegmentedControl( new List <object> { "即将开始", "往期活动" }, new List <Widget> { new EventOngoingScreenConnector(), new EventCompletedScreenConnector() }, newValue => AnalyticsManager.ClickEventSegment("Event", 0 == newValue ? "ongoing" : "completed"), 1 ) ) } ) )); }
List <Widget> _buildItems(BuildContext context, out int commentIndex) { var originItems = new List <Widget> { this._buildContentHead() }; originItems.AddRange( ContentDescription.map( context: context, cont: this._article.body, contentMap: this._article.contentMap, this._article.videoSliceMap, this._article.videoPosterMap, openUrl: this.widget.actionModel.openUrl, playVideo: this.widget.actionModel.playVideo, this.widget.actionModel.pushToLogin, UserInfoManager.isLogin() ? CCommonUtils.GetUserLicense(UserInfoManager.initUserInfo().userId, this.widget.viewModel.userLicenseDict) : "", this.widget.actionModel.browserImage ) ); // originItems.Add(this._buildActionCards(this._article.like)); originItems.Add(this._buildRelatedArticles()); commentIndex = originItems.Count; originItems.AddRange(this._buildComments(context: context)); return(originItems); }
Widget _buildNotLoginInNavigationBar() { return(new Container( color: CColors.White, padding: EdgeInsets.only(16, CCommonUtils.getSafeAreaTopPadding(context: this.context), bottom: 16), child: new Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { _buildQrScanWidget(), new Text("欢迎来到", style: CTextStyle.H2), new Text("Unity Connect", style: CTextStyle.H2), new Container( margin: EdgeInsets.only(top: 16), child: new CustomButton( padding: EdgeInsets.zero, onPressed: () => this.widget.actionModel.mainRouterPushTo(obj: MainNavigatorRoutes.Login), child: new Container( padding: EdgeInsets.symmetric(horizontal: 24, vertical: 8), decoration: new BoxDecoration( border: Border.all(color: CColors.PrimaryBlue), borderRadius: BorderRadius.all(20) ), child: new Text( "登录/注册", style: CTextStyle.PLargeMediumBlue ) ) ) ) } ) )); }
public override Widget build(BuildContext context) { base.build(context: context); var mode = this._selectValue == "all" ? "" : this._selectValue; return(new Container( padding: EdgeInsets.only(top: CCommonUtils.getSafeAreaTopPadding(context: context)), color: CColors.White, child: new Column( children: new List <Widget> { new CustomNavigationBar( new Text("活动", style: CTextStyle.H2) ), new Expanded( child: new CustomSegmentedControl( new List <object> { "即将开始", "往期活动" }, new List <Widget> { new EventOngoingScreenConnector(mode: mode), new EventCompletedScreenConnector(mode: mode) }, newValue => AnalyticsManager.ClickEventSegment("Event", 0 == newValue ? "ongoing" : "completed"), 1, trailing: new Container( padding: EdgeInsets.only(right: 12), child: new CustomDropdownButton <string>( value: this._selectValue, items: new List <CustomDropdownMenuItem <string> > { new CustomDropdownMenuItem <string>( value: "all", child: new Text("全部") ), new CustomDropdownMenuItem <string>( value: "online", child: new Text("线上") ), new CustomDropdownMenuItem <string>( value: "offline", child: new Text("线下") ) }, onChanged: newValue => { if (this._selectValue != newValue) { this.setState(() => this._selectValue = newValue); } }, headerWidget: new Container(height: 6, color: CColors.White), footerWidget: new Container(height: 6, color: CColors.White) ) ) ) ) } ) )); }
bool _onNotification(ScrollNotification notification) { var pixels = notification.metrics.pixels; var navBarBottomPosition = navBarHeight + CCommonUtils.getSafeAreaTopPadding(context: this.context); if (pixels >= navBarBottomPosition) { if (this._hideNavBar) { this.setState(() => this._hideNavBar = false); StatusBarManager.statusBarStyle(false); } } else { if (!this._hideNavBar) { this.setState(() => this._hideNavBar = true); StatusBarManager.statusBarStyle(true); } } if (pixels > imageBaseHeight - navBarHeight - 24) { if (!this._isHaveTitle) { this._controller.forward(); this.setState(() => this._isHaveTitle = true); } } else { if (this._isHaveTitle) { this._controller.reverse(); this.setState(() => this._isHaveTitle = false); } } if (pixels > imageBaseHeight - navBarHeight) { if (!this._isShowTop) { this.setState(() => this._isShowTop = true); } } else { if (this._isShowTop) { this.setState(() => this._isShowTop = false); } } return(true); }
Widget _buildNotLoginInNavigationBar() { return(new Container( color: CColors.White, padding: EdgeInsets.only(top: CCommonUtils.getSafeAreaTopPadding(context: this.context)), margin: EdgeInsets.only(bottom: 16), child: new Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { this._buildQrScanWidget(false), new Container( padding: EdgeInsets.only(16, 8, 16, 24), child: new Row( children: new List <Widget> { new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Text("欢迎来到", style: CTextStyle.H4.defaultHeight()), new Text("Unity Connect", style: CTextStyle.H2.defaultHeight()), new Container( margin: EdgeInsets.only(top: 24), child: new CustomButton( padding: EdgeInsets.zero, onPressed: () => this.widget.actionModel.mainRouterPushTo( obj: MainNavigatorRoutes.Login), child: new Container( height: 40, width: 120, alignment: Alignment.center, decoration: new BoxDecoration( color: CColors.PrimaryBlue, borderRadius: BorderRadius.all(20) ), child: new Text( "登录/注册", style: CTextStyle.PLargeMediumWhite.defaultHeight() ) ) ) ) } ), new Expanded( child: Image.asset( "image/mine_mascot_u" ) ) } ) ) } ) )); }
bool _onNotification(BuildContext context, ScrollNotification notification) { var axisDirection = notification.metrics.axisDirection; if (axisDirection == AxisDirection.left || axisDirection == AxisDirection.right) { return(true); } var pixels = notification.metrics.pixels; var topPadding = 44 + CCommonUtils.getSafeAreaTopPadding(context: context); if (this._playButtonPosition == 0.0f) { var width = MediaQuery.of(context).size.width; var imageHeight = width / this._aspectRatio; this._playButtonPosition = imageHeight + gameBriefKey.currentContext.size.height - topPadding - 24 - 6; // topPadding 是顶部的高度, 24 是底部的 padding, 6 是按钮到左边图片到底部的距离 } if (pixels >= 44 + topPadding) { if (this._showNavBarShadow) { this.setState(() => { this._showNavBarShadow = false; }); StatusBarManager.statusBarStyle(false); } } else { if (!this._showNavBarShadow) { this.setState(() => { this._showNavBarShadow = true; }); StatusBarManager.statusBarStyle(true); } } if (pixels > this._playButtonPosition) { if (!this._isHaveTitle) { this._controller.forward(); this.setState(() => { this._isHaveTitle = true; }); } } else { if (this._isHaveTitle) { this._controller.reverse(); this.setState(() => { this._isHaveTitle = false; }); } } return(true); }
public override Widget build(BuildContext context) { base.build(context: context); var completedEvents = this.widget.viewModel.completedEvents; if (!this._hasBeenLoadedData || this.widget.viewModel.eventCompletedLoading && completedEvents.isEmpty()) { return(new Container( padding: EdgeInsets.only(bottom: CConstant.TabBarHeight + CCommonUtils.getSafeAreaBottomPadding(context: context)), child: new GlobalLoading() )); } if (0 == completedEvents.Count) { return(new Container( padding: EdgeInsets.only(bottom: CConstant.TabBarHeight + CCommonUtils.getSafeAreaBottomPadding(context: context)), child: new BlankView( "暂无往期活动,看看新活动吧", "image/default-event", true, () => { this.widget.actionModel.startFetchEventCompleted(); this.widget.actionModel.fetchEvents(arg1: firstPageNumber, arg2: eventTab); } ) )); } var enablePullUp = completedEvents.Count < this.widget.viewModel.completedEventTotal; var itemCount = enablePullUp ? completedEvents.Count : completedEvents.Count + 1; return(new Container( color: CColors.Background, child: new CustomScrollbar( new SmartRefresher( controller: this._completedRefreshController, enablePullDown: true, enablePullUp: enablePullUp, onRefresh: this._completedRefresh, hasBottomMargin: true, child: ListView.builder( physics: new AlwaysScrollableScrollPhysics(), itemCount: itemCount, itemBuilder: this._buildEventCard ) ) ) )); }
void _showBloggerDialog(Rect rect) { PreferencesManager.updateKingKongType(type: KingKongType.blogger); CustomDialogUtils.showCustomDialog( child: new Bubble( "这里可以发现很多大牛博主哦", rect.width - rect.width / 8.0f, rect.bottom - 16 - CCommonUtils.getSafeAreaTopPadding(context: this.context), contentRight: 16 ), barrierDismissible: true ); }
public override Widget build(BuildContext context) { base.build(context: context); return(new Container( padding: EdgeInsets.only(top: CCommonUtils.getSafeAreaTopPadding(context: context)), color: CColors.White, child: new Column( children: new List <Widget> { this._buildSelectView(), this._buildContentView() } ) )); }
void _showTinyGameDialog(Rect rect) { PreferencesManager.updateKingKongType(type: KingKongType.tinyGame); CustomDialogUtils.showCustomDialog( child: new Bubble( "这里可以看 Tiny Projects 哦", rect.left + rect.width / 2.0f, rect.bottom + 8 - CCommonUtils.getSafeAreaTopPadding(context: this.context), contentRight: 16 ), barrierDismissible: true, onPop: () => {} ); }
bool _onNotification(BuildContext context, ScrollNotification notification) { var pixels = notification.metrics.pixels; var topPadding = 44 + CCommonUtils.getSafeAreaTopPadding(context: context); if (this._titleHeight == 0.0f) { var width = MediaQuery.of(context).size.width; var imageHeight = width / this._aspectRatio; this._titleHeight = imageHeight + eventTitleKey.currentContext.size.height - topPadding + 16; // topPadding 是顶部的高度 16 是文字与图片的间隙 } if (pixels >= 44 + topPadding) { if (this._showNavBarShadow) { this.setState(() => { this._showNavBarShadow = false; }); StatusBarManager.statusBarStyle(false); } } else { if (!this._showNavBarShadow) { this.setState(() => { this._showNavBarShadow = true; }); StatusBarManager.statusBarStyle(true); } } if (pixels > this._titleHeight) { if (!this._isHaveTitle) { this._controller.forward(); this.setState(() => { this._isHaveTitle = true; }); } } else { if (this._isHaveTitle) { this._controller.reverse(); this.setState(() => { this._isHaveTitle = false; }); } } return(true); }
public override Widget build(BuildContext context) { base.build(context: context); var ongoingEvents = this.widget.viewModel.ongoingEvents; if (!this._hasBeenLoadedData || this.widget.viewModel.eventOngoingLoading && ongoingEvents.isEmpty()) { return(new Container( padding: EdgeInsets.only(bottom: CConstant.TabBarHeight + CCommonUtils.getSafeAreaBottomPadding(context: context)), child: new GlobalLoading() )); } if (0 == ongoingEvents.Count) { return(new Container( padding: EdgeInsets.only(bottom: CConstant.TabBarHeight + CCommonUtils.getSafeAreaBottomPadding(context: context)), child: new BlankView( "暂无新活动,看看往期活动吧", "image/default-event", true, () => { this.widget.actionModel.startFetchEventOngoing(); this.widget.actionModel.fetchEvents(arg1: firstPageNumber, arg2: eventTab); } ) )); } var enablePullUp = ongoingEvents.Count < this.widget.viewModel.ongoingEventTotal; return(new Container( color: CColors.Background, child: new CustomListView( controller: this._ongoingRefreshController, enablePullDown: true, enablePullUp: enablePullUp, onRefresh: this._ongoingRefresh, hasBottomMargin: true, itemCount: ongoingEvents.Count, itemBuilder: this._buildEventCard, headerWidget: CustomListViewConstant.defaultHeaderWidget, footerWidget: enablePullUp ? null : new EndView(hasBottomMargin: true) ) )); }
Widget _buildUserCard(BuildContext context, int index) { var followingUsers = this.widget.viewModel.followingUsers; var followingUser = followingUsers[index : index]; UserType userType = UserType.unFollow; if (!this.widget.viewModel.isLoggedIn) { userType = UserType.unFollow; } else { bool followUserLoading; if (this.widget.viewModel.userDict.ContainsKey(key: followingUser.id)) { var user = this.widget.viewModel.userDict[key : followingUser.id]; followUserLoading = user.followUserLoading ?? false; } else { followUserLoading = false; } if (this.widget.viewModel.currentUserId == followingUser.id) { userType = UserType.me; } else if (followUserLoading) { userType = UserType.loading; } else if (this.widget.viewModel.followMap.ContainsKey(key: followingUser.id)) { userType = UserType.follow; } } return(new UserCard( user: followingUser, CCommonUtils.GetUserLicense(userId: followingUser.id, userLicenseMap: this.widget.viewModel.userLicenseDict), () => this.widget.actionModel.pushToUserDetail(obj: followingUser.id), userType: userType, () => this._onFollow(userType: userType, userId: followingUser.id), key: new ObjectKey(value: followingUser.id) )); }
Widget _buildArticleList(BuildContext context) { Widget content; var recommendArticleIds = this.widget.viewModel.recommendArticleIds; if (!this._hasBeenLoadedData || this.widget.viewModel.articlesLoading && recommendArticleIds.isEmpty()) { content = ListView.builder( physics: new NeverScrollableScrollPhysics(), itemCount: 6, itemBuilder: (cxt, index) => new ArticleLoading() ); } else if (0 == recommendArticleIds.Count) { content = new Container( padding: EdgeInsets.only(bottom: CConstant.TabBarHeight + CCommonUtils.getSafeAreaBottomPadding(context: context)), child: new BlankView( "哎呀,暂无推荐文章", "image/default-article", true, () => { this.widget.actionModel.startFetchArticles(); this.widget.actionModel.fetchArticles(arg1: this.widget.viewModel.currentUserId, arg2: initOffset); } ) ); } else { var enablePullUp = this.widget.viewModel.hottestHasMore; content = new CustomListView( controller: this._refreshController, enablePullDown: true, enablePullUp: enablePullUp, onRefresh: this._onRefresh, hasBottomMargin: true, itemCount: recommendArticleIds.Count, itemBuilder: this._buildArticleCard, footerWidget: enablePullUp ? null : new EndView(hasBottomMargin: true), hasScrollBar: false ); } return(new CustomScrollbar(child: content)); }
public override Widget build(BuildContext context) { if (this.tipMenuItems == null || this.tipMenuItems.Count == 0) { return(this.child); } return(new GestureDetector( onLongPress: () => { var height = MediaQuery.of(context: context).size.height; var renderBox = (RenderBox)this._tipMenuKey.currentContext.findRenderObject(); var position = renderBox.localToGlobal(point: Offset.zero); ArrowDirection arrowDirection; if (position.dy > 44 + CCommonUtils.getSafeAreaTopPadding(context: context) + CustomTextSelectionControlsUtils._kToolbarTriangleSize.height + this._getTipMenuHeight(context: context)) { arrowDirection = ArrowDirection.down; } else if (position.dy + renderBox.size.height < height - 44) { position = new Offset(dx: position.dx, position.dy + renderBox.size.height); arrowDirection = ArrowDirection.up; } else { position = new Offset(dx: position.dx, height / 2.0f); arrowDirection = ArrowDirection.up; } // var position = renderBox.localToGlobal(new Offset(0, dy: renderBox.size.height)); this._createTipMenu( context: context, arrowDirection: arrowDirection, position: position, size: renderBox.size ); }, child: new Container( key: this._tipMenuKey, child: this.child ) )); }
Widget _buildTopView(BuildContext context) { return(new Flexible( child: new Stack( children: new List <Widget> { new Positioned( top: CCommonUtils.getSafeAreaTopPadding(context: context), left: 0, child: new CustomButton( padding: EdgeInsets.symmetric(10, 16), onPressed: () => this.widget.actionModel.mainRouterPop(), child: new Icon( icon: Icons.close, size: 24, color: CColors.White ) ) ), new Align( alignment: Alignment.center, child: new Container( height: 78, child: new Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { new Container( width: 251, height: 53, child: Image.asset( "image/img-logo-unity-connect-white-with-shadow@4x", fit: BoxFit.cover ) ), new Text( "Unity 问 题 全 搞 定", maxLines: 1, style: CTextStyle.H5.copyWith(color: CColors.White, height: 1) ) } ) ) ) } ) )); }
public override Widget build(BuildContext context) { base.build(context: context); return(new Container( padding: EdgeInsets.only(top: CCommonUtils.getSafeAreaTopPadding(context: context)), color: CColors.White, child: new NotificationListener <ScrollNotification>( onNotification: this._onNotification, child: new Column( children: new List <Widget> { this._buildNavigationBar(), this._buildContent() } ) ) )); }
Widget _buildUserCard(BuildContext context, int index) { var searchUserIds = this.widget.viewModel.searchUserIds; var searchUserId = searchUserIds[index : index]; if (!this.widget.viewModel.userDict.ContainsKey(key: searchUserId)) { return(new Container()); } var searchUser = this.widget.viewModel.userDict[key : searchUserId]; UserType userType = UserType.unFollow; if (!this.widget.viewModel.isLoggedIn) { userType = UserType.unFollow; } else { if (this.widget.viewModel.currentUserId == searchUser.id) { userType = UserType.me; } else if (searchUser.followUserLoading ?? false) { userType = UserType.loading; } else if (this.widget.viewModel.followMap.ContainsKey(key: searchUser.id)) { userType = UserType.follow; } } return(new UserCard( user: searchUser, CCommonUtils.GetUserLicense(userId: searchUser.id, userLicenseMap: this.widget.viewModel.userLicenseDict), () => this.widget.actionModel.pushToUserDetail(obj: searchUser.id), userType: userType, () => this._onFollow(userType: userType, userId: searchUser.id), true, new ObjectKey(value: searchUser.id) )); }
public override Widget build(BuildContext context) { Widget content; if (this.widget.viewModel.userLoading && this.widget.viewModel.user == null) { content = new GlobalLoading(); } else if (this.widget.viewModel.user == null || this.widget.viewModel.user.errorCode == "ResourceNotFound") { content = new BlankView( "用户不存在", "image/default-following" ); } else { content = this._buildUserContent(context: context); } return(new Container( color: CColors.White, child: new CustomSafeArea( top: false, bottom: false, child: new Stack( children: new List <Widget> { content, this._buildNavigationBar(context: context), new Positioned( left: 0, top: navBarHeight + CCommonUtils.getSafeAreaTopPadding(context: context), right: 0, child: new Offstage( offstage: !this._isShowTop, child: this._buildUserArticleTitle() ) ) } ) ) )); }
void _showLeaderBoardDialog(Rect rect, List <KingKongType> kingKongTypes) { PreferencesManager.updateKingKongType(type: KingKongType.leaderBoard); CustomDialogUtils.showCustomDialog( child: new Bubble( "榜单上线,合辑、专栏、博主在这里哦", rect.width / 8.0f + rect.width / 4.0f, rect.bottom - 16 - CCommonUtils.getSafeAreaTopPadding(context: this.context), contentRight: 16 ), barrierDismissible: true, onPop: () => { if (!kingKongTypes.Contains(item: KingKongType.blogger)) { this._showBloggerDialog(rect: rect); } } ); }
void _showDailyCollectionDialog(Rect rect, List <KingKongType> kingKongTypes) { PreferencesManager.updateKingKongType(type: KingKongType.dailyCollection); CustomDialogUtils.showCustomDialog( child: new Bubble( "每日精选1篇文章,记得查看哦", rect.width / 8.0f, rect.bottom - 16 - CCommonUtils.getSafeAreaTopPadding(context: this.context), 16 ), barrierDismissible: true, onPop: () => { if (!kingKongTypes.Contains(item: KingKongType.leaderBoard)) { this._showLeaderBoardDialog(rect: rect, kingKongTypes: kingKongTypes); } } ); }
Widget _buildContent(BuildContext context) { return(new GestureDetector( onTap: () => { if (this._emailFocusNode.hasFocus) { this._emailFocusNode.unfocus(); } if (this._passwordFocusNode.hasFocus) { this._passwordFocusNode.unfocus(); } }, child: new Container( padding: EdgeInsets.only(top: CCommonUtils.getSafeAreaTopPadding(context: context)), decoration: new BoxDecoration( gradient: new LinearGradient( colors: new List <Color> { new Color(0xFFF7FBFF), new Color(0xFFEAF5FD) }, begin: Alignment.topLeft, end: Alignment.bottomRight ) ), child: new Column( children: new List <Widget> { this._buildTopView(), this._buildMiddleView(context: context), this._buildBottomView() } ) ) )); }
Widget _buildEventBottom(IEvent eventObj, EventType eventType, EventStatus eventStatus, bool isLoggedIn, BuildContext context) { if (!WechatPlugin.instance().isInstalled() || eventType == EventType.offline) { return(new Container()); } return(new Container( height: 56 + CCommonUtils.getSafeAreaBottomPadding(context: context), padding: EdgeInsets.only(16, 8, 16, 8 + CCommonUtils.getSafeAreaBottomPadding(context: context)), decoration: new BoxDecoration( color: CColors.White, border: new Border(new BorderSide(color: CColors.Separator)) ), child: new CustomButton( onPressed: () => { CustomDialogUtils.showCustomDialog( barrierColor: Color.fromRGBO(0, 0, 0, 0.5f), child: new CustomAlertDialog( "即将前往微信小程序开始观看", null, new List <Widget> { new CustomButton( child: new Text( "稍后再说", style: new TextStyle( height: 1.33f, fontSize: 16, fontFamily: "Roboto-Regular", color: new Color(0xFF959595) ), textAlign: TextAlign.center ), onPressed: CustomDialogUtils.hiddenCustomDialog ), new CustomButton( child: new Text( "立即前往", style: CTextStyle.PLargeBlue, textAlign: TextAlign.center ), onPressed: () => { CustomDialogUtils.hiddenCustomDialog(); WechatPlugin.instance().context = this.context; WechatPlugin.instance().currentEventId = eventObj.id; var path = CStringUtils.CreateMiniPath(id: eventObj.id, title: eventObj.title); if (path.isNotEmpty()) { WechatPlugin.instance().toOpenMiNi(path); } } ) } ) ); }, padding: EdgeInsets.zero, child: new Container( decoration: new BoxDecoration( color: CColors.PrimaryBlue, borderRadius: BorderRadius.all(4) ), child: new Row( mainAxisAlignment: MainAxisAlignment.center, children: new List <Widget> { new Text( "进入微信小程序", style: CTextStyle.PLargeMediumWhite.merge(new TextStyle(height: 1)) ) } ) ) ) )); }
Widget _buildHeadTop(RankData game, BuildContext context) { Widget titleWidget = new Container(); Widget playButton = new Container(); if (this._isHaveTitle) { titleWidget = new Text( game.resetTitle, style: CTextStyle.PXLargeMedium, maxLines: 1, overflow: TextOverflow.ellipsis, textAlign: TextAlign.left ); playButton = _buildPlayButton(game: game); } return(new AnimatedContainer( height: 44 + CCommonUtils.getSafeAreaTopPadding(context: context), duration: TimeSpan.Zero, padding: EdgeInsets.only(8, right: 8, top: CCommonUtils.getSafeAreaTopPadding(context: context)), decoration: new BoxDecoration( CColors.White, border: new Border( bottom: new BorderSide(this._isHaveTitle ? CColors.Separator2 : CColors.Transparent)), gradient: this._showNavBarShadow ? new LinearGradient( colors: new List <Color> { new Color(0x80000000), new Color(0x0) }, begin: Alignment.topCenter, end: Alignment.bottomCenter ) : null ), child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { new CustomButton( onPressed: () => this.widget.actionModel.mainRouterPop(), child: new Icon( Icons.arrow_back, size: 24, color: this._showNavBarShadow ? CColors.White : CColors.Icon ) ), new Expanded( child: new Stack( fit: StackFit.expand, children: new List <Widget> { new PositionedTransition( rect: this._animation, child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { titleWidget, playButton } ) ) } ) ) } ) )); }
Widget _buildOfflineRegisterNow(IEvent eventObj, bool isLoggedIn, EventStatus eventStatus, BuildContext context) { if (eventObj.type.isNotEmpty() && !(eventObj.type == "bagevent" || eventObj.type == "customize")) { return(new Container()); } var buttonText = "立即报名"; var backgroundColor = CColors.PrimaryBlue; var isEnabled = true; if (eventStatus == EventStatus.past) { buttonText = "已结束"; backgroundColor = CColors.Disable; isEnabled = false; } return(new Container( height: 56 + CCommonUtils.getSafeAreaBottomPadding(context: context), padding: EdgeInsets.only(16, 8, 16, 8 + CCommonUtils.getSafeAreaBottomPadding(context: context)), decoration: new BoxDecoration( CColors.White, border: new Border(new BorderSide(CColors.Separator)) ), child: new CustomButton( onPressed: () => { if (!isEnabled) { return; } if (isLoggedIn && eventObj.type.isNotEmpty()) { if (eventObj.type == "bagevent") { this.widget.actionModel.openUrl( $"{Config.unity_com_url}/events/{eventObj.id}/purchase"); } else if (eventObj.type == "customize" && eventObj.typeParam.isNotEmpty()) { this.widget.actionModel.openUrl(eventObj.typeParam); } } else { this.widget.actionModel.pushToLogin(); } }, padding: EdgeInsets.zero, child: new Container( decoration: new BoxDecoration( backgroundColor, borderRadius: BorderRadius.all(4) ), child: new Row( mainAxisAlignment: MainAxisAlignment.center, children: new List <Widget> { new Text( buttonText, style: CTextStyle.PLargeMediumWhite ) } ) ) ) )); }
Widget _buildHeadTop(IEvent eventObj, BuildContext context) { Widget shareWidget = new CustomButton( onPressed: () => ActionSheetUtils.showModalActionSheet(new ShareView( projectType: ProjectType.iEvent, onPressed: type => { AnalyticsManager.ClickShare(type, "Event", "Event_" + eventObj.id, eventObj.title); var linkUrl = CStringUtils.JointEventShareLink(eventId: eventObj.id); if (type == ShareType.clipBoard) { this.widget.actionModel.copyText(linkUrl); CustomDialogUtils.showToast("复制链接成功", Icons.check_circle_outline); } else { var imageUrl = CImageUtils.SizeTo200ImageUrl(eventObj.avatar); CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); this.widget.actionModel.shareToWechat(type, eventObj.title, eventObj.shortDescription, linkUrl, imageUrl, null).Then(CustomDialogUtils.hiddenCustomDialog) .Catch(_ => CustomDialogUtils.hiddenCustomDialog()); } })), child: new Container( color: CColors.Transparent, child: new Icon(Icons.share, size: 24, color: this._showNavBarShadow ? CColors.White : CColors.Icon)) ); Widget titleWidget = new Container(); if (this._isHaveTitle) { titleWidget = new Text( eventObj.title, style: CTextStyle.PXLargeMedium, maxLines: 1, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center ); } return(new AnimatedContainer( height: 44 + CCommonUtils.getSafeAreaTopPadding(context: context), duration: TimeSpan.Zero, padding: EdgeInsets.only(8, right: 8, top: CCommonUtils.getSafeAreaTopPadding(context: context)), decoration: new BoxDecoration( CColors.White, border: new Border( bottom: new BorderSide(this._isHaveTitle ? CColors.Separator2 : CColors.Transparent)), gradient: this._showNavBarShadow ? new LinearGradient( colors: new List <Color> { new Color(0x80000000), new Color(0x0) }, begin: Alignment.topCenter, end: Alignment.bottomCenter ) : null ), child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { new CustomButton( onPressed: () => this.widget.actionModel.mainRouterPop(), child: new Icon( Icons.arrow_back, size: 24, color: this._showNavBarShadow ? CColors.White : CColors.Icon ) ), new Expanded( child: new Stack( fit: StackFit.expand, children: new List <Widget> { new PositionedTransition( rect: this._animation, child: titleWidget ) } ) ), shareWidget } ) )); }
Widget _buildLecture(User host) { if (host == null) { return(new Container()); } return(new Container( padding: EdgeInsets.symmetric(horizontal: 16), margin: EdgeInsets.only(bottom: 24), color: CColors.White, child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new GestureDetector( onTap: () => this.pushToUserDetail(obj: host.id), child: new Row( children: new List <Widget> { new Container( margin: EdgeInsets.only(right: 8), child: Avatar.User(user: host, 48) ), new Flexible( child: new Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Row( children: new List <Widget> { new Flexible( child: new Text( host.fullName ?? host.name ?? "", maxLines: 1, style: new TextStyle( color: CColors.TextBody, height: 1, fontFamily: "Roboto-Medium", fontSize: 16 ), overflow: TextOverflow.ellipsis ) ), CImageUtils.GenBadgeImage( badges: host.badges, CCommonUtils.GetUserLicense( userId: host.id, userLicenseMap: this.userLicenseDict ), EdgeInsets.only(4) ) } ), host.title.isNotEmpty() ? new Container( child: new Text( data: host.title, maxLines: 1, overflow: TextOverflow.ellipsis, style: CTextStyle.PRegularBody3 ) ) : new Container() } ) ) } ) ), new Container( margin: EdgeInsets.only(top: 8), child: new Text( data: host.description, style: new TextStyle( color: CColors.TextBody3, fontFamily: "Roboto-Regular", fontSize: 16 ) ) ) } ) )); }
Widget _buildContentHead() { var user = this.eventObj.user ?? new User(); return(new Container( padding: EdgeInsets.symmetric(horizontal: 16), margin: EdgeInsets.only(top: 16, bottom: 20), child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Text( this.eventObj.title ?? "", this.titleKey, style: CTextStyle.H4 ), new Container( margin: EdgeInsets.only(top: 20), child: new Row( children: new List <Widget> { new Container( margin: EdgeInsets.only(right: 8), child: new GestureDetector( onTap: () => this.pushToUserDetail(user.id), child: Avatar.User(user, 32) ) ), new Expanded( child: new Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new GestureDetector( onTap: () => this.pushToUserDetail(user.id), child: new Row( children: new List <Widget> { new Flexible( child: new Text( user.fullName ?? user.name ?? "", style: CTextStyle.PMediumBody.merge( new TextStyle(height: 1)), maxLines: 1, overflow: TextOverflow.ellipsis ) ), CImageUtils.GenBadgeImage( badges: user.badges, CCommonUtils.GetUserLicense( userId: user.id, userLicenseMap: this.userLicenseDict ), EdgeInsets.only(4) ) } ) ), new Text( $"{DateConvert.DateStringFromNow(this.eventObj.createdTime ?? DateTime.Now)}发布", style: CTextStyle.PSmallBody3 ) } ) ) } ) ) } ) )); }
Widget _buildArticleList(BuildContext context) { Widget content; var recommendArticleIds = this.widget.viewModel.recommendArticleIds; if (!this._hasBeenLoadedData || this.widget.viewModel.articlesLoading && recommendArticleIds.isEmpty()) { content = ListView.builder( physics: new NeverScrollableScrollPhysics(), itemCount: 6, itemBuilder: (cxt, index) => new ArticleLoading() ); } else if (0 == recommendArticleIds.Count) { content = new Container( padding: EdgeInsets.only(bottom: CConstant.TabBarHeight + CCommonUtils.getSafeAreaBottomPadding(context: context)), child: new BlankView( "哎呀,暂无推荐文章", "image/default-article", true, () => { this.widget.actionModel.startFetchArticles(); this.widget.actionModel.fetchArticles(arg: initOffset); } ) ); } else { content = new SmartRefresher( controller: this._refreshController, enablePullDown: true, enablePullUp: this.widget.viewModel.hottestHasMore, onRefresh: this._onRefresh, hasBottomMargin: true, child: ListView.builder( physics: new AlwaysScrollableScrollPhysics(), itemCount: recommendArticleIds.Count, itemBuilder: (cxt, index) => { var articleId = recommendArticleIds[index: index]; if (this.widget.viewModel.blockArticleList.Contains(item: articleId)) { return(new Container()); } if (!this.widget.viewModel.articleDict.ContainsKey(key: articleId)) { return(new Container()); } if (!this.widget.viewModel.hottestHasMore && recommendArticleIds.Count > 0 && index + 1 == recommendArticleIds.Count) { return(new EndView(hasBottomMargin: true)); } var article = this.widget.viewModel.articleDict[key: articleId]; var fullName = ""; var userId = ""; if (article.ownerType == OwnerType.user.ToString()) { userId = article.userId; if (this.widget.viewModel.userDict.ContainsKey(key: article.userId)) { fullName = this.widget.viewModel.userDict[key: article.userId].fullName ?? this.widget.viewModel.userDict[key: article.userId].name; } } if (article.ownerType == OwnerType.team.ToString()) { userId = article.teamId; if (this.widget.viewModel.teamDict.ContainsKey(key: article.teamId)) { fullName = this.widget.viewModel.teamDict[key: article.teamId].name; } } var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id); return(new ArticleCard( article: article, () => { this.widget.actionModel.pushToArticleDetail(obj: articleId); AnalyticsManager.ClickEnterArticleDetail("Home_Article", articleId: article.id, articleTitle: article.title); }, () => ShareManager.showArticleShareView( this.widget.viewModel.currentUserId != userId, isLoggedIn: this.widget.viewModel.isLoggedIn, () => { Clipboard.setData(new ClipboardData(text: linkUrl)); CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline); }, () => this.widget.actionModel.pushToLogin(), () => this.widget.actionModel.pushToBlock(obj: article.id), () => this.widget.actionModel.pushToReport(arg1: article.id, arg2: ReportType.article), type => { CustomDialogUtils.showCustomDialog( child: new CustomLoadingDialog() ); string imageUrl = CImageUtils.SizeTo200ImageUrl(article.thumbnail.url); this.widget.actionModel.shareToWechat(arg1: type, arg2: article.title, arg3: article.subTitle, arg4: linkUrl, arg5: imageUrl) .Then(onResolved: CustomDialogUtils.hiddenCustomDialog) .Catch(_ => CustomDialogUtils.hiddenCustomDialog()); } ), fullName: fullName, key: new ObjectKey(value: article.id) )); } ) ); } if (this.widget.viewModel.isLoggedIn) { return(new Container( color: CColors.Background, child: new CustomScrollbar(child: content) )); } return(new NotificationListener <ScrollNotification>( onNotification: this._onNotification, child: new Container( color: CColors.Background, child: new CustomScrollbar(child: content) ) )); }