Exemple #1
0
        public async UniTask Enter(IPersonEntry entry)
        {
            ResetAnimation();

            _thumbnailImage.SetTexture(entry.Thumbnail);
            _nameText.text        = $"{entry.Name}, {entry.Age}";
            _descriptionText.text = entry.Description;

            await UnityUtils.Animate(.5f, _curve, t =>
            {
                _mask.alpha        = t;
                float initialDepth = _initialDepth / _root.lossyScale.z;
                _root.SetAnchoredPosition(z: Mathf.Lerp(initialDepth, 0f, t));
            });
        }
        public async void Enter(IPersonEntry entry)
        {
            var page = _pages[_currentPageIndex];

            page.gameObject.SetActive(true);

            try
            {
                AcceptsInput = false;
                await page.Enter(entry);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
            finally
            {
                AcceptsInput = true;
            }
        }
        public PersonEntryViewModel(IPersonEntry person, ISchedulerProvider schedulerProvider)
        {
            _person = person;
            _schedulerProvider = schedulerProvider;

            SaveCommand = new DelegateCommand(Save, () => !Person.HasErrors && !Person.State.HasError);

            var errors = Observable.FromEventPattern<EventHandler<DataErrorsChangedEventArgs>, DataErrorsChangedEventArgs>(
                    h => Person.ErrorsChanged += h,
                    h => Person.ErrorsChanged -= h)
                .Select(_ => Unit.Default);
            var states = Person.OnPropertyChanges(p => p.State)
                               .Select(_ => Unit.Default);

            _errorStateSubscription = Observable
                .Merge(errors, states)
                .ObserveOn(_schedulerProvider.Dispatcher)
                .Subscribe(_ => SaveCommand.RaiseCanExecuteChanged());

            states.ObserveOn(_schedulerProvider.Dispatcher)
                 .Subscribe(_ => OnPropertyChanged("State"));
        }
Exemple #4
0
        public PersonEntryViewModel(IPersonEntry person, ISchedulerProvider schedulerProvider)
        {
            _person            = person;
            _schedulerProvider = schedulerProvider;

            SaveCommand = new DelegateCommand(Save, () => !Person.HasErrors && !Person.State.HasError);

            var errors = Observable.FromEventPattern <EventHandler <DataErrorsChangedEventArgs>, DataErrorsChangedEventArgs>(
                h => Person.ErrorsChanged += h,
                h => Person.ErrorsChanged -= h)
                         .Select(_ => Unit.Default);
            var states = Person.OnPropertyChanges(p => p.State)
                         .Select(_ => Unit.Default);

            _errorStateSubscription = Observable
                                      .Merge(errors, states)
                                      .ObserveOn(_schedulerProvider.Dispatcher)
                                      .Subscribe(_ => SaveCommand.RaiseCanExecuteChanged());

            states.ObserveOn(_schedulerProvider.Dispatcher)
            .Subscribe(_ => OnPropertyChanged("State"));
        }