Fix group cue frame and add collapsing

This commit is contained in:
2020-10-18 22:04:42 -05:00
parent a486348981
commit ca3eda5daa
3 changed files with 75 additions and 6 deletions
+51 -5
View File
@@ -12,6 +12,11 @@ namespace qController.UI
RowSpacing = 0;
RowDefinitions.Add(new RowDefinition { Height = new GridLength(40) });
ColumnDefinitions = new ColumnDefinitionCollection
{
new ColumnDefinition{Width = GridLength.Star},
new ColumnDefinition{Width = new GridLength(4,GridUnitType.Star)}
};
//Group List "Frame" added early so other children or "on top"
if (cue.cues.Count > 0)
@@ -19,21 +24,39 @@ namespace qController.UI
var cueFrame = new Frame
{
BackgroundColor = Color.Transparent,
BorderColor = Color.Black
BorderColor = Color.Black,
Margin = qCueViewModel.nestPadding
};
Children.Add(cueFrame);
Children.Add(cueFrame,1,0);
Grid.SetRowSpan(cueFrame, cue.cues.Count + 1);
Grid.SetColumnSpan(cueFrame, ColumnDefinitions.Count-1);
}
var cueLabel = new Label
{
BindingContext = qCueViewModel,
HorizontalOptions = LayoutOptions.StartAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalTextAlignment = TextAlignment.Center,
Padding = new Thickness(10,0,0,0)
//BackgroundColor = Color.Blue,
};
cueLabel.SetBinding(Label.TextProperty, "name", BindingMode.OneWay);
cueLabel.SetDynamicResource(Label.TextColorProperty, "PrimaryTextColor");
cueLabel.SetBinding(Label.PaddingProperty, "nestPadding", BindingMode.OneWay);
var cueTypeLabel = new Label
{
FontFamily = App.QFont,
BindingContext = qCueViewModel,
HorizontalOptions = LayoutOptions.StartAndExpand,
HorizontalTextAlignment = TextAlignment.Start,
VerticalTextAlignment = TextAlignment.Center,
Padding = 0,
Margin = new Thickness(10,0,0,0),
FontSize = App.HeightUnit * 3,
//BackgroundColor = Color.Red
};
cueTypeLabel.SetBinding(Label.TextProperty, "type", BindingMode.OneWay);
cueTypeLabel.SetDynamicResource(Label.TextColorProperty, "IconTextColor");
//Section for selecting a cue by tapping the name Label
var selectCueGesture = new TapGestureRecognizer();
@@ -43,6 +66,24 @@ namespace qController.UI
};
cueLabel.GestureRecognizers.Add(selectCueGesture);
//Add collapse gesture to the cue type icon if it is a group cue
if (cue.IsGroup)
{
var CollapseGroupCueGesture = new TapGestureRecognizer();
CollapseGroupCueGesture.Tapped += (sender, e) =>
{
if (cue.IsGroup)
{
qCueViewModel.IsCollapsed = !qCueViewModel.IsCollapsed;
for (var i = 1; i < RowDefinitions.Count; i++)
{
RowDefinitions[i].Height = qCueViewModel.IsCollapsed ? 0 : GridLength.Auto;
}
}
};
cueTypeLabel.GestureRecognizers.Add(CollapseGroupCueGesture);
}
var cueBackground = new Frame
{
BindingContext = qCueViewModel,
@@ -54,6 +95,7 @@ namespace qController.UI
cueBackground.SetBinding(BackgroundColorProperty, "color", BindingMode.OneWay);
//TODO: find a solution so the selected cue indicator is under the frame
var cueSelectedIndicator = new Frame
{
BindingContext = qCueViewModel,
@@ -64,8 +106,12 @@ namespace qController.UI
cueSelectedIndicator.SetBinding(IsVisibleProperty, "IsSelected");
Children.Add(cueSelectedIndicator, 0, 0);
Grid.SetColumnSpan(cueSelectedIndicator, ColumnDefinitions.Count);
Children.Add(cueBackground, 0, 0);
Children.Add(cueLabel, 0, 0);
Grid.SetColumnSpan(cueBackground, ColumnDefinitions.Count);
Children.Add(cueTypeLabel, 0, 0);
Children.Add(cueLabel, 1, 0);
}
}
}
@@ -13,6 +13,7 @@ namespace qController.ViewModels
{
QCue cue;
bool isSelected = false;
bool isCollapsed = false;
public event PropertyChangedEventHandler PropertyChanged;
public QCueViewModel(QCue cue, bool checkPlayback)
@@ -56,6 +57,14 @@ namespace qController.ViewModels
IsSelected = args.cueID == cue.uid;
}
public Thickness nestPadding
{
get
{
return new Thickness((cue.nestLevel - 1) * 10,0,0,0);
}
}
public string name
{
get
@@ -135,5 +144,18 @@ namespace qController.ViewModels
OnPropertyChanged();
}
}
public bool IsCollapsed
{
get
{
return isCollapsed;
}
set
{
isCollapsed = value;
OnPropertyChanged();
}
}
}
}
@@ -137,8 +137,9 @@ namespace qController
cueGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
var aCueGrid = cueToGrid(aCue);
cueGridDict.Add(aCue.uid, aCueGrid);
aCueGrid.Margin = new Thickness(10, 0, 0, 0);
aCueGrid.Margin = new Thickness(0, 0, 0, 0);
cueGrid.Children.Add(aCueGrid, 0, aCue.sortIndex + 1);
Grid.SetColumnSpan(aCueGrid,cueGrid.ColumnDefinitions.Count);
}
}
return cueGrid;