コード例 #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.BindText());
            this.Bind(ViewModel.IsSynced, SyncedView.BindIsVisible());
            this.Bind(ViewModel.WorkspaceName, WorkspaceLabel.BindText());
            this.Bind(ViewModel.DurationFormat, DurationFormatLabel.BindText());
            this.Bind(ViewModel.IsRunningSync, SyncingView.BindIsVisible());
            this.Bind(ViewModel.DateFormat, DateFormatLabel.BindText());
            this.Bind(ViewModel.IsManualModeEnabled, ManualModeSwitch.BindIsOn());
            this.Bind(ViewModel.BeginningOfWeek, BeginningOfWeekLabel.BindText());
            this.Bind(ViewModel.UseTwentyFourHourFormat, TwentyFourHourClockSwitch.BindIsOn());
            this.BindVoid(ViewModel.LoggingOut, () =>
            {
                LoggingOutView.Hidden = false;
                SyncingView.Hidden    = true;
                SyncedView.Hidden     = true;
            });
            this.Bind(ViewModel.IsFeedbackSuccessViewShowing, SendFeedbackSuccessView.BindAnimatedIsVisible());

            this.Bind(HelpView.Tapped(), ViewModel.OpenHelpView);
            this.Bind(LogoutButton.Tapped(), ViewModel.TryLogout);
            this.Bind(AboutView.Tapped(), ViewModel.OpenAboutView);
            this.Bind(FeedbackView.Tapped(), ViewModel.SubmitFeedback);
            this.Bind(DateFormatView.Tapped(), ViewModel.SelectDateFormat);
            this.Bind(WorkspaceView.Tapped(), ViewModel.PickDefaultWorkspace);
            this.BindVoid(ManualModeView.Tapped(), ViewModel.ToggleManualMode);
            this.Bind(DurationFormatView.Tapped(), ViewModel.SelectDurationFormat);
            this.Bind(BeginningOfWeekView.Tapped(), ViewModel.SelectBeginningOfWeek);
            this.Bind(TwentyFourHourClockView.Tapped(), ViewModel.ToggleUseTwentyFourHourClock);
            this.BindVoid(SendFeedbackSuccessView.Tapped(), ViewModel.CloseFeedbackSuccessView);

            UIApplication.Notifications
            .ObserveWillEnterForeground((sender, e) => startAnimations())
            .DisposedBy(DisposeBag);
        }
