private void LayoutSubviews() { _hiddenInfo = _info.Height().EqualTo(0f); View.AddConstraints(_toggleButton.FullWidthOf(View)); View.AddConstraints(_mapView.FullWidthOf(View)); View.AddConstraints(new FluentLayout[] { _toggleButton.AtBottomOf(View), _mapView.AtTopOf(View), _mapView.Above(_toggleButton), _hiddenInfo, _info.AtBottomOf(_toggleButton), _info.AtLeftOf(View), _info.AtRightOf(View) }); _info.AddConstraints(new FluentLayout[] { _colon.WithSameCenterX(_info), _colon.AtBottomOf(_info, 10f), _colon.AtTopOf(_info, 10f), _latitude.AtLeftOf(_info, 10f), _latitude.ToRightOf(_colon, 10f), _latitude.AtBottomOf(_info, 10f), _latitude.AtTopOf(_info, 10f), _longitude.AtRightOf(_info, 10f), _longitude.ToLeftOf(_colon, 10f), _longitude.AtBottomOf(_info, 10f), _longitude.AtTopOf(_info, 10f), }); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = "DynamicHeightObserverView"; InitializeScrollView(); var headerLabel = new UILabel() { Text = "Wait 3 seconds...", TextAlignment = UITextAlignment.Center }; var blueView = new UIView() { BackgroundColor = UIColor.Blue }; _tableView = new UITableView() { ScrollEnabled = false }; _tableView.RowHeight = UITableView.AutomaticDimension; _tableView.EstimatedRowHeight = 30; _tableView.TableFooterView = new UIView(); var source = new MvxSimpleTableViewSource(_tableView, typeof(ItemCell), ItemCell.Key); _tableView.Source = source; var greenView = new UIView() { BackgroundColor = UIColor.Green }; var footerLabel = new UILabel() { Text = "Footer", TextAlignment = UITextAlignment.Center }; var bindingSet = this.CreateBindingSet <DynamicHeightObserverView, DynamicHeightObserverViewModel>(); bindingSet.Bind(source).To(vm => vm.Items); bindingSet.Apply(); _tableView.ReloadData(); _tableViewHeightFluentLayout = _tableView.Height().EqualTo(0); BaseContentView.AddSubviews(headerLabel, blueView, _tableView, greenView, footerLabel); BaseScrollView.AddSubviews(BaseContentView); View.AddSubviews(BaseScrollView); View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); View.AddConstraints( BaseScrollView.AtTopOf(View), BaseScrollView.AtLeftOf(View), BaseScrollView.AtRightOf(View), BaseScrollView.AtBottomOf(View), BaseContentView.WithSameWidth(View) ); BaseScrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); BaseScrollView.AddConstraints( BaseContentView.Bottom().EqualTo().BottomOf(BaseScrollView), BaseContentView.AtTopOf(BaseScrollView) ); BaseContentView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); BaseContentView.AddConstraints( headerLabel.AtTopOf(BaseContentView, 8), headerLabel.AtLeftOf(BaseContentView, 8), headerLabel.AtRightOf(BaseContentView, 8), blueView.Below(headerLabel, 8), blueView.WithSameLeft(headerLabel), blueView.WithSameRight(headerLabel), blueView.Height().EqualTo(50), _tableView.Below(blueView, 8), _tableView.WithSameLeft(headerLabel), _tableView.WithSameRight(headerLabel), _tableViewHeightFluentLayout, greenView.Below(_tableView, 8), greenView.WithSameLeft(headerLabel), greenView.WithSameRight(headerLabel), greenView.WithSameHeight(blueView), footerLabel.Below(greenView, 8), footerLabel.WithSameLeft(headerLabel), footerLabel.WithSameRight(headerLabel), footerLabel.AtBottomOf(BaseContentView, 8) ); }
protected override void SetupLayoutConstraints() { base.SetupLayoutConstraints(); this.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); ContentView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); DateBeginView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); DateEndView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); _contentViewExpanded = ContentView.AtBottomOf(this); _contentViewCollapsedByToolbar = ContentView.Above(DatePickerToolbar); _contentViewCollapsedByToolbar.Active = false; this.AddConstraints( ContentView.FullWidthOf(this)); this.AddConstraints( ContentView.AtTopOf(this), _contentViewExpanded, _contentViewCollapsedByToolbar); this.AddConstraints( VacationsPager.AtTopOf(ContentView, AppDimens.Inset3X), VacationsPager.WithSameCenterX(ContentView), VacationsPager.WithRelativeHeight(ContentView, 0.3f), VacationsPager.WithSameWidth(ContentView)); this.AddConstraints( VacationPageControl.WithSameCenterX(ContentView), VacationPageControl.Below(VacationsPager, AppDimens.Inset1X), VacationPageControl.WithSameWidth(ContentView), VacationPageControl.Height().EqualTo(AppDimens.Inset2X)); this.AddConstraints( AboveDateSeparator.AtLeftOf(ContentView), AboveDateSeparator.Below(VacationPageControl, AppDimens.Inset1X), AboveDateSeparator.AtRightOf(ContentView), AboveDateSeparator.Height().EqualTo(AppDimens.SeparatorSize)); this.AddConstraints( DateBeginView.Below(AboveDateSeparator, AppDimens.Inset1X), DateBeginView.AtLeftOf(ContentView), DateBeginView.WithRelativeWidth(ContentView, 0.5f), DateBeginView.Height().EqualTo(AppDimens.Inset9X)); this.AddConstraints( DateEndView.ToRightOf(DateBeginView), DateEndView.Below(AboveDateSeparator), DateEndView.WithRelativeWidth(ContentView, 0.5f), DateEndView.Height().EqualTo(AppDimens.Inset9X)); this.AddConstraints( BelowDateSeparator.AtLeftOf(ContentView), BelowDateSeparator.Below(DateBeginView, AppDimens.Inset1X), BelowDateSeparator.AtRightOf(ContentView), BelowDateSeparator.Height().EqualTo(AppDimens.SeparatorSize)); this.AddConstraints( StatusSegmentedControl.Below(BelowDateSeparator, AppDimens.Inset4X), StatusSegmentedControl.WithSameCenterX(ContentView)); _toolbarBottom = DatePickerToolbar.AtBottomOf(this); _toolbarAboveStartPicker = DatePickerToolbar.Above(StartDatePicker); _toolbarAboveStartPicker.Active = false; _toolbarAboveEndPicker = DatePickerToolbar.Above(EndDatePicker); _toolbarAboveEndPicker.Active = false; _datePickerToolbarCollapsed = DatePickerToolbar.Height().EqualTo(0); _datePickerToolbarExpanded = DatePickerToolbar.Height().EqualTo(AppDimens.ToolbarSize); _datePickerToolbarExpanded.Active = false; this.AddConstraints( DatePickerToolbar.AtLeftOf(this), DatePickerToolbar.AtRightOf(this), _toolbarBottom, _toolbarAboveStartPicker, _toolbarAboveEndPicker, _datePickerToolbarCollapsed, _datePickerToolbarExpanded); _datePickerStartCollapsed = StartDatePicker.Height().EqualTo(0); _datePickerStartExpanded = StartDatePicker.Height().EqualTo(AppDimens.DatePickerSize); _datePickerStartExpanded.Active = false; this.AddConstraints( StartDatePicker.AtLeftOf(this), StartDatePicker.AtBottomOf(this), StartDatePicker.AtRightOf(this), _datePickerStartCollapsed, _datePickerStartExpanded); _datePickerEndCollapsed = EndDatePicker.Height().EqualTo(0); _datePickerEndExpanded = EndDatePicker.Height().EqualTo(AppDimens.DatePickerSize); _datePickerEndExpanded.Active = false; this.AddConstraints( EndDatePicker.AtLeftOf(this), EndDatePicker.AtBottomOf(this), EndDatePicker.AtRightOf(this), _datePickerEndCollapsed, _datePickerEndExpanded); this.AddConstraints( ActivityIndicator.WithSameCenterX(this), ActivityIndicator.WithSameCenterY(this)); }
public ScrollViewExpandAndCollapse() { View = scrollView = new UIScrollView(View.Bounds); View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; View.BackgroundColor = UIColor.White; expand1 = new UIButton(UIButtonType.System); expand1.TouchUpInside += (object sender, EventArgs e) => { table1Expanded = !table1Expanded; var height = Enumerable .Range(0, table1.NumberOfRowsInSection(0)) .Select(position => { return(table1.RectForRowAtIndexPath(NSIndexPath.FromItemSection(position, 0)).Height); }) .Aggregate((aggregated, nextValue) => aggregated += nextValue); tableHeight1.Minus(tableHeight1.Constant); tableHeight1.Plus(table1Expanded ? height : 0f); this.UpdateViewConstraints(); expand1.SetTitle(table1Expanded ? "Collapse" : "Embiggen'", UIControlState.Normal); UIView.Animate(.2d, View.LayoutIfNeeded); }; expand1.SetTitle("Embiggen'", UIControlState.Normal); View.Add(expand1); table1 = new UITableView(); table1.BackgroundColor = UIColor.Red; table1.Source = new ExpandableSource(); View.Add(table1); expand2 = new UIButton(UIButtonType.System); expand2.TouchUpInside += (object sender, EventArgs e) => { table2Expanded = !table2Expanded; tableHeight2.Minus(tableHeight2.Constant); var height = Enumerable .Range(0, table2.NumberOfRowsInSection(0)) .Select(position => { return(table2.RectForRowAtIndexPath(NSIndexPath.FromItemSection(position, 0)).Height); }) .Aggregate((aggregated, nextValue) => aggregated += nextValue); tableHeight2.Plus(table2Expanded ? height : 0f); this.UpdateViewConstraints(); expand2.SetTitle(table2Expanded ? "Collapse" : "Embiggen'", UIControlState.Normal); UIView.Animate(.6d, View.LayoutIfNeeded); }; expand2.SetTitle("Embiggen'", UIControlState.Normal); View.Add(expand2); table2 = new UITableView(); table2.BackgroundColor = UIColor.Red; table2.Source = new ExpandableSource(); View.Add(table2); View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); tableHeight1 = new FluentLayout(table1, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 0f); tableHeight2 = new FluentLayout(table2, NSLayoutAttribute.Height, NSLayoutRelation.Equal, Enumerable .Range(0, table2.NumberOfRowsInSection(0)) .Select(position => { return(table2.RectForRowAtIndexPath(NSIndexPath.FromItemSection(position, 0)).Height); }) .Aggregate((aggregated, nextValue) => aggregated += nextValue) ); table2Expanded = true; UpdateViewConstraints(); }