Skip to content

Commit 7b58c34

Browse files
committed
Call dispose correctly
1 parent 8a7333b commit 7b58c34

File tree

8 files changed

+26
-25
lines changed

8 files changed

+26
-25
lines changed

src/Bible.Alarm/MauiProgram.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private static void RegisterViewModels(IServiceCollection services)
242242
services.AddTransient<BookSelectionViewModel>();
243243
services.AddTransient<ChapterSelectionViewModel>();
244244
services.AddTransient<AlarmViewModal>();
245-
services.AddSingleton<MediaProgressViewModal>();
245+
services.AddTransient<MediaProgressViewModal>();
246246

247247
// Register ScheduleListItem as transient for list items
248248
services.AddTransient<ScheduleListItem>();

src/Bible.Alarm/Services/UI/NavigationService.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,9 @@ public async Task CloseModalAsync()
152152
var navigation = GetNavigation();
153153
if (navigation.ModalStack.Count > 0)
154154
{
155-
var modal = await navigation.PopModalAsync();
156-
if (modal.BindingContext is IDisposable disposable)
157-
{
158-
disposable.Dispose();
159-
}
155+
await navigation.PopModalAsync();
156+
// Disposal is handled automatically by BaseContentPage.OnNavigatedFrom
157+
// for all modals that inherit from BaseContentPage
160158
}
161159
}
162160
}

src/Bible.Alarm/Views/General/AlarmModal.xaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

3-
<ContentPage
3+
<views:BaseContentPage
44
x:Class="Bible.Alarm.Views.General.AlarmModal"
5+
xmlns:views="clr-namespace:Bible.Alarm.Views"
56
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
67
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
78
xmlns:forms="http://schemas.microsoft.com/dotnet/2021/maui/design"
@@ -10,10 +11,10 @@
1011
xmlns:converters="clr-namespace:Bible.Alarm.Common.ViewHelpers.Converters"
1112
xmlns:fn="clr-namespace:Bible.Alarm.Views"
1213
x:DataType="shared:AlarmViewModal">
13-
<ContentPage.Resources>
14+
<views:BaseContentPage.Resources>
1415
<converters:IsEnabledColorConverter x:Key="isEnabledConverter" />
15-
</ContentPage.Resources>
16-
<ContentPage.Content>
16+
</views:BaseContentPage.Resources>
17+
<views:BaseContentPage.Content>
1718
<Grid HorizontalOptions="Center" VerticalOptions="Fill">
1819
<Grid.RowDefinitions>
1920
<RowDefinition Height="*" />
@@ -223,5 +224,5 @@
223224
</Grid>
224225
</Grid>
225226

226-
</ContentPage.Content>
227-
</ContentPage>
227+
</views:BaseContentPage.Content>
228+
</views:BaseContentPage>

src/Bible.Alarm/Views/General/AlarmModal.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Bible.Alarm.Views.General;
44

5-
public partial class AlarmModal : ContentPage
5+
public partial class AlarmModal : BaseContentPage
66
{
77
public AlarmViewModal ViewModel => BindingContext as AlarmViewModal;
88

src/Bible.Alarm/Views/General/BatteryOptimizationExclusionModal.xaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

3-
<ContentPage
3+
<views:BaseContentPage
44
x:Class="Bible.Alarm.Views.General.BatteryOptimizationExclusionModal"
5+
xmlns:views="clr-namespace:Bible.Alarm.Views"
56
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
67
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
78
xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design"
@@ -10,10 +11,10 @@
1011
xmlns:converters="clr-namespace:Bible.Alarm.Common.ViewHelpers.Converters"
1112
x:DataType="vm:ScheduleViewModel"
1213
mc:Ignorable="d">
13-
<ContentPage.Resources>
14+
<views:BaseContentPage.Resources>
1415
<converters:NegateBooleanConverter x:Key="negateBooleanConverter" />
15-
</ContentPage.Resources>
16-
<ContentPage.Content>
16+
</views:BaseContentPage.Resources>
17+
<views:BaseContentPage.Content>
1718
<StackLayout
1819
Margin="0,0,0,125"
1920
AutomationId="BatteryOptimizationModal"
@@ -98,5 +99,5 @@
9899
TextColor="SlateBlue"
99100
WidthRequest="200" />
100101
</StackLayout>
101-
</ContentPage.Content>
102-
</ContentPage>
102+
</views:BaseContentPage.Content>
103+
</views:BaseContentPage>

src/Bible.Alarm/Views/General/BatteryOptimizationExclusionModal.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Bible.Alarm.Views.General;
22

3-
public partial class BatteryOptimizationExclusionModal : ContentPage
3+
public partial class BatteryOptimizationExclusionModal : BaseContentPage
44
{
55
public BatteryOptimizationExclusionModal()
66
{
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

3-
<ContentPage
3+
<views:BaseContentPage
44
x:Class="Bible.Alarm.Views.General.MediaProgressModal"
5+
xmlns:views="clr-namespace:Bible.Alarm.Views"
56
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
67
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
78
xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design"
@@ -10,7 +11,7 @@
1011
x:DataType="vm:MediaProgressViewModal"
1112
BackgroundColor="White"
1213
mc:Ignorable="d">
13-
<ContentPage.Content>
14+
<views:BaseContentPage.Content>
1415
<StackLayout
1516
HorizontalOptions="Center"
1617
Orientation="Vertical"
@@ -21,5 +22,5 @@
2122
Progress="{Binding Progress}"
2223
ProgressColor="SlateBlue" />
2324
</StackLayout>
24-
</ContentPage.Content>
25-
</ContentPage>
25+
</views:BaseContentPage.Content>
26+
</views:BaseContentPage>

src/Bible.Alarm/Views/General/MediaProgressModal.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace Bible.Alarm.Views.General;
22

33
[XamlCompilation(XamlCompilationOptions.Compile)]
4-
public partial class MediaProgressModal : ContentPage
4+
public partial class MediaProgressModal : BaseContentPage
55
{
66
public MediaProgressModal()
77
{

0 commit comments

Comments
 (0)