Пример #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            prepareViews();

            Title             = ViewModel.Title;
            VersionLabel.Text = ViewModel.Version;

            LoggingOutView.Hidden          = true;
            SendFeedbackSuccessView.Hidden = true;

            this.Bind(ViewModel.Email, EmailLabel.Rx().Text());
            this.Bind(ViewModel.IsSynced, SyncedView.Rx().IsVisible());
            this.Bind(ViewModel.WorkspaceName, WorkspaceLabel.Rx().Text());
            this.Bind(ViewModel.DurationFormat, DurationFormatLabel.Rx().Text());
            this.Bind(ViewModel.IsRunningSync, SyncingView.Rx().IsVisible());
            this.Bind(ViewModel.DateFormat, DateFormatLabel.Rx().Text());
            this.Bind(ViewModel.BeginningOfWeek, BeginningOfWeekLabel.Rx().Text());
            this.Bind(ViewModel.IsFeedbackSuccessViewShowing, SendFeedbackSuccessView.Rx().AnimatedIsVisible());
            this.BindVoid(ViewModel.LoggingOut, () =>
            {
                LoggingOutView.Hidden = false;
                SyncingView.Hidden    = true;
                SyncedView.Hidden     = true;
            });

            this.Bind(HelpView.Rx().Tap(), ViewModel.OpenHelpView);
            this.Bind(LogoutButton.Rx().Tap(), ViewModel.TryLogout);
            this.Bind(AboutView.Rx().Tap(), ViewModel.OpenAboutView);
            this.Bind(FeedbackView.Rx().Tap(), ViewModel.SubmitFeedback);
            this.Bind(DateFormatView.Rx().Tap(), ViewModel.SelectDateFormat);
            this.Bind(WorkspaceView.Rx().Tap(), ViewModel.PickDefaultWorkspace);
            this.Bind(DurationFormatView.Rx().Tap(), ViewModel.SelectDurationFormat);
            this.BindVoid(ManualModeSwitch.Rx().Changed(), ViewModel.ToggleManualMode);
            this.Bind(BeginningOfWeekView.Rx().Tap(), ViewModel.SelectBeginningOfWeek);
            this.Bind(CalendarSettingsView.Rx().Tap(), ViewModel.OpenCalendarSettingsAction);
            this.BindVoid(SendFeedbackSuccessView.Rx().Tap(), ViewModel.CloseFeedbackSuccessView);
            this.Bind(NotificationSettingsView.Rx().Tap(), ViewModel.OpenNotificationSettingsAction);
            this.Bind(TwentyFourHourClockSwitch.Rx().Changed(), ViewModel.ToggleUseTwentyFourHourClock);

            UIApplication.Notifications
            .ObserveWillEnterForeground((sender, e) => startAnimations())
            .DisposedBy(DisposeBag);

            if (!ViewModel.CalendarSettingsEnabled)
            {
                hideCalendarSettingsSection();
            }

            ViewModel.IsManualModeEnabled
            .FirstAsync()
            .Subscribe(isEnabled => ManualModeSwitch.SetState(isEnabled, false))
            .DisposedBy(DisposeBag);

            ViewModel.UseTwentyFourHourFormat
            .FirstAsync()
            .Subscribe(useTwentyFourHourFormat => TwentyFourHourClockSwitch.SetState(useTwentyFourHourFormat, false))
            .DisposedBy(DisposeBag);
        }
