Skip to content

Commit 82ab556

Browse files
committed
feat: add default title text color, update v-timeline
1 parent d0b6c41 commit 82ab556

15 files changed

+387
-220
lines changed

samples/src/Views/VTimeLineView.xaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,62 @@
2121
<control:VTimeLine ItemsSource="{Binding ProBarList}"></control:VTimeLine>
2222

2323

24+
<Label Text="Hide Remark"
25+
Style="{StaticResource ItemDetailsLabel}" />
26+
27+
28+
<control:VTimeLine ItemsSource="{Binding ProBarList1}"
29+
IsShowRemark="False"></control:VTimeLine>
30+
31+
32+
<Label Text="Customized Remark"
33+
Style="{StaticResource ItemDetailsLabel}" />
34+
35+
36+
<control:VTimeLine ItemsSource="{Binding ProBarList1}">
37+
38+
<control:VTimeLine.RemarkSlot>
39+
<VerticalStackLayout>
40+
<Label Text="Remark:"
41+
FontAttributes="Bold"
42+
Margin="0,10,0,10" />
43+
<Grid RowDefinitions="*,*,*"
44+
ColumnSpacing="5"
45+
ColumnDefinitions="auto,*">
46+
47+
48+
<Rectangle WidthRequest="7"
49+
HeightRequest="7"
50+
Grid.Row="0"
51+
Fill="{StaticResource NormalFill}" />
52+
<Label Text="Procedure to be done."
53+
Grid.Row="0"
54+
Grid.Column="1"
55+
TextColor="{StaticResource Gray360}" />
56+
<Rectangle WidthRequest="7"
57+
HeightRequest="7"
58+
Grid.Row="1"
59+
Fill="{StaticResource SuccessFill}" />
60+
<Label Text="Procedure completed."
61+
Grid.Row="1"
62+
Grid.Column="1"
63+
TextColor="{StaticResource Gray360}" />
64+
65+
<Rectangle WidthRequest="7"
66+
HeightRequest="7"
67+
Grid.Row="2"
68+
Fill="{StaticResource ActiveFill}" />
69+
<Label Text="Present procedure."
70+
Grid.Row="2"
71+
Grid.Column="1"
72+
TextColor="{StaticResource Gray360}" />
73+
74+
</Grid>
75+
</VerticalStackLayout>
76+
77+
</control:VTimeLine.RemarkSlot>
78+
</control:VTimeLine>
79+
2480
</VerticalStackLayout>
2581
</ScrollView>
2682

src/Controls/VButton.xaml.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private void VButton_Loaded(object? sender, EventArgs e)
2525
public static readonly BindableProperty TitleTextProperty = BindableProperty.Create(
2626
nameof(TitleText),
2727
typeof(string),
28-
typeof(VCollectionItem),
28+
typeof(VButton),
2929
"TITLE HERE"
3030
);
3131

@@ -51,7 +51,8 @@ private void VButton_Loaded(object? sender, EventArgs e)
5151
public static readonly BindableProperty TextColorProperty = BindableProperty.Create(
5252
nameof(TextColor),
5353
typeof(Color),
54-
typeof(VButton)
54+
typeof(VButton),
55+
default
5556
);
5657

5758
public static BindableProperty FontSizeProperty = BindableProperty.Create(
@@ -105,7 +106,13 @@ private void SetButtonStyle(ButtonStyles style)
105106
default:
106107
break;
107108
}
108-
this.Style = Application.Current.Resources[styleResources] as Style;
109+
this.Style = Application.Current?.Resources[styleResources] as Style;
110+
if (TextColor == default)
111+
{
112+
object textColor = default;
113+
Application.Current?.Resources.TryGetValue("OnSurface", out textColor);
114+
TextColor = textColor as Color;
115+
}
109116
}
110117

111118
public static readonly BindableProperty CommandProperty = BindableProperty.Create(

src/Controls/VCollectionExpandableItem.xaml.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ public VCollectionExpandableItem()
1212
InitializeComponent();
1313
Loaded += VCollectionExpandableItem_Loaded;
1414
GoToState(IsExpanded);
15+
if (TitleTextColor == default)
16+
{
17+
object textColor = default;
18+
Application.Current?.Resources.TryGetValue("OnSurface", out textColor);
19+
TitleTextColor = textColor as Color;
20+
}
21+
1522
}
1623

