Skip to content

Commit caf5af2

Browse files
committed
Improve UI
1 parent 427e9e9 commit caf5af2

File tree

5 files changed

+95
-23
lines changed

5 files changed

+95
-23
lines changed

dev/ViewModels/Settings/FontSettingViewModel.cs

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public FontSettingViewModel()
3434

3535
#region Change Color
3636
[RelayCommand]
37-
private async void OnChooseColor(string settingType)
37+
private async Task OnChooseColor(string settingType)
3838
{
3939
var scrollViewer = new ScrollViewer { Margin = new Thickness(10) };
4040
var colorPicker = new ColorPicker
@@ -43,7 +43,7 @@ private async void OnChooseColor(string settingType)
4343
IsMoreButtonVisible = false,
4444
IsColorSliderVisible = true,
4545
IsColorChannelTextInputVisible = false,
46-
IsHexInputVisible = false,
46+
IsHexInputVisible = true,
4747
IsAlphaEnabled = false,
4848
IsAlphaSliderVisible = false,
4949
IsAlphaTextInputVisible = false,
@@ -52,21 +52,29 @@ private async void OnChooseColor(string settingType)
5252

5353
colorPicker.ColorChanged += (s, e) =>
5454
{
55-
var selectedColor = new SolidColorBrush(e.NewColor);
56-
switch (settingType)
55+
try
56+
{
57+
var selectedColor = new SolidColorBrush(e.NewColor);
58+
switch (settingType)
59+
{
60+
case "Aya":
61+
TxtAyaForeground = selectedColor;
62+
Settings.AyatForeground = e.NewColor.ToString();
63+
break;
64+
case "AyaNumber":
65+
TxtAyaNumberForeground = selectedColor;
66+
Settings.AyatNumberForeground = e.NewColor.ToString();
67+
break;
68+
case "Translation":
69+
TxtTranslationForeground = selectedColor;
70+
Settings.TranslationForeground = e.NewColor.ToString();
71+
break;
72+
}
73+
74+
FontSettingPage.Instance.RefreshTextBlockForeground();
75+
}
76+
catch (Exception)
5777
{
58-
case "Aya":
59-
TxtAyaForeground = selectedColor;
60-
Settings.AyatForeground = e.NewColor.ToString();
61-
break;
62-
case "AyaNumber":
63-
TxtAyaNumberForeground = selectedColor;
64-
Settings.AyatNumberForeground = e.NewColor.ToString();
65-
break;
66-
case "Translation":
67-
TxtTranslationForeground = selectedColor;
68-
Settings.TranslationForeground = e.NewColor.ToString();
69-
break;
7078
}
7179
};
7280

@@ -79,6 +87,8 @@ private async void OnChooseColor(string settingType)
7987
};
8088
contentDialog.Title = "انتخاب رنگ";
8189
contentDialog.PrimaryButtonText = "تایید";
90+
contentDialog.SecondaryButtonText = "انصراف";
91+
contentDialog.PrimaryButtonStyle = (Style) Application.Current.Resources["AccentButtonStyle"];
8292
contentDialog.FlowDirection = FlowDirection.RightToLeft;
8393
await contentDialog.ShowAsyncQueue();
8494
}
@@ -90,6 +100,7 @@ private void OnResetColors()
90100
Settings.AyatNumberForeground = null;
91101
Settings.TranslationForeground = null;
92102
GetDefaultColors();
103+
FontSettingPage.Instance.RefreshTextBlockForeground2();
93104
}
94105

95106
private void GetDefaultColors()

dev/Views/QuranTabViewItem.xaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@
2626
<TextBlock Padding="5,10,5,5"
2727
FontFamily="{Binding ElementName=tabViewItem, Path=DataContext.viewModel.AyatFontFamily}"
2828
FontSize="{Binding ElementName=tabViewItem, Path=DataContext.viewModel.AyatFontSize}"
29-
Foreground="{Binding ElementName=tabViewItem, Path=DataContext.viewModel.AyatForeground}"
29+
Loaded="TextBlock_Loaded"
30+
Tag="Ayat"
3031
Text="{x:Bind AyahText}"
3132
TextWrapping="Wrap"
3233
Visibility="{Binding ElementName=tabViewItem, Path=DataContext.viewModel.IsOriginalTextActive, Converter={StaticResource BoolToVisibilityConverter}}" />
3334
<TextBlock Grid.Row="1"
3435
Padding="5,0,5,5"
3536
FontFamily="{Binding ElementName=tabViewItem, Path=DataContext.viewModel.TranslationFontFamily}"
3637
FontSize="{Binding ElementName=tabViewItem, Path=DataContext.viewModel.TranslationFontSize}"
37-
Foreground="{Binding ElementName=tabViewItem, Path=DataContext.viewModel.TranslationForeground}"
38+
Loaded="TextBlock_Loaded"
39+
Tag="Translation"
3840
Text="{x:Bind TranslationText}"
3941
TextWrapping="Wrap"
4042
Visibility="{Binding ElementName=tabViewItem, Path=DataContext.viewModel.IsTranslationActive, Converter={StaticResource BoolToVisibilityConverter}}" />
@@ -44,7 +46,8 @@
4446
FontFamily="{Binding ElementName=tabViewItem, Path=DataContext.viewModel.AyatNumberFontFamily}"
4547
FontSize="{Binding ElementName=tabViewItem, Path=DataContext.viewModel.AyatNumberFontSize}"
4648
FontWeight="Bold"
47-
Foreground="{Binding ElementName=tabViewItem, Path=DataContext.viewModel.AyatNumberForeground}"
49+
Loaded="TextBlock_Loaded"
50+
Tag="AyatNumber"
4851
Text="{x:Bind AyaDetail}" />
4952
</Grid>
5053
</DataTemplate>

