Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions OneGateApp/Pages/LaunchDAppPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,27 @@
<ToolbarItem Order="Primary" IconImageSource="{FontImageSource &#xe68b;, FontFamily=Icons, Color={toolkit:AppThemeResource Primary}}" IsEnabled="{Binding DApp.IsActive}" Command="{x:Static og:Commands.Share}" CommandParameter="{Binding DApp}" />
<ToolbarItem x:Name="developerToolsButton" Order="Primary" IconImageSource="{FontImageSource &#xe716;, FontFamily=Icons, Color={toolkit:AppThemeResource Primary}}" Clicked="OnDeveloperToolsClicked" />
</ContentPage.ToolbarItems>
<og:BridgeWebView x:Name="webView" Source="{Binding Url}" Navigating="OnNavigating" InvokedFromJavaScript="OnInvokedFromJavaScript" />
</ContentPage>
<Grid>
<og:BridgeWebView x:Name="webView" Source="{Binding Url}" Navigating="OnNavigating" Navigated="OnNavigated" InvokedFromJavaScript="OnInvokedFromJavaScript" />
<Grid BackgroundColor="{toolkit:AppThemeResource PageBackground}" IsVisible="{Binding IsDAppLoading}">
<VerticalStackLayout Spacing="12" HorizontalOptions="Center" VerticalOptions="Center">
<ActivityIndicator IsRunning="{Binding IsDAppLoading}" WidthRequest="32" HeightRequest="32" />
<Label FontAttributes="Bold" HorizontalOptions="Center">
<Label.FormattedText>
<FormattedString>
<Span Text="{x:Static og:Strings.Loading}" />
<Span Text="…" />
</FormattedString>
</Label.FormattedText>
</Label>
</VerticalStackLayout>
</Grid>
<Grid BackgroundColor="{toolkit:AppThemeResource PageBackground}" IsVisible="{Binding HasDAppLoadError}" Padding="32">
<VerticalStackLayout Spacing="16" HorizontalOptions="Center" VerticalOptions="Center" MaximumWidthRequest="420">
<Label Text="{Binding DAppLoadErrorTitle}" FontAttributes="Bold" FontSize="22" HorizontalTextAlignment="Center" />
<Label StyleClass="Secondary" Text="{Binding DAppLoadErrorMessage}" HorizontalTextAlignment="Center" />
<Button Text="{Binding RetryText}" Padding="36,14" Clicked="OnRetryDAppClicked" />
</VerticalStackLayout>
</Grid>
</Grid>
</ContentPage>
62 changes: 61 additions & 1 deletion OneGateApp/Pages/LaunchDAppPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,28 @@ public partial class LaunchDAppPage : ContentPage, IQueryAttributable
readonly HttpClient httpClient;
readonly RpcServer rpcServer;
readonly RpcClient rpcClient;
string? url;

public required DApp DApp { get; set { field = value; OnPropertyChanged(); } }
public required string Url { get; set { field = value; OnPropertyChanged(); } }
public string? Url
{
get => url;
set
{
if (url == value) return;
url = value;
if (!string.IsNullOrWhiteSpace(url))
BeginDAppLoad();
OnPropertyChanged();
}
}
public bool IsFavorite { get; set { field = value; OnPropertyChanged(); } }
public bool IsDeveloperToolsEnabled { get; set { field = value; OnPropertyChanged(); } }
public bool IsDAppLoading { get; set { field = value; OnPropertyChanged(); } }
public bool HasDAppLoadError { get; set { field = value; OnPropertyChanged(); } }
public string DAppLoadErrorTitle { get; set { field = value; OnPropertyChanged(); } } = "";
public string DAppLoadErrorMessage { get; set { field = value; OnPropertyChanged(); } } = "";
public string RetryText => Strings.Retry;

public LaunchDAppPage(IServiceProvider serviceProvider, ProtocolSettings protocolSettings, IWalletProvider walletProvider, WalletAuthorizationService walletAuthorizationService, ApplicationDbContext dbContext, HttpClient httpClient, RpcClient rpcClient, IHomeShortcutService homeShortcutService)
{
Expand Down Expand Up @@ -130,7 +147,50 @@ async void OnNavigating(object sender, WebNavigatingEventArgs e)
{
e.Cancel = true;
await Toast.Show(Strings.RedirectionBlockedText);
IsDAppLoading = false;
HasDAppLoadError = false;
return;
}
BeginDAppLoad();
}

void OnNavigated(object sender, WebNavigatedEventArgs e)
{
IsDAppLoading = false;
if (e.Result == WebNavigationResult.Success || e.Result == WebNavigationResult.Cancel)
{
HasDAppLoadError = false;
return;
}
ShowDAppLoadError(e.Url, e.Result);
}

void OnRetryDAppClicked(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(Url)) return;
BeginDAppLoad();
webView.Reload();
}