1724
private void VCollectionExpandableItem_Loaded(object sender, EventArgs e)
@@ -113,7 +120,8 @@ object newValue
113120
nameof(TitleTextColor),
114121
typeof(Color),
115122
typeof(VCollectionExpandableItem),
116-
null
123+
default
124+
117125
);
118126

119127
public bool IsExpanded

src/Controls/VCollectionItem.xaml.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Windows.Input;
2+
using Microsoft.Maui.Graphics.Text;
23

34
namespace VControl.Controls;
45

@@ -12,6 +13,12 @@ public VCollectionItem()
1213
{
1314
InitializeComponent();
1415
Loaded += VCollectionItem_Loaded;
16+
if (TitleTextColor == default)
17+
{
18+
object textColor = default;
19+
Application.Current?.Resources.TryGetValue("OnSurface", out textColor);
20+
TitleTextColor = textColor as Color;
21+
}
1522
}
1623

1724
private void VCollectionItem_Loaded(object sender, EventArgs e)
@@ -85,7 +92,7 @@ private void VCollectionItem_Loaded(object sender, EventArgs e)
8592
nameof(TitleTextColor),
8693
typeof(Color),
8794
typeof(VCollectionItem),
88-
null
95+
default
8996
);
9097

9198
public ICommand EditCommand

src/Controls/VExpander.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public IExpanderAnimation ExpanderAnimation
3737
nameof(TitleTextColor),
3838
typeof(Color),
3939
typeof(VExpander),
40-
null
40+
default
4141
);
4242

4343

@@ -88,6 +88,12 @@ public VExpander()
8888
InitializeComponent();
8989
Loaded += VExpander_Loaded;
9090
UpdateExpandDirection();
91+
if (TitleTextColor == default)
92+
{
93+
object textColor = default;
94+
Application.Current?.Resources.TryGetValue("OnSurface", out textColor);
95+
TitleTextColor = textColor as Color;
96+
}
9197
}
9298

9399
private void VExpander_Loaded(object sender, EventArgs e)

src/Controls/VFormItem.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ public VFormItem()
99
InitializeComponent();
1010
Loaded += VFormItem_Loaded;
1111
this.IsRequiredMark = "*";
12+
if (TitleTextColor == default)
13+
{
14+
object textColor = default;
15+
Application.Current?.Resources.TryGetValue("OnSurface", out textColor);
16+
TitleTextColor = textColor as Color;
17+
}
1218
}
1319

1420
private void VFormItem_Loaded(object sender, EventArgs e)
@@ -163,7 +169,7 @@ private static void OnIsRequiredProperty(BindableObject bindable, object oldValu
163169
nameof(TitleTextColor),
164170
typeof(Color),
165171
typeof(VFormItem),
166-
null
172+
default
167173
);
168174

169175
private string _isRequiredMark;

src/Controls/VMenuCell.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ public partial class VMenuCell : ViewCell
77
public VMenuCell()
88
{
99
InitializeComponent();
10+
if (MenuTextColor == default)
11+
{
12+
object textColor = default;
13+
Application.Current?.Resources.TryGetValue("OnSurface", out textColor);
14+
MenuTextColor = textColor as Color;
15+
}
1016
}
1117

1218
public static readonly BindableProperty CommandProperty = BindableProperty.Create(
@@ -65,7 +71,7 @@ public VMenuCell()
6571
nameof(MenuTextColor),
6672
typeof(Color),
6773
typeof(VMenuCell),
68-
null
74+
default
6975
);
7076

7177
public ICommand Command

src/Controls/VSearchBar.xaml.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ public VSearchBar()
88
{
99
InitializeComponent();
1010
Loaded += VSearchBar_Loaded;
11+
if (TitleColor == default)
12+
{
13+
object textColor = default;
14+
Application.Current?.Resources.TryGetValue("OnSurface", out textColor);
15+
TitleColor = textColor as Color;
16+
}
1117
}
1218

1319
private void VSearchBar_Loaded(object? sender, EventArgs e)
@@ -86,12 +92,12 @@ private void VSearchBar_Loaded(object? sender, EventArgs e)
8692
nameof(TitleColor),
8793
typeof(Color),
8894
typeof(VSearchBar),
89-
null
95+
default
9096
);
9197
public static readonly BindableProperty HasSearchButtonProperty = BindableProperty.Create(
9298
nameof(HasSearchButton),
9399
typeof(bool),
94-
typeof(VCollectionItem),
100+
typeof(VSearchBar),
95101
true
96102
);
97103

