Add app rating and sharing functionality to MoreView and MoreWalkerView
This commit is contained in:
parent
0ee468ef8c
commit
421672e8cb
@ -1,4 +1,5 @@
|
||||
using CommunityToolkit.Maui;
|
||||
using Plugin.Maui.AppRating;
|
||||
using CommunityToolkit.Maui;
|
||||
using gehGassi.LocalNotifications;
|
||||
using gehGassiApp.Constants;
|
||||
using gehGassiApp.Core.Data;
|
||||
@ -484,7 +485,8 @@ public static class MauiProgram
|
||||
|
||||
SetHandler();
|
||||
|
||||
return builder.Build();
|
||||
builder.Services.AddSingleton<IAppRating>(AppRating.Default);
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
#region Handler
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using Plugin.Maui.AppRating;
|
||||
using System.Text.Json;
|
||||
using CommunityToolkit.Maui.Core;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
@ -30,7 +31,8 @@ namespace gehGassiApp.ViewModels.More
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly ISystemMessageService _systemMessageService;
|
||||
private readonly IDispatcher _dispatcher;
|
||||
private readonly IPushnotificationService _pushnotificationService;
|
||||
private readonly IPushnotificationService _pushnotificationService;
|
||||
private readonly IAppRating _appRating;
|
||||
|
||||
/// <summary>
|
||||
/// Erstellt eine Instanz
|
||||
@ -40,8 +42,8 @@ namespace gehGassiApp.ViewModels.More
|
||||
/// <param name="systemMessageService">Instanz eines ISystemMessageService</param>
|
||||
/// <param name="dispatcher">Instanz eines IDispatcher</param>
|
||||
/// <param name="pushnotificationService">Instanz eines IPushnotificationService</param>
|
||||
public MoreViewModel(IAccountService accountService, IDialogService dialogService, ISystemMessageService systemMessageService, IDispatcher dispatcher,
|
||||
IPushnotificationService pushnotificationService)
|
||||
public MoreViewModel(IAccountService accountService, IDialogService dialogService, ISystemMessageService systemMessageService, IDispatcher dispatcher,
|
||||
IPushnotificationService pushnotificationService, IAppRating appRating)
|
||||
{
|
||||
_accountService = accountService;
|
||||
_dialogService = dialogService;
|
||||
@ -50,6 +52,43 @@ namespace gehGassiApp.ViewModels.More
|
||||
_pushnotificationService = pushnotificationService;
|
||||
Title = Text.View_Title_More;
|
||||
SelectedMenu = MenuSelected.More;
|
||||
_appRating = appRating;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command für die Store-Bewertung
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
public async Task RateApp()
|
||||
{
|
||||
try
|
||||
{
|
||||
await _appRating.PerformRatingOnStoreAsync(
|
||||
packageName: "com.gehgassi.gehgassi",
|
||||
applicationId: "id1662116305"
|
||||
);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TrackErrorAsync(ex, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command für das Teilen der App
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
public async Task ShareApp()
|
||||
{
|
||||
string url = DeviceInfo.Platform == DevicePlatform.iOS
|
||||
? "https://apps.apple.com/us/app/gehgassi/id1662116305"
|
||||
: "https://play.google.com/store/apps/details?id=com.gehgassi.gehgassi";
|
||||
string text = $"Schau dir die gehgassi App an! {url}";
|
||||
await Share.Default.RequestAsync(new ShareTextRequest
|
||||
{
|
||||
Text = text,
|
||||
Title = "App teilen"
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using Plugin.Maui.AppRating;
|
||||
using System.Text.Json;
|
||||
using CommunityToolkit.Maui.Core;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
@ -30,7 +31,8 @@ namespace gehGassiApp.ViewModels.More
|
||||
private readonly IUserService _userService;
|
||||
private readonly ISystemMessageService _systemMessageService;
|
||||
private readonly IDispatcher _dispatcher;
|
||||
private readonly IPushnotificationService _pushnotificationService;
|
||||
private readonly IPushnotificationService _pushnotificationService;
|
||||
private readonly IAppRating _appRating;
|
||||
|
||||
/// <summary>
|
||||
/// Erstellt eine Instanz
|
||||
@ -41,8 +43,8 @@ namespace gehGassiApp.ViewModels.More
|
||||
/// <param name="systemMessageService">Instanz eines ISystemMessageService</param>
|
||||
/// <param name="dispatcher">Instanz eines IDispatcher</param>
|
||||
/// <param name="pushnotificationService">Instanz eines IPushnotificationService</param>
|
||||
public MoreWalkerViewModel(IAccountService accountService, IDialogService dialogService, IUserService userService, ISystemMessageService systemMessageService, IDispatcher dispatcher,
|
||||
IPushnotificationService pushnotificationService)
|
||||
public MoreWalkerViewModel(IAccountService accountService, IDialogService dialogService, IUserService userService, ISystemMessageService systemMessageService, IDispatcher dispatcher,
|
||||
IPushnotificationService pushnotificationService, IAppRating appRating)
|
||||
{
|
||||
_accountService = accountService;
|
||||
_dialogService = dialogService;
|
||||
@ -52,8 +54,43 @@ namespace gehGassiApp.ViewModels.More
|
||||
_pushnotificationService = pushnotificationService;
|
||||
Title = Text.View_Title_More;
|
||||
SelectedMenu = MenuSelected.More;
|
||||
_appRating = appRating;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command für die Store-Bewertung
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
public async Task RateApp()
|
||||
{
|
||||
try
|
||||
{
|
||||
await _appRating.PerformRatingOnStoreAsync(
|
||||
packageName: "com.gehgassi.gehgassi",
|
||||
applicationId: "id1662116305"
|
||||
);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TrackErrorAsync(ex, true);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Command für das Teilen der App
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
public async Task ShareApp()
|
||||
{
|
||||
string url = DeviceInfo.Platform == DevicePlatform.iOS
|
||||
? "https://apps.apple.com/us/app/gehgassi/id1662116305"
|
||||
: "https://play.google.com/store/apps/details?id=com.gehgassi.gehgassi";
|
||||
string text = $"Schau dir die gehgassi App an! {url}";
|
||||
await Share.Default.RequestAsync(new ShareTextRequest
|
||||
{
|
||||
Text = text,
|
||||
Title = "App teilen"
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// Gibt an ob Switch verfügbar ist
|
||||
/// </summary>
|
||||
|
||||
@ -398,6 +398,76 @@
|
||||
|
||||
<Border Style="{StaticResource Separator}" />
|
||||
|
||||
<Grid
|
||||
ColumnDefinitions="24,*,24"
|
||||
ColumnSpacing="12"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="StartAndExpand">
|
||||
<Image Grid.Column="0" HeightRequest="24">
|
||||
<Image.Source>
|
||||
<FontImageSource
|
||||
FontFamily="MaterialIconsRegular"
|
||||
Glyph="thumb_up"
|
||||
Color="{StaticResource Primary_DarkBlue}" />
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Label
|
||||
Grid.Column="1"
|
||||
HorizontalOptions="StartAndExpand"
|
||||
LineBreakMode="TailTruncation"
|
||||
Style="{StaticResource H5_Blue}"
|
||||
Text="App bewerten"
|
||||
VerticalOptions="Center" />
|
||||
<Image Grid.Column="2" HeightRequest="24">
|
||||
<Image.Source>
|
||||
<FontImageSource
|
||||
FontFamily="IconMoon"
|
||||
Glyph="{x:Static i:IconsMoon.Icon_Chevron_Right}"
|
||||
Color="{StaticResource Primary_DarkBlue}" />
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Grid.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding RateAppCommand}" />
|
||||
</Grid.GestureRecognizers>
|
||||
</Grid>
|
||||
|
||||
<Border Style="{StaticResource Separator}" />
|
||||
|
||||
<Grid
|
||||
ColumnDefinitions="24,*,24"
|
||||
ColumnSpacing="12"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="StartAndExpand">
|
||||
<Image Grid.Column="0" HeightRequest="24">
|
||||
<Image.Source>
|
||||
<FontImageSource
|
||||
FontFamily="MaterialIconsRegular"
|
||||
Glyph="share"
|
||||
Color="{StaticResource Primary_DarkBlue}" />
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Label
|
||||
Grid.Column="1"
|
||||
HorizontalOptions="StartAndExpand"
|
||||
LineBreakMode="TailTruncation"
|
||||
Style="{StaticResource H5_Blue}"
|
||||
Text="App teilen"
|
||||
VerticalOptions="Center" />
|
||||
<Image Grid.Column="2" HeightRequest="24">
|
||||
<Image.Source>
|
||||
<FontImageSource
|
||||
FontFamily="IconMoon"
|
||||
Glyph="{x:Static i:IconsMoon.Icon_Chevron_Right}"
|
||||
Color="{StaticResource Primary_DarkBlue}" />
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Grid.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding ShareAppCommand}" />
|
||||
</Grid.GestureRecognizers>
|
||||
</Grid>
|
||||
|
||||
<Border Style="{StaticResource Separator}" />
|
||||
|
||||
<Grid
|
||||
ColumnDefinitions="24,*,24"
|
||||
ColumnSpacing="12"
|
||||
|
||||
@ -221,8 +221,8 @@
|
||||
</Grid.GestureRecognizers>
|
||||
</Grid>
|
||||
|
||||
<Border Style="{StaticResource Separator}" />
|
||||
|
||||
<Border Style="{StaticResource Separator}" />
|
||||
<Grid
|
||||
ColumnDefinitions="24,*,24"
|
||||
ColumnSpacing="12"
|
||||
@ -256,8 +256,9 @@
|
||||
</Grid.GestureRecognizers>
|
||||
</Grid>
|
||||
|
||||
<Border Style="{StaticResource Separator}" />
|
||||
|
||||
|
||||
<Border Style="{StaticResource Separator}" />
|
||||
<Grid
|
||||
ColumnDefinitions="24,*,24"
|
||||
ColumnSpacing="12"
|
||||
@ -360,6 +361,74 @@
|
||||
<TapGestureRecognizer Command="{Binding FeedbackCommand}" />
|
||||
</Grid.GestureRecognizers>
|
||||
</Grid>
|
||||
<Border Style="{StaticResource Separator}" />
|
||||
<Grid
|
||||
ColumnDefinitions="24,*,24"
|
||||
ColumnSpacing="12"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="StartAndExpand">
|
||||
<Image Grid.Column="0" HeightRequest="24">
|
||||
<Image.Source>
|
||||
<FontImageSource
|
||||
FontFamily="MaterialIconsRegular"
|
||||
Glyph="thumb_up"
|
||||
Color="{StaticResource Primary_DarkBlue}" />
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Label
|
||||
Grid.Column="1"
|
||||
HorizontalOptions="StartAndExpand"
|
||||
LineBreakMode="TailTruncation"
|
||||
Style="{StaticResource H5_Blue}"
|
||||
Text="App bewerten"
|
||||
VerticalOptions="Center" />
|
||||
<Image Grid.Column="2" HeightRequest="24">
|
||||
<Image.Source>
|
||||
<FontImageSource
|
||||
FontFamily="IconMoon"
|
||||
Glyph="{x:Static i:IconsMoon.Icon_Chevron_Right}"
|
||||
Color="{StaticResource Primary_DarkBlue}" />
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Grid.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding RateAppCommand}" />
|
||||
</Grid.GestureRecognizers>
|
||||
</Grid>
|
||||
|
||||
<Border Style="{StaticResource Separator}" />
|
||||
|
||||
<Grid
|
||||
ColumnDefinitions="24,*,24"
|
||||
ColumnSpacing="12"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="StartAndExpand">
|
||||
<Image Grid.Column="0" HeightRequest="24">
|
||||
<Image.Source>
|
||||
<FontImageSource
|
||||
FontFamily="MaterialIconsRegular"
|
||||
Glyph="share"
|
||||
Color="{StaticResource Primary_DarkBlue}" />
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Label
|
||||
Grid.Column="1"
|
||||
HorizontalOptions="StartAndExpand"
|
||||
LineBreakMode="TailTruncation"
|
||||
Style="{StaticResource H5_Blue}"
|
||||
Text="App teilen"
|
||||
VerticalOptions="Center" />
|
||||
<Image Grid.Column="2" HeightRequest="24">
|
||||
<Image.Source>
|
||||
<FontImageSource
|
||||
FontFamily="IconMoon"
|
||||
Glyph="{x:Static i:IconsMoon.Icon_Chevron_Right}"
|
||||
Color="{StaticResource Primary_DarkBlue}" />
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Grid.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding ShareAppCommand}" />
|
||||
</Grid.GestureRecognizers>
|
||||
</Grid>
|
||||
|
||||
<Border Style="{StaticResource Separator}" />
|
||||
|
||||
|
||||
@ -205,6 +205,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.12" />
|
||||
<PackageReference Include="Microsoft.Maui.Graphics.Skia" Version="8.0.100" />
|
||||
<PackageReference Include="Plugin.InAppBilling" Version="8.0.5" />
|
||||
<PackageReference Include="Plugin.Maui.AppRating" Version="1.2.1" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.1.2" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.100" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.100" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user