public override void ViewDidLoad() { base.ViewDidLoad(); settingsButton.SetImage(UIImage.FromBundle("icSettings"), UIControlState.Normal); ViewModel .ShouldShowOnboarding .FirstAsync() .Subscribe( shouldShowOnboarding => OnboardingView.Alpha = shouldShowOnboarding ? 1: 0) .DisposedBy(DisposeBag); this.Bind(ViewModel.ShouldShowOnboarding, OnboardingView.Rx().IsVisibleWithFade()); this.Bind(GetStartedButton.Rx().Tap(), ViewModel.GetStartedAction); var timeService = Mvx.Resolve <ITimeService>(); dataSource = new CalendarCollectionViewSource( CalendarCollectionView, ViewModel.Date, ViewModel.TimeOfDayFormat, ViewModel.CalendarItems); layout = new CalendarCollectionViewLayout(timeService, dataSource); editItemHelper = new CalendarCollectionViewEditItemHelper(CalendarCollectionView, dataSource, layout); createFromSpanHelper = new CalendarCollectionViewCreateFromSpanHelper(CalendarCollectionView, dataSource, layout); CalendarCollectionView.SetCollectionViewLayout(layout, false); CalendarCollectionView.Delegate = dataSource; CalendarCollectionView.DataSource = dataSource; CalendarCollectionView.ContentInset = new UIEdgeInsets(20, 0, 20, 0); this.Bind(dataSource.ItemTapped, ViewModel.OnItemTapped); this.Bind(settingsButton.Rx().Tap(), ViewModel.SelectCalendars); this.Bind(editItemHelper.EditCalendarItem, ViewModel.OnUpdateTimeEntry); this.Bind(ViewModel.SettingsAreVisible, settingsButton.Rx().IsVisible()); this.Bind(createFromSpanHelper.CreateFromSpan, ViewModel.OnDurationSelected); CalendarCollectionView.LayoutIfNeeded(); var currentTimeY = layout.FrameForCurrentTime().Y; var scrollPointY = currentTimeY - View.Frame.Height / 2; var currentTimePoint = new CGPoint(0, scrollPointY.Clamp(0, CalendarCollectionView.ContentSize.Height)); CalendarCollectionView.SetContentOffset(currentTimePoint, false); }
public CalendarCollectionViewEditItemHelper( UICollectionView CollectionView, CalendarCollectionViewSource dataSource, CalendarCollectionViewLayout Layout) : base(CollectionView, Layout) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); this.dataSource = dataSource; longPressGestureRecognizer = new UILongPressGestureRecognizer(onLongPress); longPressGestureRecognizer.Delegate = this; CollectionView.AddGestureRecognizer(longPressGestureRecognizer); panGestureRecognizer = new UIPanGestureRecognizer(onPan); panGestureRecognizer.Delegate = this; tapGestureRecognizer = new UITapGestureRecognizer(onTap); tapGestureRecognizer.Delegate = this; }
public CalendarCollectionViewEditItemHelper( UICollectionView CollectionView, ITimeService timeService, CalendarCollectionViewSource dataSource, CalendarCollectionViewLayout Layout) : base(CollectionView, Layout) { Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); this.timeService = timeService; this.dataSource = dataSource; longPressGestureRecognizer = new UILongPressGestureRecognizer(onLongPress); longPressGestureRecognizer.Delegate = this; CollectionView.AddGestureRecognizer(longPressGestureRecognizer); panGestureRecognizer = new UIPanGestureRecognizer(onPan); panGestureRecognizer.Delegate = this; tapGestureRecognizer = new UITapGestureRecognizer(onTap); tapGestureRecognizer.Delegate = this; scalingEndedSubscription = Layout.ScalingEnded.Subscribe(onLayoutScalingEnded); }
public override void ViewDidLoad() { base.ViewDidLoad(); ExtendedNavbarView.BackgroundColor = NavigationController.NavigationBar.BackgroundColor; TimeTrackedTodayLabel.Font = TimeTrackedTodayLabel.Font.GetMonospacedDigitFont(); TitleLabel.Text = Resources.Welcome; DescriptionLabel.Text = Resources.CalendarFeatureDescription; GetStartedButton.SetTitle(Resources.GetStarted, UIControlState.Normal); settingsButton.SetImage(UIImage.FromBundle("icSettings"), UIControlState.Normal); ViewModel .ShouldShowOnboarding .FirstAsync() .Subscribe( shouldShowOnboarding => OnboardingView.Alpha = shouldShowOnboarding ? 1: 0) .DisposedBy(DisposeBag); ViewModel.ShouldShowOnboarding .Subscribe(OnboardingView.Rx().IsVisibleWithFade()) .DisposedBy(DisposeBag); GetStartedButton.Rx() .BindAction(ViewModel.GetStarted) .DisposedBy(DisposeBag); ViewModel.TimeTrackedToday .Subscribe(TimeTrackedTodayLabel.Rx().Text()) .DisposedBy(DisposeBag); ViewModel.CurrentDate .Subscribe(CurrentDateLabel.Rx().Text()) .DisposedBy(DisposeBag); dataSource = new CalendarCollectionViewSource( timeService, CalendarCollectionView, ViewModel.TimeOfDayFormat, ViewModel.CalendarItems); layout = new CalendarCollectionViewLayout(timeService, dataSource); editItemHelper = new CalendarCollectionViewEditItemHelper(CalendarCollectionView, timeService, dataSource, layout); createFromSpanHelper = new CalendarCollectionViewCreateFromSpanHelper(CalendarCollectionView, dataSource, layout); zoomHelper = new CalendarCollectionViewZoomHelper(CalendarCollectionView, layout); CalendarCollectionView.SetCollectionViewLayout(layout, false); CalendarCollectionView.Delegate = dataSource; CalendarCollectionView.DataSource = dataSource; CalendarCollectionView.ContentInset = new UIEdgeInsets(20, 0, 20, 0); dataSource.ItemTapped .Subscribe(ViewModel.OnItemTapped.Inputs) .DisposedBy(DisposeBag); settingsButton.Rx() .BindAction(ViewModel.SelectCalendars) .DisposedBy(DisposeBag); editItemHelper.EditCalendarItem .Subscribe(ViewModel.OnUpdateTimeEntry.Inputs) .DisposedBy(DisposeBag); editItemHelper.LongPressCalendarEvent .Subscribe(ViewModel.OnCalendarEventLongPressed.Inputs) .DisposedBy(DisposeBag); ViewModel.SettingsAreVisible .Subscribe(settingsButton.Rx().IsVisible()) .DisposedBy(DisposeBag); createFromSpanHelper.CreateFromSpan .Subscribe(ViewModel.OnDurationSelected.Inputs) .DisposedBy(DisposeBag); CalendarCollectionView.LayoutIfNeeded(); }