示例#1
0
        public ExerciseDetailsViewModel(
            IMasterDetailNavigation navigationService, IDialogService dialogService, IMessagingService messagingService, IUnitsService units,
            IExercisesRepository exercisesRepository, IRoutineDaysRepository routineDaysRepository)
        {
            _navigationService     = navigationService;
            _dialogService         = dialogService;
            _messagingService      = messagingService;
            _units                 = units;
            _exercisesRepository   = exercisesRepository;
            _routineDaysRepository = routineDaysRepository;

            Title = AppResources.AddExerciseTitle;

            DeleteCommand = new Command(async() => { await OnDelete(); });
            SaveCommand   = new Command(async() => await OnSave());
        }
示例#2
0
        public WorkoutsViewModel(
            IComponentContext componentContext, IMasterDetailNavigation navigationService,
            IMessagingService messagingService, IDatePickerDialog datePickerDialog, IWorkoutRules workoutRules,
            IWorkoutsRepository workoutsRepository, IExercisesRepository exercisesRepository,
            ICalendarRepository calendarRepository, IRoutineDaysRepository routineDaysRepository)
        {
            _componentContext      = componentContext;
            _navigationService     = navigationService;
            _messagingService      = messagingService;
            _datePickerDialog      = datePickerDialog;
            _workoutRules          = workoutRules;
            _workoutsRepository    = workoutsRepository;
            _exercisesRepository   = exercisesRepository;
            _calendarRepository    = calendarRepository;
            _routineDaysRepository = routineDaysRepository;

            RestTimerItem = _componentContext.Resolve <RestTimerItem>();

            Title = "One Set To Failure";

            ChevronTapCommand    = new Command(async(s) => { await OnChevronTapCommand(s); });
            CalendarNotesCommand = new Command(async() => { await OnCalendarNotesCommand(); });
            GotoDateCommand      = new Command(OnGotoDateCommand);
            SelectItemCommand    = new Command(async(item) => { await OnItemSelected(item); });
            TimerCommand         = new Command(async() =>
            {
                var parameters = new NavigationParameters {
                    { "RestTimerItem", RestTimerItem }
                };
                await _navigationService.NavigateToHierarchical <RestTimerViewModel>(parameters);
            });

            _messagingService.Subscribe <WorkoutDetailsViewModel, Workout>(this, Messages.ItemChanged, (sender, workout) =>
            {
                var item = Routine.FirstOrDefault(x => x.Exercise.ExerciseId == workout.ExerciseId);
                if (item == null)
                {
                    return;
                }
                item.Workout = null;
                item.Workout = workout;
            });

            _messagingService.Subscribe <ExerciseDetailsViewModel, Exercise>(this, Messages.ItemAdded, async(sender, e) =>
            {
                await Reload();
            });
            _messagingService.Subscribe <ExerciseDetailsViewModel, Exercise>(this, Messages.ItemChanged, async(sender, e) =>
            {
                await Reload();
            });
            _messagingService.Subscribe <ExerciseDetailsViewModel>(this, Messages.ItemDeleted, async sender =>
            {
                await Reload();
            });

            _messagingService.Subscribe <CalendarNotesViewModel>(this, Messages.ItemChanged, async sender =>
            {
                await LoadNotes();
            });

            _messagingService.Subscribe <SettingsViewModel>(this, Messages.WorkoutDataCleared, async sender =>
            {
                await Reload();
            });
        }