Пример #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            GroupSimilarTimeEntriesLabel.Text = Resources.GroupTimeEntries;
            YourProfileCellLabel.Text         = Resources.YourProfile;
            WorkspaceCellLabel.Text           = Resources.Workspace;
            FormatSettingsHeaderLabel.Text    = Resources.FormatSettings;
            DateFormatCellLabel.Text          = Resources.DateFormat;
            Use24HourClockCellLabel.Text      = Resources.Use24HourClock;
            DurationFormatCellLabel.Text      = Resources.DurationFormat;
            FirstDayOfTheWeekCellLabel.Text   = Resources.FirstDayOfTheWeek;
            ManualModeCellLabel.Text          = Resources.ManualMode;
            ManualModeDescriptionLabel.Text   = Resources.ManualModeDescription;
            CalendarSettingsCellLabel.Text    = Resources.CalendarSettingsTitle;
            SmartAlertCellLabel.Text          = Resources.SmartAlerts;
            SubmitFeedbackCellLabel.Text      = Resources.SubmitFeedback;
            AboutCellLabel.Text          = Resources.About;
            HelpCellLabel.Text           = Resources.Help;
            LoggingOutLabel.Text         = Resources.LoggingOutSecurely;
            SyncingLabel.Text            = Resources.Syncing;
            SyncedLabel.Text             = Resources.SyncCompleted;
            FeedbackToastTitleLabel.Text = Resources.DoneWithExclamationMark.ToUpper();
            FeedbackToastTextLabel.Text  = Resources.ThankYouForTheFeedback;
            LogoutButton.SetTitle(Resources.SignOutOfToggl, UIControlState.Normal);

            prepareViews();

            Title             = ViewModel.Title;
            VersionLabel.Text = ViewModel.Version;

            LoggingOutView.Hidden          = true;
            SendFeedbackSuccessView.Hidden = true;

            ViewModel.Email
            .Subscribe(EmailLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            ViewModel.IsSynced
            .Subscribe(SyncedView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.WorkspaceName
            .Subscribe(WorkspaceLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            ViewModel.DurationFormat
            .Subscribe(DurationFormatLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            ViewModel.IsRunningSync
            .Subscribe(SyncingView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.DateFormat
            .Subscribe(DateFormatLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            ViewModel.BeginningOfWeek
            .Subscribe(BeginningOfWeekLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            ViewModel.IsFeedbackSuccessViewShowing
            .Subscribe(SendFeedbackSuccessView.Rx().AnimatedIsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.LoggingOut
            .Subscribe(_ =>
            {
                LoggingOutView.Hidden = false;
                SyncingView.Hidden    = true;
                SyncedView.Hidden     = true;
            })
            .DisposedBy(DisposeBag);

            HelpView.Rx()
            .BindAction(ViewModel.OpenHelpView)
            .DisposedBy(DisposeBag);

            LogoutButton.Rx()
            .BindAction(ViewModel.TryLogout)
            .DisposedBy(DisposeBag);

            AboutView.Rx()
            .BindAction(ViewModel.OpenAboutView)
            .DisposedBy(DisposeBag);

            FeedbackView.Rx()
            .BindAction(ViewModel.SubmitFeedback)
            .DisposedBy(DisposeBag);

            DateFormatView.Rx()
            .BindAction(ViewModel.SelectDateFormat)
            .DisposedBy(DisposeBag);

            WorkspaceView.Rx()
            .BindAction(ViewModel.PickDefaultWorkspace)
            .DisposedBy(DisposeBag);

            DurationFormatView.Rx()
            .BindAction(ViewModel.SelectDurationFormat)
            .DisposedBy(DisposeBag);

            ManualModeSwitch.Rx().Changed()
            .Subscribe(ViewModel.ToggleManualMode)
            .DisposedBy(DisposeBag);

            GroupSimilarTimeEntriesSwitch.Rx()
            .BindAction(ViewModel.ToggleTimeEntriesGrouping)
            .DisposedBy(DisposeBag);

            BeginningOfWeekView.Rx()
            .BindAction(ViewModel.SelectBeginningOfWeek)
            .DisposedBy(DisposeBag);

            CalendarSettingsView.Rx()
            .BindAction(ViewModel.OpenCalendarSettings)
            .DisposedBy(DisposeBag);

            SendFeedbackSuccessView.Rx().Tap()
            .Subscribe(ViewModel.CloseFeedbackSuccessView)
            .DisposedBy(DisposeBag);

            NotificationSettingsView.Rx()
            .BindAction(ViewModel.OpenNotificationSettings)
            .DisposedBy(DisposeBag);

            TwentyFourHourClockSwitch.Rx().Changed()
            .Subscribe(ViewModel.ToggleTwentyFourHourSettings.Inputs)
            .DisposedBy(DisposeBag);

            UIApplication.Notifications
            .ObserveWillEnterForeground((sender, e) => startAnimations())
            .DisposedBy(DisposeBag);

            if (!ViewModel.CalendarSettingsEnabled)
            {
                hideCalendarSettingsSection();
            }

            ViewModel.IsManualModeEnabled
            .FirstAsync()
            .Subscribe(isEnabled => ManualModeSwitch.SetState(isEnabled, false))
            .DisposedBy(DisposeBag);

            ViewModel.IsGroupingTimeEntries
            .FirstAsync()
            .Subscribe(isGrouping => GroupSimilarTimeEntriesSwitch.SetState(isGrouping, false))
            .DisposedBy(DisposeBag);

            ViewModel.UseTwentyFourHourFormat
            .FirstAsync()
            .Subscribe(useTwentyFourHourFormat => TwentyFourHourClockSwitch.SetState(useTwentyFourHourFormat, false))
            .DisposedBy(DisposeBag);
        }