src/Controls/VTimeLine.xaml

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,39 @@
2626
</BindableLayout.ItemTemplate>
2727
</StackLayout>
2828

29+
<ContentView Grid.Row="2"
30+
Grid.ColumnSpan="2"
31+
BindingContext="{Reference this}"
32+
IsVisible="{Binding IsShowRemark}"
33+
x:Name="RemarkContent">
34+
<VerticalStackLayout>
35+
<Label Text="Remark:"
36+
FontAttributes="Bold"
37+
Margin="0,10,0,10" />
38+
<FlexLayout Wrap="Wrap"
39+
AlignItems="Center">
40+
<Ellipse WidthRequest="7"
41+
HeightRequest="7"
42+
Fill="{StaticResource NormalFill}"
43+
Margin="0,0,5,0" />
44+
<Label Text="Procedure to be done."
45+
TextColor="{StaticResource Gray360}" />
46+
<Ellipse WidthRequest="7"
47+
HeightRequest="7"
48+
Fill="{StaticResource SuccessFill}"
49+
Margin="20,0,5,0" />
50+
<Label Text="Procedure completed."
51+
TextColor="{StaticResource Gray360}" />
52+
53+
<Ellipse WidthRequest="7"
54+
HeightRequest="7"
55+
Fill="{StaticResource ActiveFill}"
56+
Margin="0,0,5,0" />
57+
<Label Text="Present procedure."
58+
TextColor="{StaticResource Gray360}" />
59+
</FlexLayout>
60+
</VerticalStackLayout>
61+
</ContentView>
2962

30-
<Label Text="Remark:"
31-
FontAttributes="Bold"
32-
Margin="0,0,0,10" />
33-
<HorizontalStackLayout>
34-
<Rectangle WidthRequest="7"
35-
HeightRequest="7"
36-
Fill="#B3B3B3"
37-
RadiusX="7"
38-
RadiusY="7"
39-
Margin="0,0,5,0" />
40-
<Label Text="Procedure to be done."
41-
TextColor="{StaticResource Gray360}" />
42-
<Rectangle WidthRequest="7"
43-
HeightRequest="7"
44-
Fill="#01ae54"
45-
RadiusX="7"
46-
RadiusY="7"
47-
Margin="20,0,5,0" />
48-
<Label Text="Procedure completed."
49-
TextColor="{StaticResource Gray360}" />
50-
</HorizontalStackLayout>
51-
<HorizontalStackLayout Margin="0,10,0,0">
52-
<Rectangle WidthRequest="7"
53-
HeightRequest="7"
54-
Fill="{StaticResource Primary}"
55-
RadiusX="7"
56-
RadiusY="7"
57-
Margin="0,0,5,0" />
58-
<Label Text="Present procedure."
59-
TextColor="{StaticResource Gray360}" />
60-
</HorizontalStackLayout>
6163
</VerticalStackLayout>
6264
</ContentView>

src/Controls/VTimeLine.xaml.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,27 @@ public partial class VTimeLine : ContentView
77
public VTimeLine()
88
{
99
InitializeComponent();
10+
Loaded += VTimeLine_Loaded;
1011
}
1112

13+
private void VTimeLine_Loaded(object? sender, EventArgs e)
14+
{
15+
if (this.RemarkSlot != default)
16+
{
17+
(this.FindByName("RemarkContent") as ContentView).Content = (View)this.RemarkSlot;
18+
}
19+
}
20+
21+
public IView RemarkSlot { get; set; }
22+
23+
24+
public static readonly BindableProperty IsShowRemarkProperty = BindableProperty.Create(
25+
nameof(IsShowRemark),
26+
typeof(bool),
27+
typeof(VTimeLine),
28+
true
29+
);
30+
1231
public static readonly BindableProperty SelectedIndexProperty = BindableProperty.Create(
1332
nameof(SelectedIndex),
1433
typeof(int),
@@ -70,6 +89,12 @@ object newValue
7089
}
7190
}
7291

92+
public bool IsShowRemark
93+
{
94+
get { return (bool)GetValue(IsShowRemarkProperty); }
95+
set { SetValue(IsShowRemarkProperty, value); }
96+
}
97+
7398
public object SelectedItem
7499
{
75100
get { return GetValue(SelectedItemProperty); }

0 commit comments

Comments
 (0)