Skip to content

Commit 44e3837

Browse files
committed
Improve UI
1 parent e5f8553 commit 44e3837

File tree

7 files changed

+205
-215
lines changed

7 files changed

+205
-215
lines changed

dev/ViewModels/QuranViewModel/QuranViewModel.Command.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,6 @@ private void OnPageLoaded()
77

88
}
99

10-
[RelayCommand]
11-
private void OnTranslationItemChanged()
12-
{
13-
var instance = QuranPage.Instance.GetTabViewItem();
14-
if (CurrentTranslation != null && instance != null)
15-
{
16-
var itemIndex = instance.GetListViewSelectedIndex();
17-
Settings.QuranTranslation = CurrentTranslation;
18-
instance.CurrentQuranTranslation = CurrentTranslation;
19-
instance.GetTranslationText();
20-
instance.GetSuraText();
21-
instance.ScrollIntoView(itemIndex);
22-
}
23-
}
24-
25-
[RelayCommand]
26-
private void OnQariItemChanged()
27-
{
28-
var instance = QuranPage.Instance.GetTabViewItem();
29-
30-
if (CurrentQari != null && instance != null)
31-
{
32-
Settings.QuranAudio = CurrentQari;
33-
instance.CurrentQuranAudio = CurrentQari;
34-
var qariPath = Path.Combine(Settings.AudiosPath, CurrentQari.DirName);
35-
instance.GetAudios(qariPath);
36-
}
37-
}
38-
3910
[RelayCommand]
4011
private void OnSortItemChanged(object sender)
4112
{

dev/ViewModels/QuranViewModel/QuranViewModel.Property.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,6 @@ public partial class QuranViewModel : ObservableRecipient
99
[ObservableProperty]
1010
public AdvancedCollectionView chaptersACV;
1111

12-
[ObservableProperty]
13-
public ObservableCollection<QuranTranslation> translationsCollection = new();
14-
15-
[ObservableProperty]
16-
public QuranTranslation currentTranslation = Settings.QuranTranslation;
17-
18-
[ObservableProperty]
19-
public int translationIndex = -1;
20-
21-
[ObservableProperty]
22-
public ObservableCollection<QuranAudio> qarisCollection = new();
23-
24-
[ObservableProperty]
25-
public QuranAudio currentQari = Settings.QuranAudio;
26-
27-
[ObservableProperty]
28-
public int qariIndex = -1;
29-
3012
[ObservableProperty]
3113
public int listViewSelectedIndex;
3214

dev/ViewModels/QuranViewModel/QuranViewModel.cs

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
using Newtonsoft.Json;
2-
3-
namespace AlAnvar.ViewModels;
1+
namespace AlAnvar.ViewModels;
42

53
public partial class QuranViewModel : ObservableRecipient, ITitleBarAutoSuggestBoxAware
64
{
75
public QuranViewModel()
86
{
97
LoadQuranAsync();
10-
LoadTranslationAsync();
118

129
Task.Run(() =>
1310
{
14-
LoadQaris();
1511
GetDefaultFont();
1612
GetDefaultForeground();
1713
});
@@ -68,62 +64,6 @@ await Task.Run(async () =>
6864
IsActive = false;
6965
}
7066

71-
private void LoadQaris()
72-
{
73-
dispatcherQueue.TryEnqueue(() =>
74-
{
75-
if (Directory.Exists(Settings.AudiosPath))
76-
{
77-
var files = Directory.GetFiles(Settings.AudiosPath, "*.ini", SearchOption.AllDirectories);
78-
if (files.Any())
79-
{
80-
foreach (var file in files)
81-
{
82-
try
83-
{
84-
var audios = JsonConvert.DeserializeObject<QuranAudio>(File.ReadAllText(file));
85-
if (audios is not null)
86-
{
87-
QarisCollection.Add(audios);
88-
}
89-
}
90-
catch (JsonException)
91-
{
92-
continue;
93-
}
94-
}
95-
}
96-
97-
if (QarisCollection.Any())
98-
{
99-
CurrentQari = QarisCollection.Where(audio => ((QuranAudio) audio).DirName == Settings.QuranAudio?.DirName).FirstOrDefault();
100-
QariIndex = QarisCollection.IndexOf(CurrentQari);
101-
}
102-
}
103-
});
104-
}
105-
106-
private async void LoadTranslationAsync()
107-
{
108-
IsActive = true;
109-
await Task.Run(async () =>
110-
{
111-
using var db = new AlAnvarDBContext();
112-
var data = await db.Translations.Where(x => x.IsActive).ToListAsync();
113-
dispatcherQueue.TryEnqueue(() =>
114-
{
115-
TranslationsCollection = new(data);
116-
117-
if (Settings.QuranTranslation != null)
118-
{
119-
CurrentTranslation = TranslationsCollection.FirstOrDefault(x => x.Id == Settings.QuranTranslation.Id);
120-
TranslationIndex = TranslationsCollection.IndexOf(CurrentTranslation);
121-
}
122-
});
123-
});
124-
IsActive = false;
125-
}
126-
12767
public void Search(AutoSuggestBox sender)
12868
{
12969
if (ChaptersACV != null)

dev/Views/QuranPage.xaml

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -159,63 +159,15 @@
159159

160160
<!-- FOOTER -->
161161
<Border Grid.Row="2"
162-
Grid.ColumnSpan="2"
162+
Grid.Column="1"
163163
Margin="5,0,5,5"
164164
Padding="5"
165165
Style="{ThemeResource WarningBorderPanelStyle}">
166166
<StackPanel Orientation="Horizontal"
167167
Spacing="5">
168-
<TextBlock MinWidth="200"
169-
Margin="10,0"
168+
<TextBlock Margin="10,0"
170169
VerticalAlignment="Center"
171170
Text="{x:Bind ViewModel.StatusText, Mode=OneWay}" />
172-
173-
<TextBlock VerticalAlignment="Center"
174-
Text="قاری" />
175-
<ComboBox x:Name="CmbQari"
176-
ItemsSource="{x:Bind ViewModel.QarisCollection, Mode=OneWay}"
177-
SelectedIndex="{x:Bind ViewModel.QariIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
178-
SelectedItem="{x:Bind ViewModel.CurrentQari, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
179-
<ComboBox.ItemTemplate>
180-
<DataTemplate x:DataType="tables:QuranAudio">
181-
<StackPanel Orientation="Horizontal">
182-
<TextBlock Text="{x:Bind PName}" />
183-
<TextBlock Text="-" />
184-
<TextBlock Text="{x:Bind Name}" />
185-
</StackPanel>
186-
</DataTemplate>
187-
</ComboBox.ItemTemplate>
188-
<i:Interaction.Behaviors>
189-
<ic:EventTriggerBehavior EventName="SelectionChanged">
190-
<ic:EventTriggerBehavior.Actions>
191-
<ic:InvokeCommandAction Command="{x:Bind ViewModel.QariItemChangedCommand}" />
192-
</ic:EventTriggerBehavior.Actions>
193-
</ic:EventTriggerBehavior>
194-
</i:Interaction.Behaviors>
195-
</ComboBox>
196-
<TextBlock VerticalAlignment="Center"
197-
Text="مترجم" />
198-
<ComboBox x:Name="CmbTranslation"
199-
ItemsSource="{x:Bind ViewModel.TranslationsCollection, Mode=OneWay}"
200-
SelectedIndex="{x:Bind ViewModel.TranslationIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
201-
SelectedItem="{x:Bind ViewModel.CurrentTranslation, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
202-
<ComboBox.ItemTemplate>
203-
<DataTemplate x:DataType="tables:QuranTranslation">
204-
<StackPanel Orientation="Horizontal">
205-
<TextBlock Text="{x:Bind Name}" />
206-
<TextBlock Text="-" />
207-
<TextBlock Text="{x:Bind Language}" />
208-
</StackPanel>
209-
</DataTemplate>
210-
</ComboBox.ItemTemplate>
211-
<i:Interaction.Behaviors>
212-
<ic:EventTriggerBehavior EventName="SelectionChanged">
213-
<ic:EventTriggerBehavior.Actions>
214-
<ic:InvokeCommandAction Command="{x:Bind ViewModel.TranslationItemChangedCommand}" />
215-
</ic:EventTriggerBehavior.Actions>
216-
</ic:EventTriggerBehavior>
217-
</i:Interaction.Behaviors>
218-
</ComboBox>
219171
</StackPanel>
220172
</Border>
221173
</Grid>

dev/Views/QuranPage.xaml.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,5 @@ private void tabView_SelectionChanged(object sender, SelectionChangedEventArgs e
2626
{
2727
LogoImage.Visibility = Visibility.Visible;
2828
}
29-
30-
var tabItem = tabView.SelectedItem as QuranTabViewItem;
31-
if (tabItem != null)
32-
{
33-
CmbTranslation.SelectedItem = tabItem.CurrentQuranTranslation;
34-
CmbTranslation.SelectedIndex = ViewModel.TranslationsCollection.IndexOf(tabItem.CurrentQuranTranslation);
35-
36-
CmbQari.SelectedItem = tabItem.CurrentQuranAudio;
37-
CmbQari.SelectedIndex = ViewModel.QarisCollection.IndexOf(tabItem.CurrentQuranAudio);
38-
tabItem.SetAppBarToggleButtonValue();
39-
}
4029
}
4130
}

dev/Views/QuranTabViewItem.xaml

Lines changed: 102 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -54,47 +54,110 @@
5454
<RowDefinition Height="auto" />
5555
<RowDefinition />
5656
</Grid.RowDefinitions>
57-
<StackPanel Margin="10"
57+
58+
<StackPanel Margin="5,0,5,0"
5859
VerticalAlignment="Top">
59-
<MediaPlayerElement x:Name="mediaPlayerElement"
60-
HorizontalAlignment="Stretch"
61-
AreTransportControlsEnabled="True"
62-
AutoPlay="False" />
60+
<Grid>
61+
<Grid.ColumnDefinitions>
62+
<ColumnDefinition Width="Auto" />
63+
<ColumnDefinition />
64+
<ColumnDefinition Width="2*" />
65+
</Grid.ColumnDefinitions>
66+
<MediaPlayerElement x:Name="mediaPlayerElement"
67+
Grid.Column="2"
68+
HorizontalAlignment="Stretch"
69+
AreTransportControlsEnabled="True"
70+
AutoPlay="False" />
71+
<TextBlock Grid.Column="0"
72+
Margin="10,0"
73+
VerticalAlignment="Center"
74+
Text="قاری" />
75+
<ComboBox x:Name="CmbQari"
76+
Grid.Column="1"
77+
HorizontalAlignment="Stretch"
78+
VerticalAlignment="Center"
79+
ItemsSource="{x:Bind QarisCollection, Mode=OneWay}"
80+
SelectedIndex="{x:Bind QariIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
81+
SelectedItem="{x:Bind CurrentQari, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
82+
SelectionChanged="CmbQari_SelectionChanged">
83+
<ComboBox.ItemTemplate>
84+
<DataTemplate x:DataType="table:QuranAudio">
85+
<StackPanel Orientation="Horizontal">
86+
<TextBlock Text="{x:Bind PName}" />
87+
<TextBlock Text="-" />
88+
<TextBlock Text="{x:Bind Name}" />
89+
</StackPanel>
90+
</DataTemplate>
91+
</ComboBox.ItemTemplate>
92+
</ComboBox>
93+
</Grid>
94+
6395
<Border Style="{ThemeResource InfoBorderPanelStyle}">
64-
<CommandBar HorizontalAlignment="Center"
65-
Background="Transparent"
66-
DefaultLabelPosition="Right"
67-
IsOpen="False">
68-
<AppBarToggleButton x:Name="btnShowTranslation"
69-
Checked="OnAppBarToggleButtonChanged"
70-
Icon="Caption"
71-
IsChecked="True"
72-
Label="نمایش ترجمه"
73-
Tag="Translation"
74-
Unchecked="OnAppBarToggleButtonChanged" />
75-
<AppBarToggleButton x:Name="btnShowAya"
76-
Checked="OnAppBarToggleButtonChanged"
77-
Icon="Caption"
78-
IsChecked="True"
79-
Label="نمایش آیه"
80-
Tag="Aya"
81-
Unchecked="OnAppBarToggleButtonChanged" />
82-
<AppBarSeparator />
83-
<AppBarButton x:Name="btnNext"
84-
Click="AppBarButton_Click"
85-
Icon="Next"
86-
Label="بعدی"
87-
Tag="Next" />
88-
<AppBarToggleButton x:Name="btnPlay"
89-
Click="AppBarToggleButton_Click"
90-
Icon="Play"
91-
Label="پخش" />
92-
<AppBarButton x:Name="btnPrev"
93-
Click="AppBarButton_Click"
94-
Icon="Previous"
95-
Label="قبلی"
96-
Tag="Previous" />
97-
</CommandBar>
96+
<Grid>
97+
<Grid.ColumnDefinitions>
98+
<ColumnDefinition Width="Auto" />
99+
<ColumnDefinition />
100+
<ColumnDefinition Width="2*" />
101+
</Grid.ColumnDefinitions>
102+
<TextBlock Margin="10,0"
103+
VerticalAlignment="Center"
104+
Text="مترجم" />
105+
<ComboBox x:Name="CmbTranslation"
106+
Grid.Column="1"
107+
HorizontalAlignment="Stretch"
108+
VerticalAlignment="Center"
109+
ItemsSource="{x:Bind TranslationsCollection, Mode=OneWay}"
110+
SelectedIndex="{x:Bind TranslationIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
111+
SelectedItem="{x:Bind CurrentTranslation, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
112+
SelectionChanged="CmbTranslation_SelectionChanged">
113+
<ComboBox.ItemTemplate>
114+
<DataTemplate x:DataType="table:QuranTranslation">
115+
<StackPanel Orientation="Horizontal">
116+
<TextBlock Text="{x:Bind Name}" />
117+
<TextBlock Text="-" />
118+
<TextBlock Text="{x:Bind Language}" />
119+
</StackPanel>
120+
</DataTemplate>
121+
</ComboBox.ItemTemplate>
122+
</ComboBox>
123+
124+
<CommandBar Grid.Column="2"
125+
HorizontalAlignment="Center"
126+
Background="Transparent"
127+
DefaultLabelPosition="Right"
128+
IsOpen="False">
129+
<AppBarToggleButton x:Name="btnShowTranslation"
130+
Checked="OnAppBarToggleButtonChanged"
131+
Icon="Caption"
132+
IsChecked="True"
133+
Label="نمایش ترجمه"
134+
Tag="Translation"
135+
Unchecked="OnAppBarToggleButtonChanged" />
136+
<AppBarToggleButton x:Name="btnShowAya"
137+
Checked="OnAppBarToggleButtonChanged"
138+
Icon="Caption"
139+
IsChecked="True"
140+
Label="نمایش آیه"
141+
Tag="Aya"
142+
Unchecked="OnAppBarToggleButtonChanged" />
143+
<AppBarSeparator />
144+
<AppBarButton x:Name="btnNext"
145+
Click="AppBarButton_Click"
146+
Icon="Next"
147+
Label="بعدی"
148+
Tag="Next" />
149+
<AppBarToggleButton x:Name="btnPlay"
150+
Click="AppBarToggleButton_Click"
151+
Icon="Play"
152+
Label="پخش" />
153+
<AppBarButton x:Name="btnPrev"
154+
Click="AppBarButton_Click"
155+
Icon="Previous"
156+
Label="قبلی"
157+
Tag="Previous" />
158+
</CommandBar>
159+
160+
</Grid>
98161
</Border>
99162

100163
</StackPanel>

0 commit comments

Comments
 (0)