Skip to content

Commit

Permalink
Merge pull request #2429 from nextcloud/fix/neon_framework/login-flow…
Browse files Browse the repository at this point in the history
…-launch-url
  • Loading branch information
provokateurin authored Aug 28, 2024
2 parents 2a48f06 + 251dffa commit 44e7b17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/neon_framework/lib/src/pages/login_flow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:async';

import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
import 'package:neon_framework/models.dart';
import 'package:neon_framework/src/bloc/result.dart';
import 'package:neon_framework/src/blocs/login_flow.dart';
import 'package:neon_framework/src/router.dart';
Expand Down Expand Up @@ -39,7 +38,7 @@ class _LoginFlowPageState extends State<LoginFlowPage> {

initSubscription = bloc.init.listen((result) async {
if (result.hasData) {
await launchUrl(NeonProvider.of<Account>(context), result.requireData.login);
await launchUrl(null, result.requireData.login);
}
});

Expand Down
9 changes: 7 additions & 2 deletions packages/neon_framework/lib/src/utils/launch_url.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import 'package:neon_framework/models.dart';
import 'package:url_launcher/url_launcher.dart' as url_launcher;

/// Completes the [url] using the [account] if necessary and launches it in an external application.
Future<bool> launchUrl(Account account, String url) async {
Future<bool> launchUrl(Account? account, String url) async {
var uri = Uri.parse(url);
if (account != null) {
uri = account.completeUri(uri);
}

return url_launcher.launchUrl(
account.completeUri(Uri.parse(url)),
uri,
mode: url_launcher.LaunchMode.externalApplication,
);
}

0 comments on commit 44e7b17

Please sign in to comment.