dev/Views/QuranTabViewItem.xaml.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,4 +623,30 @@ private void CmbTranslation_SelectionChanged(object sender, SelectionChangedEven
623623
ScrollIntoView(itemIndex);
624624
}
625625
}
626+
627+
private void TextBlock_Loaded(object sender, RoutedEventArgs e)
628+
{
629+
var textblock = sender as TextBlock;
630+
switch (textblock?.Tag?.ToString())
631+
{
632+
case "Ayat":
633+
if (Settings.AyatForeground != null)
634+
{
635+
textblock.Foreground = viewModel.AyatForeground;
636+
}
637+
break;
638+
case "AyatNumber":
639+
if (Settings.AyatNumberForeground != null)
640+
{
641+
textblock.Foreground = viewModel.AyatNumberForeground;
642+
}
643+
break;
644+
case "Translation":
645+
if (Settings.TranslationForeground != null)
646+
{
647+
textblock.Foreground = viewModel.TranslationForeground;
648+
}
649+
break;
650+
}
651+
}
626652
}

dev/Views/Settings/FontSettingPage.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
Header="رنگ متن آیات (کلیک کنید)"
2828
HeaderIcon="{wuc:BitmapIcon Source=Assets/Fluent/color.png}"
2929
IsClickEnabled="True">
30-
<TextBlock Foreground="{x:Bind ViewModel.TxtAyaForeground, Mode=OneWay}"
30+
<TextBlock x:Name="TxtAyat"
3131
Text="بسم الله الرحمن الرحیم" />
3232
</wuc:SettingsCard>
3333
<wuc:SettingsCard ActionIcon="{wuc:SymbolIcon Symbol=FontColor}"
@@ -36,7 +36,7 @@
3636
Header="رنگ متن شماره آیات (کلیک کنید)"
3737
HeaderIcon="{wuc:BitmapIcon Source=Assets/Fluent/color.png}"
3838
IsClickEnabled="True">
39-
<TextBlock Foreground="{x:Bind ViewModel.TxtAyaNumberForeground, Mode=OneWay}"
39+
<TextBlock x:Name="TxtAyatNumber"
4040
Text="(1:7)" />
4141
</wuc:SettingsCard>
4242
<wuc:SettingsCard ActionIcon="{wuc:SymbolIcon Symbol=FontColor}"
@@ -45,7 +45,7 @@
4545
Header="رنگ متن ترجمه آیات (کلیک کنید)"
4646
HeaderIcon="{wuc:BitmapIcon Source=Assets/Fluent/color.png}"
4747
IsClickEnabled="True">
48-
<TextBlock Foreground="{x:Bind ViewModel.TxtTranslationForeground, Mode=OneWay}"
48+
<TextBlock x:Name="TxtTranslation"
4949
Text="بنام خداوند بخشنده مهربان" />
5050
</wuc:SettingsCard>
5151
</wuc:SettingsExpander.Items>

dev/Views/Settings/FontSettingPage.xaml.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,43 @@ public sealed partial class FontSettingPage : Page
66
{
77
public FontSettingViewModel ViewModel { get; }
88
public string BreadCrumbBarItemText { get; set; }
9-
9+
public static FontSettingPage Instance { get; set; }
1010
public FontSettingPage()
1111
{
1212
ViewModel = App.GetService<FontSettingViewModel>();
1313
this.InitializeComponent();
14+
Instance = this;
15+
Loaded += FontSettingPage_Loaded;
16+
}
17+
18+
private void FontSettingPage_Loaded(object sender, RoutedEventArgs e)
19+
{
20+
RefreshTextBlockForeground();
21+
}
22+
23+
public void RefreshTextBlockForeground()
24+
{
25+
if (Settings.AyatForeground != null)
26+
{
27+
TxtAyat.Foreground = ViewModel.TxtAyaForeground;
28+
}
29+
30+
if (Settings.AyatNumberForeground != null)
31+
{
32+
TxtAyatNumber.Foreground = ViewModel.TxtAyaNumberForeground;
33+
}
34+
35+
if (Settings.TranslationForeground != null)
36+
{
37+
TxtTranslation.Foreground = ViewModel.TxtTranslationForeground;
38+
}
39+
}
40+
41+
public void RefreshTextBlockForeground2()
42+
{
43+
TxtAyat.Foreground = null;
44+
TxtAyatNumber.Foreground = null;
45+
TxtTranslation.Foreground = null;
1446
}
1547

1648
protected override void OnNavigatedTo(NavigationEventArgs e)

0 commit comments

Comments
 (0)