Esempio n. 1
0
        public App()
        {
            InitializeComponent();

            Store.RegisterEffects(
                LyraWallet.States.Effects.CreateWalletEffect,
                LyraWallet.States.Effects.OpenWalletEffect,
                LyraWallet.States.Effects.OpenWalletAndSyncEffect,
                LyraWallet.States.Effects.RestoreWalletEffect,
                LyraWallet.States.Effects.RemoveWalletEffect,
                LyraWallet.States.Effects.ChangeVoteWalletEffect,
                LyraWallet.States.Effects.RefreshWalletEffect,
                LyraWallet.States.Effects.SendTokenWalletEffect,
                LyraWallet.States.Effects.CreateTokenWalletEffect,
                LyraWallet.States.Effects.ImportWalletEffect,
                LyraWallet.States.Effects.RedeemWalletEffect,
                LyraWallet.States.Effects.NonFungibleTokenWalletEffect
                );

            WalletPassword wp;
            // check default wallet exists.
            var path = DependencyService.Get <IPlatformSvc>().GetStoragePath();
            var fn   = $"{path}/default.lyrawallet";

            if (File.Exists(fn))
            {
                wp = new WalletPassword(true);
            }
            else
            {
                wp = new WalletPassword(false);
            }
            wp.Path  = path;
            MainPage = new NavigationPage(wp);
        }
Esempio n. 2
0
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            var rootFrame = (Window.Current.Content as Frame).ToOption()
                            .Match <Frame>()
                            .None().Do(() =>
            {
                var newFrame           = CreateNewFrame(e.PreviousExecutionState);
                Window.Current.Content = newFrame;
                return(newFrame);
            })
                            .Some().Do(f => f)
                            .Result();

            // Enable router store feature
            Store.EnableRouterFeature(rootFrame);

            // Register Effects
            Store.RegisterEffects(
                TrackAction
                );

            if (!e.PrelaunchActivated)
            {
                var rootFrameContentOption = rootFrame.Content.ToOption();

                if (!rootFrameContentOption.HasValue)
                {
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }

                Window.Current.Activate();
            }
        }
        public static IServiceCollection AddRedux(this IServiceCollection services)
        {
            services.AddScoped(sp =>
            {
                var store   = new ReduxStore <MovieSearchState>(MovieSearchReducers.CreateReducers());
                var effects = new MovieSearchEffects(store, sp.GetService <IOmdbMovieService>());
                store.RegisterEffects(effects.SearchMovies);

                return(store);
            });

            return(services);
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            //ConfigureFilters(global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory);
            this.UnhandledException += App_UnhandledException;

            this.InitializeComponent();
            this.Suspending += OnSuspending;

            Store.RegisterEffects(
                LyraWallet.States.Effects.CreateWalletEffect,
                LyraWallet.States.Effects.OpenWalletEffect,
                LyraWallet.States.Effects.OpenWalletAndSyncEffect,
                LyraWallet.States.Effects.RestoreWalletEffect,
                LyraWallet.States.Effects.RemoveWalletEffect,
                LyraWallet.States.Effects.ChangeVoteWalletEffect,
                LyraWallet.States.Effects.RefreshWalletEffect,
                LyraWallet.States.Effects.GetTxHistoryEffect,
                LyraWallet.States.Effects.SendTokenWalletEffect,
                LyraWallet.States.Effects.CreateTokenWalletEffect,
                LyraWallet.States.Effects.ImportWalletEffect,
                LyraWallet.States.Effects.RedeemWalletEffect,
                LyraWallet.States.Effects.NonFungibleTokenWalletEffect
                );
        }
