/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.Portable.ViewModels.ViewModelBase"/> class. /// </summary> /// <param name="signalRClient">Signal RC lient.</param> public ViewModelBase(ISQLiteStorage storage, IScheduler scheduler, Logging.ILogger log, ApplicationStateHandler applicationStateHandler, WebServiceController webServiceController, GoogleMapsWebServiceController googleMapsWebServiceController, IPathLocator pathLocator, IScreen hostScreen, ILocationManager locationManager) { HostScreen = hostScreen; Locations = new ObservableCollection <Location>(); CurrentLocation = new Location(); LocationManager = locationManager; ConnectedStatusMessage = Labels.ConnectedTitle.ToUpper(); Storage = storage; scheduler.Schedule((arg1) => Storage.CreateSQLiteConnection()); WebServiceController = webServiceController; GoogleMapsWebServiceController = googleMapsWebServiceController; PathLocator = pathLocator; Subscriptions = new CompositeDisposable(); Scheduler = scheduler; ApplicationStateHandler = applicationStateHandler; Log = log; Tag = $"{GetType()} "; }
/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.ViewModels.TileViewModel"/> class. /// </summary> /// <param name="signalRClient">Signal RC lient.</param> public FeedbackListItemViewModel(ISQLiteStorage storage, IScheduler scheduler, ILogger log, ApplicationStateHandler applicationStateHandler, WebServiceController webServiceController, GoogleMapsWebServiceController googleMapsWebServiceController, IPathLocator pathLocator, IScreen hostScreen, ILocationManager locationManager) : base(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { Height = 200; }
/// <summary> /// Creates the path async. /// </summary> /// <returns>The path async.</returns> public IObservable <Unit> SelectFeedbackAsync() { IsLoading = true; IsError = false; return(GoogleMapsWebServiceController .GetDirectionsPolyLine(null, null, _currentTravelMode) .ObserveOn(this.Scheduler) .Catch <object, Exception>(error => { DidException(error, "Select failed using call to web service GetEReactiveUIAroundMeById"); return Observable.Empty <AuthContract>(); }) .Do(geocode => { IsLoading = false; }).Select(x => Unit.Default)); }
/// <summary> /// Creates the path async. /// </summary> /// <returns>The path async.</returns> public IObservable <Unit> CreatePathAsync(GoogleMapsTravelModes travelMode) { IsLoading = true; IsError = false; _currentTravelMode = travelMode; var startCoordinate = new GeoCoordinate(CurrentLocation.Latitude, CurrentLocation.Longitude); return(GoogleMapsWebServiceController .GetDirectionsPolyLine(startCoordinate, _endCoordinate, _currentTravelMode) .ObserveOn(this.Scheduler) .Catch <GoogleGeocodeContract, Exception>(error => { DidException(error, "Select failed using call to web service GetEReactiveUIAroundMeById"); return Observable.Empty <GoogleGeocodeContract>(); }) .Do(geocode => { IsLoading = false; var routes = geocode.Routes; var route = routes?.Length > 0 ? routes[0] : null; if (route != null) { var polyline = route.Bounds; var path = CreatePath(route.OverviewPolyline.Points); // update new path PathUpdate?.Invoke(this, new PathUpdateEventArgs() { StartCoordinate = startCoordinate, EndCoordinate = _endCoordinate, Path = path, }); } }).Select(x => Unit.Default)); }
/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.Portable.ViewModels.HomePageViewModel"/> class. /// </summary> /// <param name="signalRClient">Signal RC lient.</param> /// <param name="scheduler">Scheduler.</param> /// <param name="applicationStateHandler">Application state handler.</param> /// <param name="storage">Storage.</param> /// <param name="webServiceController">Web service controller.</param> /// <param name="log">Log.</param> /// <param name="device">Device.</param> public HomePageViewModel(IScheduler scheduler, ApplicationStateHandler applicationStateHandler, ISQLiteStorage storage, WebServiceController webServiceController, GoogleMapsWebServiceController googleMapsWebServiceController, IPathLocator pathLocator, ILogger log, IDevice device, IScreen hostScreen, ILocationManager locationManager) : base(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { Title = "Welcome"; _webServiceController = webServiceController; _device = device; scheduler.ScheduleAsync((arg1, arg2) => SetupSQLite()); scheduler.ScheduleAsync((arg1, arg2) => Load()); var canSearch = this.WhenAnyValue( vm => vm.CurrentLocation, (location) => location.Timestamp != default(DateTimeOffset)); SearchCommand = ReactiveCommand.CreateFromObservable(SearchAsync, canSearch, scheduler); }
/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.Portable.ViewModels.HomePageViewModel"/> class. /// </summary> /// <param name="signalRClient">Signal RC lient.</param> /// <param name="scheduler">Scheduler.</param> /// <param name="applicationStateHandler">Application state handler.</param> /// <param name="storage">Storage.</param> /// <param name="webServiceController">Web service controller.</param> /// <param name="log">Log.</param> /// <param name="device">Device.</param> public FlyoutMenuPageViewModel(IScheduler scheduler, ApplicationStateHandler applicationStateHandler, ISQLiteStorage storage, WebServiceController webServiceController, GoogleMapsWebServiceController googleMapsWebServiceController, IPathLocator pathLocator, ILogger log, IDevice device, IScreen hostScreen, ILocationManager locationManager) : base(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { Title = "Results"; Results = new ReactiveList <EReactiveUIAroundMeListItemViewModel>(); _webServiceController = webServiceController; _device = device; var canSelect = this.WhenAnyValue(vm => vm.Results, (results) => !results.IsEmpty && !IsLoading); ResultSelectCommand = ReactiveCommand.CreateFromObservable(SelectAsync, canSelect, Scheduler); }
/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.Portable.ViewModels.HomePageViewModel"/> class. /// </summary> /// <param name="signalRClient">Signal RC lient.</param> /// <param name="scheduler">Scheduler.</param> /// <param name="applicationStateHandler">Application state handler.</param> /// <param name="storage">Storage.</param> /// <param name="webServiceController">Web service controller.</param> /// <param name="log">Log.</param> /// <param name="device">Device.</param> public MapPageViewModel(IScheduler scheduler, ApplicationStateHandler applicationStateHandler, ISQLiteStorage storage, WebServiceController webServiceController, GoogleMapsWebServiceController googleMapsWebServiceController, IPathLocator pathLocator, ILogger log, IDevice device, IScreen hostScreen, ILocationManager locationManager) : base(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { Title = "Results"; Feedbacks = new ReactiveList <FeedbackListItemViewModel>(); Infos = new ReactiveList <TetrixViewModelBase>(); Infos.Add(new HeaderListItemViewModel(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { Title = "Contacts" }); foreach (var icon in icons) { Infos.Add(new ContactListItemViewModel(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { Icon = string.Format("{0}.png", icon) }); } var canSelectFeedback = this.WhenAnyValue( vm => vm.Feedbacks, vm => vm.IsLoading, (feedbacks, isLoading) => !feedbacks.IsEmpty && !isLoading); FeedbackSelectCommand = ReactiveCommand.CreateFromObservable(SelectFeedbackAsync, canSelectFeedback, Scheduler); var canSelectTravelMode = this.WhenAnyValue(vm => vm.IsLoading, (isLoading) => !isLoading); TransitCommand = ReactiveCommand.CreateFromObservable(() => CreatePathAsync(GoogleMapsTravelModes.Transit), canSelectTravelMode, Scheduler); DrivingCommand = ReactiveCommand.CreateFromObservable(() => CreatePathAsync(GoogleMapsTravelModes.Driving), canSelectTravelMode, Scheduler); WalkingCommand = ReactiveCommand.CreateFromObservable(() => CreatePathAsync(GoogleMapsTravelModes.Walking), canSelectTravelMode, Scheduler); }
/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.Portable.ViewModels.TetrixPageViewModelBase"/> class. /// </summary> /// <param name="storage">Storage.</param> /// <param name="scheduler">Scheduler.</param> /// <param name="signalRClient">Signal RC lient.</param> /// <param name="log">Log.</param> /// <param name="applicationStateHandler">Application state handler.</param> protected TetrixPageViewModelBase(ISQLiteStorage storage, IScheduler scheduler, ILogger log, ApplicationStateHandler applicationStateHandler, WebServiceController webServiceController, GoogleMapsWebServiceController googleMapsWebServiceController, IPathLocator pathLocator, IScreen hostScreen, ILocationManager locationManager) : base(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { Cells = new ObservableRangeCollection <TetrixViewModelBase>(); DataChanges = new Subject <DataChange>(); }
/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.ViewModels.TetrixViewModelBase"/> class. /// </summary> protected SelectableViewModelBase(ISQLiteStorage storage, IScheduler scheduler, ILogger log, ApplicationStateHandler applicationStateHandler, WebServiceController webServiceController, GoogleMapsWebServiceController googleMapsWebServiceController, IPathLocator pathLocator, IScreen hostScreen, ILocationManager locationManager) : base(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { // todo: working on this logic _selectAsync = Observable.Create((IObserver <bool> observer) => { IsSelected = !IsSelected; return(Disposable.Empty); }).Select(x => Unit.Default); var canExecute = this.WhenAnyValue(x => x.IsSelectable, (selectable) => !selectable); _selectCommand = ReactiveCommand.CreateFromObservable(() => _selectAsync, canExecute); }
/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.Portable.ViewModels.SuperAdminPageViewModel"/> class. /// </summary> /// <param name="storage">Storage.</param> /// <param name="scheduler">Scheduler.</param> /// <param name="signalRClient">Signal RC lient.</param> /// <param name="log">Log.</param> /// <param name="applicationStateHandler">Application state handler.</param> /// <param name="webServiceController">Web service controller.</param> public SuperAdminPageViewModel(ISQLiteStorage storage, IScheduler scheduler, ILogger log, ApplicationStateHandler applicationStateHandler, WebServiceController webServiceController, GoogleMapsWebServiceController googleMapsWebServiceController, IPathLocator pathLocator, IScreen hostScreen, ILocationManager locationManager) : base(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { _pathLocator = pathLocator; Title = "Super Admin"; selection = (obj) => { var parameters = (obj as TetrixViewModelBase)?.SelectParameters; object selectKey; parameters.TryGetValue("ViewModel", out selectKey); if (selectKey != null) { HostScreen.Router.Navigate.Execute(new SuperAdminPageViewModel(Storage, Scheduler, Log, ApplicationStateHandler, WebServiceController, GoogleMapsWebServiceController, PathLocator, HostScreen, LocationManager)); var viewModelType = Type.GetType(string.Format("ReactiveUIAroundMe.Portable.ViewModels.{0}", selectKey)); var instance = (ViewModelBase)Activator.CreateInstance(viewModelType, new object[] { Storage, Scheduler, Log, ApplicationStateHandler, WebServiceController, PathLocator, HostScreen }); HostScreen.Router.Navigate.Execute(instance); } ; return(Unit.Default); }; InitSelectCommand((obj) => selection(obj)); var tiles = _tileTiles.Select((title, index) => { var tileModel = new TileViewModel(Storage, Scheduler, Log, ApplicationStateHandler, WebServiceController, GoogleMapsWebServiceController, PathLocator, HostScreen, LocationManager); tileModel.Title = _tileTiles[index]; tileModel.BannerImage = _pathLocator.GetPath(_bannerImages[index], "jpg"); tileModel.TileImage = _pathLocator.GetPath("profile_image", "jpeg"); // hack: for mac until wet selectable cells working for collection views tileModel.InitSelectionCommand((obj) => selection(obj)); tileModel.SelectParameters = new Dictionary <string, object>() { { "ViewModel", _tileNavigationViewModels[index] }, }; tileModel.UseXSpacing = true; tileModel.UseYSpacing = true; tileModel.Layout = LayoutType.Fifth; tileModel.Position = index; return(tileModel); }); Cells.AddRange(tiles); }
/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.Portable.ViewModels.LoginPageViewModel"/> class. /// </summary> /// <param name="signalRClient">Signal RC lient.</param> /// <param name="scheduler">Scheduler.</param> /// <param name="applicationStateHandler">Application state handler.</param> /// <param name="storage">Storage.</param> /// <param name="webServiceController">Web service controller.</param> /// <param name="log">Log.</param> /// <param name="device">Device.</param> public LoginPageViewModel(IScheduler scheduler, ApplicationStateHandler applicationStateHandler, ISQLiteStorage storage, WebServiceController webServiceController, GoogleMapsWebServiceController googleMapsWebServiceController, IPathLocator pathLocator, ILogger log, IDevice device, IScreen hostScreen, ILocationManager locationManager) : base(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { Title = "Welcome"; _webServiceController = webServiceController; _device = device; scheduler.ScheduleAsync((arg1, arg2) => SetupSQLite()); scheduler.ScheduleAsync((arg1, arg2) => Load()); var canLogin = this.WhenAnyValue( vm => vm.Username, vm => vm.Password, vm => vm.IsLoading, (username, password, loading) => !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password) && !IsLoading); LoginCommand = ReactiveCommand.CreateFromObservable(LoginAsync, canLogin, Scheduler); }
/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.Droid.AppBootstrapper"/> class. /// </summary> public AppBootstrapper() { Router = new RoutingState(); Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen)); HttpClientHandler clientHandler = new HttpClientHandler(); //_isWindows ? new HttpClientHandler() : new NativeMessageHandler(); clientHandler.UseCookies = false; clientHandler.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; // TODO: singletons, we want to pull resolved items from container, rather than outside declarations var sqliteplatform = new SQLitePlatformAndroid(); var logger = new LoggerAndroid(); var settings = new Settings(); var userDefaults = new UserDefaults(settings); // temp until settings page added userDefaults.Host = Config.BaseUrl; var device = new Device.Device(); var sqliteSetup = new SQLiteSetup(sqliteplatform); var sqliteStorage = new SQLiteStorage(sqliteSetup, logger); var scheduler = new ReactiveUIAroundMe.Droid.Threading.HandlerScheduler(); var webServiceController = new WebServiceController(sqliteStorage, logger, clientHandler, scheduler, userDefaults); var googleMapsWebServiceController = new GoogleMapsWebServiceController(sqliteStorage, logger, clientHandler, scheduler, userDefaults); var applicationStateHandler = new ApplicationStateHandler(sqliteStorage); //var orientationHandler = new OrientationHandlerAndroid(); var pathLocator = new PathLocator(); var locationManager = new LocationManager(); // pages // todo: we could use reflection here //Locator.CurrentMutable.Register(() => new LoginPage(), typeof(IViewFor<LoginPageViewModel>)); Locator.CurrentMutable.Register(() => new HomeActivity(), typeof(IViewFor <HomePageViewModel>)); //Locator.CurrentMutable.Register(() => new SuperAdminPage(), typeof(IViewFor<SuperAdminPageViewModel>)); //Locator.CurrentMutable.Register(() => new SearchResultsPage(), typeof(IViewFor<SearchResultsPageViewModel>)); //Locator.CurrentMutable.Register(() => new MapPage(), typeof(IViewFor<MapPageViewModel>)); Locator.CurrentMutable.Register(() => new FlyoutMenuActivity(), typeof(IViewFor <FlyoutMenuPageViewModel>)); // singletons Locator.CurrentMutable.RegisterLazySingleton(() => applicationStateHandler, typeof(ApplicationStateHandler)); Locator.CurrentMutable.RegisterLazySingleton(() => webServiceController, typeof(WebServiceController)); Locator.CurrentMutable.RegisterLazySingleton(() => googleMapsWebServiceController, typeof(GoogleMapsWebServiceController)); Locator.CurrentMutable.Register <ISettings>(() => settings); Locator.CurrentMutable.Register <IUserDefaults>(() => userDefaults); Locator.CurrentMutable.Register <ISQLitePlatform>(() => sqliteplatform); Locator.CurrentMutable.Register <ISQLiteSetup>(() => sqliteSetup); Locator.CurrentMutable.Register <ISQLiteStorage>(() => sqliteStorage); Locator.CurrentMutable.Register <Portable.Logging.ILogger>(() => logger); Locator.CurrentMutable.Register <IDevice>(() => device); //Locator.CurrentMutable.Register<IOrientationHandler>(() => orientationHandler); Locator.CurrentMutable.Register <IPathLocator>(() => pathLocator); Locator.CurrentMutable.Register <IScheduler>(() => scheduler); Locator.CurrentMutable.Register <ILocationManager>(() => locationManager); Locator.CurrentMutable.Register <HttpClientHandler>(() => clientHandler); // converters Locator.CurrentMutable.RegisterConstant(new NotConverter(), typeof(IBindingTypeConverter)); //Locator.CurrentMutable.RegisterViewsForViewModels(this.GetType().GetTypeInfo().Assembly); _flyoutMenuViewModel = new FlyoutMenuPageViewModel(scheduler, applicationStateHandler, sqliteStorage, webServiceController, googleMapsWebServiceController, pathLocator, logger, device, this, locationManager); //// Navigate to the opening page of the application Router.Navigate.Execute(new HomePageViewModel(scheduler, applicationStateHandler, sqliteStorage, webServiceController, googleMapsWebServiceController, pathLocator, logger, device, this, locationManager)); }
/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.ViewModels.TetrixViewModelBase"/> class. /// </summary> protected TetrixViewModelBase(ISQLiteStorage storage, IScheduler scheduler, ILogger log, ApplicationStateHandler applicationStateHandler, WebServiceController webServiceController, GoogleMapsWebServiceController googleMapsWebServiceController, IPathLocator pathLocator, IScreen hostScreen, ILocationManager locationManager) : base(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { }
/// <summary> /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.Portable.ViewModels.HomePageViewModel"/> class. /// </summary> /// <param name="signalRClient">Signal RC lient.</param> /// <param name="scheduler">Scheduler.</param> /// <param name="applicationStateHandler">Application state handler.</param> /// <param name="storage">Storage.</param> /// <param name="webServiceController">Web service controller.</param> /// <param name="log">Log.</param> /// <param name="device">Device.</param> public SearchResultsPageViewModel(IScheduler scheduler, ApplicationStateHandler applicationStateHandler, ISQLiteStorage storage, WebServiceController webServiceController, GoogleMapsWebServiceController googleMapsWebServiceController, IPathLocator pathLocator, ILogger log, IDevice device, IScreen hostScreen, ILocationManager locationManager) : base(storage, scheduler, log, applicationStateHandler, webServiceController, googleMapsWebServiceController, pathLocator, hostScreen, locationManager) { Title = "Results"; Results = new ReactiveList <EReactiveUIAroundMeListItemViewModel>(); _webServiceController = webServiceController; _device = device; }