Пример #1
0
 public ChannelMentionScreen(
     ChannelMentionScreenViewModel viewModel     = null,
     ChannelMentionScreenActionModel actionModel = null,
     Key key = null
     ) : base(key: key)
 {
     this.viewModel   = viewModel;
     this.actionModel = actionModel;
 }
Пример #2
0
        public override Widget build(BuildContext context)
        {
            return(new StoreConnector <AppState, ChannelMentionScreenViewModel>(
                       converter: state => {
                var channel = state.channelState.channelDict[key: this.channelId];
                var memberDict = new Dictionary <string, ChannelMember>();
                foreach (var memberKey in channel.memberIds)
                {
                    if (channel.membersDict.ContainsKey(memberKey))
                    {
                        memberDict[memberKey] = channel.membersDict[memberKey];
                    }
                }

                return new ChannelMentionScreenViewModel {
                    channelMembers = memberDict,
                    me = state.loginState.loginInfo.userId,
                    currentMember = channel.currentMember,
                    mentionSuggestions =
                        state.channelState.mentionSuggestions.getOrDefault(key: this.channelId, null),
                    userDict = state.userState.userDict,
                    mentionLoading = state.channelState.mentionLoading,
                    lastMentionQuery = state.channelState.lastMentionQuery,
                    mentionSearching = state.channelState.mentionSearching,
                    queryMentions = state.channelState.queryMentions
                };
            },
                       builder: (context1, viewModel, dispatcher) => {
                var actionModel = new ChannelMentionScreenActionModel {
                    mainRouterPop = () => dispatcher.dispatch(new MainNavigatorPopAction()),
                    chooseMentionCancel = () => {
                        dispatcher.dispatch(new ChannelChooseMentionCancelAction());
                        dispatcher.dispatch(new MainNavigatorPopAction());
                    },
                    chooseMentionConfirm = (mentionUserId, mentionUserName) => {
                        dispatcher.dispatch(new ChannelChooseMentionConfirmAction {
                            mentionUserId = mentionUserId,
                            mentionUserName = mentionUserName
                        });
                        dispatcher.dispatch(new MainNavigatorPopAction());
                    },
                    startLoadingMention = () => {
                        dispatcher.dispatch(new StartFetchChannelMentionSuggestionAction());
                        dispatcher.dispatch <IPromise>(
                            Actions.fetchChannelMentionSuggestions(channelId: this.channelId));
                    },
                    startQueryMention = query => {
                        dispatcher.dispatch(new StartSearchChannelMentionSuggestionAction());
                        dispatcher.dispatch <IPromise>(
                            Actions.queryChannelMentionSuggestions(channelId: this.channelId, query: query));
                    },
                    updateMentionQuery = query => {
                        dispatcher.dispatch(new ChannelUpdateMentionQueryAction {
                            mentionQuery = query
                        });
                    },
                    clearQueryMention = () => { dispatcher.dispatch(new ChannelClearMentionQueryAction()); }
                };
                return new ChannelMentionScreen(viewModel: viewModel, actionModel: actionModel);
            }
                       ));
        }