Esempio n. 5
0
        public static void EnableRouterFeature <TState>(this ReduxStore <TState> store, Frame rootFrame)
            where TState : class, IBaseRouterState, new()
        {
            // TODO : Find children frame in the current one for multi-layer navigation?

            // Add router navigation reducers
            var routerReducers = new[]
            {
                On <RouterNavigating, RouterState>(
                    (state, action) => state.With(new
                {
                    rootFrame.CanGoBack,
                    rootFrame.CanGoForward,
                })
                    ),
                On <RouterNavigated, RouterState>(
                    (state, action) => state.With(new
                {
                    rootFrame.CanGoBack,
                    rootFrame.CanGoForward,
                })
                    ),
                On <RouterError, RouterState>(
                    (state, action) => state.With(new
                {
                    rootFrame.CanGoBack,
                    rootFrame.CanGoForward,
                })
                    ),
                On <RouterCancel, RouterState>(
                    (state, action) => state.With(new
                {
                    rootFrame.CanGoBack,
                    rootFrame.CanGoForward,
                })
                    )
            };

            var reducers = CreateSubReducers <TState, RouterState>(routerReducers, SelectRouter);

            store.AddReducers(reducers);

            // Listen to router events
            var navigatingEffect = CreateEffect <TState>(
                () => rootFrame.Events().Navigating
                .Select(@event =>
            {
                return(new RouterNavigating
                {
                    Event = @event
                });
            }),
                true
                );
            var navigatedEffect = CreateEffect <TState>(
                () => rootFrame.Events().Navigated
                .Select(@event =>
            {
                return(new RouterNavigated
                {
                    Event = @event
                });
            }),
                true
                );
            var navigationFailedEffect = CreateEffect <TState>(
                () => rootFrame.Events().NavigationFailed
                .Select(@event =>
            {
                return(new RouterError
                {
                    Event = @event
                });
            }),
                true
                );
            var navigationStoppedEffect = CreateEffect <TState>(
                () => rootFrame.Events().NavigationStopped
                .Select(@event =>
            {
                return(new RouterCancel
                {
                    Event = @event
                });
            }),
                true
                );

            // Add router navigation effects
            store.RegisterEffects(
                navigatingEffect,
                navigatedEffect,
                navigationFailedEffect,
                navigationStoppedEffect
                );
        }
Esempio n. 6
0
        /// <summary>
        /// Enable the router feature to the specified store.
        /// </summary>
        /// <typeparam name="TState">Type of the state.</typeparam>
        /// <param name="store">Store used to store router information.</param>
        /// <param name="rootFrame">The root frame of the UWP application.</param>
        public static void EnableRouterFeature <TState>(this ReduxStore <TState> store, Frame rootFrame)
            where TState : class, IBaseRouterState, new()
        {
            // TODO : Find children frame in the current one for multi-layer navigation?

            // Add router navigation reducers
            var routerReducers = new[]
            {
                On <RouterNavigatingAction, RouterState>(
                    (state, action) => state.With(new
                {
                    rootFrame.CanGoBack,
                    rootFrame.CanGoForward,
                })
                    ),
                On <RouterNavigatedAction, RouterState>(
                    (state, action) => state.With(new
                {
                    rootFrame.CanGoBack,
                    rootFrame.CanGoForward,
                })
                    ),
                On <RouterErrorAction, RouterState>(
                    (state, action) => state.With(new
                {
                    rootFrame.CanGoBack,
                    rootFrame.CanGoForward,
                })
                    ),
                On <RouterCancelAction, RouterState>(
                    (state, action) => state.With(new
                {
                    rootFrame.CanGoBack,
                    rootFrame.CanGoForward,
                })
                    )
            };

            var reducers = CreateSubReducers <TState, RouterState>(routerReducers, SelectRouter);

            store.AddReducers(reducers);

            // Listen to router events
            var navigatingEffect = CreateEffect <TState>(
                () => rootFrame.Events().Navigating
                .Select(@event =>
            {
                return(new RouterNavigatingAction
                {
                    Event = new RouterNavigatingEvent
                    {
                        Cancel = @event.Cancel,
                        NavigationMode = @event.NavigationMode,
                        Parameter = @event.Parameter,
                        SourcePageType = @event.SourcePageType
                    }
                });
            }),
                true
                );
            var navigatedEffect = CreateEffect <TState>(
                () => rootFrame.Events().Navigated
                .Select(@event =>
            {
                return(new RouterNavigatedAction
                {
                    Event = new RouterNavigatedEvent
                    {
                        ContentType = @event.Content?.GetType(),
                        SourcePageType = @event.SourcePageType,
                        NavigationMode = @event.NavigationMode,
                        Parameter = @event.Parameter,
                        Uri = @event.Uri
                    }
                });
            }),
                true
                );
            var navigationFailedEffect = CreateEffect <TState>(
                () => rootFrame.Events().NavigationFailed
                .Select(@event =>
            {
                return(new RouterErrorAction
                {
                    Event = new RouterErrorEvent
                    {
                        Exception = @event.Exception,
                        Handled = @event.Handled,
                        SourcePageType = @event.SourcePageType
                    }
                });
            }),
                true
                );
            var navigationStoppedEffect = CreateEffect <TState>(
                () => rootFrame.Events().NavigationStopped
                .Select(@event =>
            {
                return(new RouterCancelAction
                {
                    Event = new RouterCancelEvent
                    {
                        ContentType = @event.Content?.GetType(),
                        SourcePageType = @event.SourcePageType,
                        NavigationMode = @event.NavigationMode,
                        Parameter = @event.Parameter,
                        Uri = @event.Uri
                    }
                });
            }),
                true
                );

            // Add router navigation effects
            store.RegisterEffects(
                navigatingEffect,
                navigatedEffect,
                navigationFailedEffect,
                navigationStoppedEffect
                );
        }