コード例 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            prepareViews();
            prepareOnboarding();
            setupTableViewHeader();

            var visibilityConverter       = new MvxVisibilityValueConverter();
            var projectTaskClientCombiner = new ProjectTaskClientValueCombiner(
                CurrentTimeEntryProjectTaskClientLabel.Font.CapHeight,
                Color.Main.CurrentTimeEntryClientColor.ToNativeColor(),
                true
                );
            var startTimeEntryButtonManualModeIconConverter = new BoolToConstantValueConverter <UIImage>(
                UIImage.FromBundle("manualIcon"),
                UIImage.FromBundle("playIcon")
                );
            var durationCombiner = new DurationValueCombiner();

            var bindingSet = this.CreateBindingSet <MainViewController, MainViewModel>();

            // Table view
            tableViewSource = new TimeEntriesLogViewSource(ViewModel.TimeEntries, TimeEntriesLogViewCell.Identifier);
            TimeEntriesLogTableView
            .Bind(tableViewSource)
            .DisposedBy(disposeBag);

            this.Bind(tableViewSource.FirstCell, f =>
            {
                onFirstTimeEntryChanged(f);
                firstTimeEntryCell = f;
            });

            this.Bind(tableViewSource.ScrollOffset, onTableScroll);

            var continueTimeEntry = Observable.Merge(
                tableViewSource.ContinueTap,
                tableViewSource.SwipeToContinue
                );

            this.Bind(continueTimeEntry, ViewModel.ContinueTimeEntry);
            this.Bind(tableViewSource.SwipeToDelete, ViewModel.TimeEntriesViewModel.DelayDeleteTimeEntry);
            this.Bind(tableViewSource.ItemSelected, ViewModel.SelectTimeEntry);
            this.Bind(ViewModel.TimeEntriesViewModel.ShouldShowUndo, toggleUndoDeletion);

            tableViewSource.SwipeToContinue
            .VoidSubscribe(() =>
            {
                swipeRightStep.Dismiss();
            })
            .DisposedBy(disposeBag);

            tableViewSource.SwipeToDelete
            .VoidSubscribe(() =>
            {
                swipeLeftStep.Dismiss();
            })
            .DisposedBy(disposeBag);

            // Refresh Control
            var refreshControl = new RefreshControl(ViewModel.SyncProgressState, tableViewSource);

            this.Bind(refreshControl.Refresh, ViewModel.RefreshAction);
            TimeEntriesLogTableView.CustomRefreshControl = refreshControl;

            //Commands
            bindingSet.Bind(settingsButton).To(vm => vm.OpenSettingsCommand);
            bindingSet.Bind(StopTimeEntryButton).To(vm => vm.StopTimeEntryCommand);
            bindingSet.Bind(StartTimeEntryButton).To(vm => vm.StartTimeEntryCommand);
            bindingSet.Bind(EditTimeEntryButton).To(vm => vm.EditTimeEntryCommand);
            bindingSet.Bind(syncFailuresButton).To(vm => vm.OpenSyncFailuresCommand);

            bindingSet.Bind(CurrentTimeEntryCard)
            .For(v => v.BindTap())
            .To(vm => vm.EditTimeEntryCommand);

            bindingSet.Bind(suggestionsView)
            .For(v => v.SuggestionTappedCommad)
            .To(vm => vm.SuggestionsViewModel.StartTimeEntryCommand);

            bindingSet.Bind(StartTimeEntryButton)
            .For(v => v.BindLongPress())
            .To(vm => vm.AlternativeStartTimeEntryCommand);

            //Visibility
            var shouldWelcomeBack = ViewModel.ShouldShowWelcomeBack;

            this.Bind(ViewModel.ShouldShowEmptyState, visible => emptyStateView.Hidden = !visible);
            this.Bind(shouldWelcomeBack, WelcomeBackView.BindIsVisible());
            this.Bind(shouldWelcomeBack, spiderContainerView.BindIsVisible());
            this.Bind(shouldWelcomeBack, visible =>
            {
                if (visible)
                {
                    spiderBroView.Show();
                }
                else
                {
                    spiderBroView.Hide();
                }
            });

            //Text
            bindingSet.Bind(CurrentTimeEntryDescriptionLabel).To(vm => vm.CurrentTimeEntryDescription);

            bindingSet.Bind(CurrentTimeEntryElapsedTimeLabel)
            .ByCombining(durationCombiner,
                         vm => vm.CurrentTimeEntryElapsedTime,
                         vm => vm.CurrentTimeEntryElapsedTimeFormat);

            bindingSet.Bind(CurrentTimeEntryProjectTaskClientLabel)
            .For(v => v.AttributedText)
            .ByCombining(projectTaskClientCombiner,
                         v => v.CurrentTimeEntryProject,
                         v => v.CurrentTimeEntryTask,
                         v => v.CurrentTimeEntryClient,
                         v => v.CurrentTimeEntryProjectColor);

            //The start button
            bindingSet.Bind(StartTimeEntryButton)
            .For(v => v.BindImage())
            .To(vm => vm.IsInManualMode)
            .WithConversion(startTimeEntryButtonManualModeIconConverter);

            //The sync failures button
            bindingSet.Bind(syncFailuresButton)
            .For(v => v.BindVisibility())
            .To(vm => vm.NumberOfSyncFailures)
            .WithConversion(visibilityConverter);

            bindingSet.Apply();

            this.Bind(ViewModel.RatingViewModel.IsFeedbackSuccessViewShowing,
                      SendFeedbackSuccessView.BindAnimatedIsVisible());
            this.BindVoid(SendFeedbackSuccessView.Tapped(), ViewModel.RatingViewModel.CloseFeedbackSuccessView);

            View.SetNeedsLayout();
            View.LayoutIfNeeded();
        }