Beispiel #1
0
        public RootTabPage()
        {
            InitializeComponent();
            Children.Add(new NavigationPage(new MainPage())
            {
                Title = "Top"
            });
            Children.Add(new NavigationPage(new VotePage())
            {
                Title = "Vote"
            });
            Children.Add(new NavigationPage(new PhotoPage())
            {
                Title = "Photo"
            });
            Children.Add(new NavigationPage(new UserPage())
            {
                Title = "User"
            });

            App.Store.Subscribe((ApplicationState state) =>
            {
                if (!state.CurrentUser.IsAuthenticated && state.NavigationState.CurrentPage != typeof(LoginPage))
                {
                    Debug.WriteLine("### NOT AUTHENTICATED GOIN TO LOGIN PAGE");
                    App.Store.Dispatch(ActionCreators.Push(Navigation, typeof(RootTabPage), typeof(LoginPage),
                                                           new LoginPage(), true, false));
                }
            });
        }
Beispiel #2
0
        private async void SearchRepositoriesTextBox_KeyUp(object sender, KeyRoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(SearchRepositoriesTextBox.Text))
            {
                return;
            }

            App.Store.Dispatch(await ActionCreators.SearchRepositories(SearchRepositoriesTextBox.Text));
        }
Beispiel #3
0
    void OnGUI()
    {
        var x    = 20;
        var y    = 40;
        var w    = 100;
        var h    = 30;
        var xgap = 10;
        var ygap = 10;

        if (GUI.Toggle(new Rect(x, y, w, h), this.visibilityFilter == "SHOW_ALL", "Show All"))
        {
            if (this.visibilityFilter != "SHOW_ALL")
            {
                this.store.dispatch(ActionCreators.setVisibilityFilter("SHOW_ALL"));
            }
        }
        x += w + xgap;
        if (GUI.Toggle(new Rect(x, y, w, h), this.visibilityFilter == "SHOW_ACTIVE", "Show Active"))
        {
            if (this.visibilityFilter != "SHOW_ACTIVE")
            {
                this.store.dispatch(ActionCreators.setVisibilityFilter("SHOW_ACTIVE"));
            }
        }
        x += w + xgap;
        if (GUI.Toggle(new Rect(x, y, w, h), this.visibilityFilter == "SHOW_COMPLETED", "Show Completed"))
        {
            if (this.visibilityFilter != "SHOW_COMPLETED")
            {
                this.store.dispatch(ActionCreators.setVisibilityFilter("SHOW_COMPLETED"));
            }
        }

        y        += h + ygap;
        x         = 20;
        w         = 100;
        h         = 30;
        todoTitle = GUI.TextField(new Rect(x, y, w, h), todoTitle);

        x += w + ygap;
        w  = 80;
        if (GUI.Button(new Rect(x, y, w, h), "Add TODO"))
        {
            if (todoTitle.Length > 0)
            {
                this.store.dispatch(ActionCreators.addTodo(todoTitle));
                todoTitle = "";
            }
        }

        y += h + ygap;
        x  = 20;
        w  = 100;
        h  = 20;
        for (int i = 0, len = this.todos.Length; i < len; ++i)
        {
            var todo = this.getVisibleTodo(todos [i]);
            if (todo == null)
            {
                continue;
            }
            var check = GUI.Toggle(new Rect(x, y, w, h), todo.completed, todo.text);
            if ((todo.completed && !check) || (!todo.completed && check))
            {
                this.store.dispatch(ActionCreators.toggleTodo(todo.id));
            }
            y += h + ygap;
        }

        x = 20;
        w = 200;
        h = 20;
        GUI.Label(new Rect(x, y, w, h), "Timeline (Action: " +
                  (this.timeline.monitoredStateIndex + 1) + "/" +
                  this.timeline.monitoredStates.Count + ")");

        y += h + ygap;
        x  = 300;
        w  = 20;
        if (GUI.Button(new Rect(x, y, w, h), "<"))
        {
            var i = this.timeline.monitoredStateIndex - 1;
            this.store.dispatch(Redux.Devtools.ActionCreators.jumpToState(i));
        }
        x += w + xgap;
        if (GUI.Button(new Rect(x, y, w, h), ">"))
        {
            var i = this.timeline.monitoredStateIndex + 1;
            if (i < this.timeline.monitoredStates.Count)
            {
                this.store.dispatch(Redux.Devtools.ActionCreators.jumpToState(i));
            }
        }

        y += h + ygap;
        x  = 20;
        w  = 300;
        var ret = GUI.HorizontalSlider(new Rect(x, y, w, h),
                                       this.timeline.monitoredStateIndex,
                                       0, this.timeline.monitoredStates.Count - 1);

        if (ret != this.timeline.monitoredStateIndex &&
            ret < this.timeline.monitoredStates.Count)
        {
            this.store.dispatch(Redux.Devtools.ActionCreators.jumpToState(
                                    Mathf.RoundToInt(ret)
                                    ));
        }
    }
Beispiel #4
0
 private async void SearchButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     await App.Store.Dispatch(ActionCreators.SearchRepositories(SearchRepositoriesTextBox.Text));
 }
 protected override async Task OnInitializedAsync()
 {
     //forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
     await ActionCreators.LoadWeather(Store.Dispatch, Http);
 }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("----------- Add reducers");

        var reducers = new Redux.Reducer[] {
            Reducers.sumResult,
            Reducers.multiplyResult
        };

//		var type = typeof (Reducers);
//		var methods = type.GetMethods (
//			System.Reflection.BindingFlags.NonPublic |
//			System.Reflection.BindingFlags.Public |
//			System.Reflection.BindingFlags.Static |
//			System.Reflection.BindingFlags.FlattenHierarchy);
//
//		var reducers = new List<Redux.Reducer> ();
//		foreach (var method in methods) {
//			if (method.DeclaringType.FullName == type.FullName) {
//				//reducers
//				Expression.Lambda<Redux.Reducer> (
//					Expression.Call (Expression.Convert (input, o.GetType ()), method), input).Compile ();
//			}
//		}

        this.store = Redux.createStore(
            Redux.combineReducers(reducers),
            null,
            Redux.applyMiddleware(new Redux.Middleware[] {
            ReduxMiddleware.createThunk,
            ReduxMiddleware.createLogger,
            ReduxMiddleware.createCrashReport
        })
            );

        Debug.Log("----------- Subscribe");

        var unsubscribe = this.store.subscribe(this.onChangeState);

        {
            Debug.Log("----------- Dispatch");

            this.store.dispatch(ActionCreators.sum(10, 20));
            this.store.dispatch(ActionCreators.multiply(10, 20));

            Debug.Log("----------- Remove reducers");

            Redux.removeReducers(new Redux.Reducer[] {
                Reducers.multiplyResult
            });

            Debug.Log("----------- Dispatch");

            try {
                this.store.dispatch(ActionCreators.sum(100, 200));
                this.store.dispatch(ActionCreators.multiply(100, 200));
            } catch (Redux.Error e) {
                Debug.LogError(e.Message);
            }
        }

        Debug.Log("----------- Unsubscribe");

        unsubscribe();
    }
Beispiel #7
0
 private void OnLoginBtnClicked(object sender, EventArgs e)
 {
     Debug.WriteLine("### Login Clicked");
     App.Store.Dispatch(ActionCreators.Login(Navigation, this, NameOrEmailEntry.Text, PasswordEntry.Text));
 }