void BeginDAppLoad()
{
IsDAppLoading = true;
HasDAppLoadError = false;
}

void ShowDAppLoadError(string failedUrl, WebNavigationResult result)
{
string appName = DApp?.NameLocalizer.Localize() ?? GetHostOrUrl(failedUrl);
DAppLoadErrorTitle = Strings.DAppLoadFailed;
DAppLoadErrorMessage = string.Format(Strings.DAppLoadFailedText, appName, result);
Comment thread
Jim8y marked this conversation as resolved.
Outdated
HasDAppLoadError = true;
}

static string GetHostOrUrl(string url)
{
return Uri.TryCreate(url, UriKind.Absolute, out Uri? uri) && !string.IsNullOrWhiteSpace(uri.Host)
? uri.Host
: url;
}

string CreateDocumentStartScript()
Expand Down
31 changes: 29 additions & 2 deletions OneGateApp/Properties/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ Möchten Sie fortfahren?</value>
<data name="OpenDAppFailedText" xml:space="preserve">
<value>Rückkehr zur DApp fehlgeschlagen</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
Comment thread
Jim8y marked this conversation as resolved.
Outdated
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>Teilen</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ Después de desactivarla, deberá introducir manualmente la contraseña de la bi
<data name="OpenDAppFailedText" xml:space="preserve">
<value>No se pudo volver a la DApp</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
Comment thread
Jim8y marked this conversation as resolved.
Outdated
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>Compartir</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ Voulez-vous continuer ?</value>
<data name="OpenDAppFailedText" xml:space="preserve">
<value>Impossible de revenir à la DApp</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
Comment thread
Jim8y marked this conversation as resolved.
Outdated
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>Partager</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.id.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ Apakah Anda ingin melanjutkan?</value>
<data name="OpenDAppFailedText" xml:space="preserve">
<value>Tidak dapat kembali ke DApp</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
Comment thread
Jim8y marked this conversation as resolved.
Outdated
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>Bagikan</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.it.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ Vuoi continuare?</value>
<data name="OpenDAppFailedText" xml:space="preserve">
<value>Impossibile tornare alla DApp</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
Comment thread
Jim8y marked this conversation as resolved.
Outdated
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>Condividi</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@
<data name="OpenDAppFailedText" xml:space="preserve">
<value>DAppに戻れませんでした</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
Comment thread
Jim8y marked this conversation as resolved.
Outdated
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>共有</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.ko.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@
<data name="OpenDAppFailedText" xml:space="preserve">
<value>DApp으로 돌아갈 수 없습니다</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
Comment thread
Jim8y marked this conversation as resolved.
Outdated
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>공유</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.nl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ Wilt u doorgaan?</value>
<data name="OpenDAppFailedText" xml:space="preserve">
<value>Kan niet terugkeren naar de DApp</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
Comment thread
Jim8y marked this conversation as resolved.
Outdated
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>Delen</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.pt-BR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ Deseja continuar?</value>
<data name="OpenDAppFailedText" xml:space="preserve">
<value>Não foi possível voltar para a DApp</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
Comment thread
Jim8y marked this conversation as resolved.
Outdated
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>Compartilhar</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ Do you want to continue?</value>
<data name="OpenDAppFailedText" xml:space="preserve">
<value>Unable to return to the DApp</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>Share</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@
<data name="OpenDAppFailedText" xml:space="preserve">
<value>Не удалось вернуться в DApp</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
Comment thread
Jim8y marked this conversation as resolved.
Outdated
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>Поделиться</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.tr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ Devam etmek istiyor musunuz?</value>
<data name="OpenDAppFailedText" xml:space="preserve">
<value>DApp'e geri dönülemedi</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
Comment thread
Jim8y marked this conversation as resolved.
Outdated
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>Paylaş</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.vi.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ Bạn có muốn tiếp tục không?</value>
<data name="OpenDAppFailedText" xml:space="preserve">
<value>Không thể quay lại DApp</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp did not load</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} could not be loaded. Check your connection and try again. Status: {1}</value>
Comment thread
Jim8y marked this conversation as resolved.
Outdated
</data>
<data name="Retry" xml:space="preserve">
<value>Retry</value>
</data>
<data name="Share" xml:space="preserve">
<value>Chia sẻ</value>
</data>
Expand Down
9 changes: 9 additions & 0 deletions OneGateApp/Properties/Strings.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@
<data name="OpenDAppFailedText" xml:space="preserve">
<value>无法返回 DApp</value>
</data>
<data name="DAppLoadFailed" xml:space="preserve">
<value>DApp 未能加载</value>
</data>
<data name="DAppLoadFailedText" xml:space="preserve">
<value>{0} 暂时无法加载。请检查网络连接后重试。状态:{1}</value>
</data>
<data name="Retry" xml:space="preserve">
<value>重试</value>
</data>
<data name="Share" xml:space="preserve">
<value>分享</value>
</data>
Expand Down
Loading