Example #1
0
 public static HeaderViewModel MakeHeaderViewModel(ApplicationState state)
 {
     return new HeaderViewModel
     {
         CompleteAllIsChecked = state.Todos.All(x => x.IsCompleted),
         CompleteAllIsVisible = state.Todos.Any()
     };
 }
Example #2
0
        public MainActivity()
        {
            var initialState = new ApplicationState
            {
                Todos = ImmutableArray<Todo>.Empty,
                Filter = TodosFilter.All
            };

            Store = new Store<ApplicationState>(initialState, ApplicationReducer.Execute);
        }
Example #3
0
 public static FooterViewModel MakeFooterViewModel(ApplicationState state)
 {
     return new FooterViewModel
     {
         ClearTodosIsVisible = state.Todos.Any(todo => todo.IsCompleted),
         ActiveTodosCounterMessage = GetActiveTodosCounterMessage(state.Todos),
         SelectedFilter = state.Filter,
         AreFiltersVisible = state.Todos.Any()
     };
 }
Example #4
0
        public App()
        {
            InitializeComponent();

            var initialState = new ApplicationState
            {
                Todos = ImmutableArray<Todo>.Empty,
                Filter = TodosFilter.All
            };

            //Store = new Store<ApplicationState>(initialState, Reducers.ReduceApplication);
            Store = new TimeMachineStore<ApplicationState>(initialState, Reducers.ReduceApplication);
        }
Example #5
0
        public static IEnumerable<Todo> GetFilteredTodos(ApplicationState state)
        {
            if (state.Filter == TodosFilter.Completed)
            {
                return state.Todos.Where(x => x.IsCompleted);
            }

            if (state.Filter == TodosFilter.InProgress)
            {
                return state.Todos.Where(x => !x.IsCompleted);
            }

            return state.Todos;
        }
Example #6
0
        public App()
        {
            var initialState = new ApplicationState
            {
                Todos = ImmutableArray<Todo>.Empty,
                Filter = TodosFilter.All
            };

            var masterDetail = new MasterDetailPage();

            Store = new Store<ApplicationState>(initialState, Reducers.ReduceApplication);

            masterDetail.Detail =
                new NavigationPage(
                    new MainPage() { Title = "Todo List" }
                );

            MainPage = masterDetail;
        }
Example #7
0
 public static ApplicationState Execute(ApplicationState previousState, IAction action)
 {
     return new ApplicationState
     {
         Filter = action is FilterTodosAction ? ((FilterTodosAction)action).Filter : previousState.Filter,
         Todos = TodosReducer(previousState.Todos, action)
     };
 }