Exemplo n.º 1
0
 public override Widget build(BuildContext context)
 {
     return(new StoreConnector <AppState, EventDetailScreenViewModel>(
                converter: state => new EventDetailScreenViewModel {
         eventId = this.eventId,
         isLoggedIn = state.loginState.isLoggedIn,
         eventDetailLoading = state.eventState.eventDetailLoading,
         joinEventLoading = state.eventState.joinEventLoading,
         channelId = state.eventState.channelId,
         eventsDict = state.eventState.eventsDict
     },
                builder: (context1, viewModel, dispatcher) => {
         var actionModel = new EventDetailScreenActionModel {
             mainRouterPop = () => dispatcher.dispatch(new MainNavigatorPopAction()),
             pushToLogin = () => dispatcher.dispatch(new MainNavigatorPushToAction {
                 routeName = MainNavigatorRoutes.Login
             }),
             openUrl = url => dispatcher.dispatch(new MainNavigatorPushToWebViewAction {
                 url = url
             }),
             copyText = text => dispatcher.dispatch(new CopyTextAction {
                 text = text
             }),
             startFetchEventDetail = () => dispatcher.dispatch(new StartFetchEventDetailAction()),
             fetchEventDetail = (id, eventType) =>
                                dispatcher.dispatch <IPromise>(Actions.fetchEventDetail(id, eventType)),
             startJoinEvent = () => dispatcher.dispatch(new StartJoinEventAction()),
             joinEvent = id => dispatcher.dispatch <IPromise>(Actions.joinEvent(id)),
             shareToWechat = (type, title, description, linkUrl, imageUrl) => dispatcher.dispatch <IPromise>(
                 Actions.shareToWechat(type, title, description, linkUrl, imageUrl))
         };
         return new EventOfflineDetailScreen(viewModel, actionModel);
     }
                ));
 }
 public EventOfflineDetailScreen(
     EventDetailScreenViewModel viewModel     = null,
     EventDetailScreenActionModel actionModel = null,
     Key key = null
     ) : base(key: key)
 {
     this.viewModel   = viewModel;
     this.actionModel = actionModel;
 }
        public override Widget build(BuildContext context)
        {
            return(new StoreConnector <AppState, EventDetailScreenViewModel>(
                       converter: state => {
                var channelId = state.eventState.channelId;
                var channelMessageList = state.messageState.channelMessageList;
                var messageList = new List <string>();
                if (channelMessageList.ContainsKey(channelId))
                {
                    messageList = channelMessageList[channelId];
                }

                return new EventDetailScreenViewModel {
                    eventId = this.eventId,
                    currOldestMessageId = state.messageState.currOldestMessageId,
                    isLoggedIn = state.loginState.isLoggedIn,
                    eventDetailLoading = state.eventState.eventDetailLoading,
                    joinEventLoading = state.eventState.joinEventLoading,
                    showChatWindow = state.eventState.showChatWindow,
                    channelId = state.eventState.channelId,
                    messageList = messageList,
                    messageLoading = state.messageState.messageLoading,
                    hasMore = state.messageState.hasMore,
                    sendMessageLoading = state.messageState.sendMessageLoading,
                    channelMessageDict = state.messageState.channelMessageDict,
                    eventsDict = state.eventState.eventsDict,
                    userLicenseDict = state.userState.userLicenseDict
                };
            },
                       builder: (context1, viewModel, dispatcher) => {
                var actionModel = new EventDetailScreenActionModel {
                    mainRouterPop = () => dispatcher.dispatch(new MainNavigatorPopAction()),
                    pushToLogin = () => dispatcher.dispatch(new MainNavigatorPushToAction {
                        routeName = MainNavigatorRoutes.Login
                    }),
                    pushToUserDetail = userId => {
                        dispatcher.dispatch(
                            new MainNavigatorPushToUserDetailAction {
                            userId = userId
                        }
                            );
                    },
                    openUrl = url => { OpenUrlUtil.OpenUrl(url, dispatcher); },
                    browserImage = url => {
                        dispatcher.dispatch(new MainNavigatorPushToPhotoViewAction {
                            urls = ContentDescription.imageUrls,
                            url = url
                        });
                    },
                    copyText = text => dispatcher.dispatch(new CopyTextAction {
                        text = text
                    }),
                    startFetchEventDetail = () => dispatcher.dispatch(new StartFetchEventDetailAction()),
                    fetchEventDetail = (id, eventType) =>
                                       dispatcher.dispatch <IPromise>(Actions.fetchEventDetail(id, eventType)),
                    startSendMessage = () => dispatcher.dispatch(new StartSendMessageAction()),
                    sendMessage = (channelId, content, nonce, parentMessageId) => dispatcher.dispatch <IPromise>(
                        Actions.sendMessage(channelId, content, nonce, parentMessageId)),
                    showChatWindow = show => dispatcher.dispatch(new ShowChatWindowAction {
                        show = show
                    }),
                    startFetchMessages = () => dispatcher.dispatch(new StartFetchMessagesAction()),
                    fetchMessages = (channelId, currOldestMessageId, isFirstLoad) =>
                                    dispatcher.dispatch <IPromise>(
                        Actions.fetchMessages(channelId, currOldestMessageId, isFirstLoad)
                        ),
                    shareToWechat = (type, title, description, linkUrl, imageUrl, path) =>
                                    dispatcher.dispatch <IPromise>(
                        Actions.shareToWechat(type, title, description, linkUrl, imageUrl, path, true))
                };
                return new EventOnlineDetailScreen(viewModel, actionModel);
            }
                       ));
        }