Skip to content

Commit

Permalink
feat: add a new example for oauth that uses webview (#147)
Browse files Browse the repository at this point in the history
* feat: add a new example for oauth that uses webview

* chore(deps): update `flutter_inappwebview` dependency

* chore(deps): run `flutter pub get` and `pod install --repo-update`

* feat: add new launch option for oauth_webview

* chore(refactor): fix:

- alignment of buttons
- replace deprecated params and types

* chore(deps): bump dart version to the latest

* fix: remove deprecated parameter with the new replacement

* linter: ignore warning lint by the newest dart sdk version for example project

* ci: update flutter version to latest 3.27.3

---------

Co-authored-by: David Barroso <[email protected]>
  • Loading branch information
totzk9 and dbarrosop authored Feb 3, 2025
1 parent 806dc7d commit fb79943
Show file tree
Hide file tree
Showing 22 changed files with 329 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.nhost_auth_dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Setup Dart/Flutter (specific channel)
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.9"
flutter-version: "3.27.3"
channel: "stable"

# Get binary dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.nhost_dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Setup Dart/Flutter (specific channel)
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.9"
flutter-version: "3.27.3"
channel: "stable"

# Get binary dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.nhost_flutter_auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Setup Dart/Flutter (specific channel)
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.9"
flutter-version: "3.27.3"
channel: "stable"

# Get binary dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.nhost_flutter_graphql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Setup Dart/Flutter (specific channel)
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.9"
flutter-version: "3.27.3"
channel: "stable"

# Get binary dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.nhost_functions_dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Setup Dart/Flutter (specific channel)
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.9"
flutter-version: "3.27.3"
channel: "stable"

# Get binary dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.nhost_gql_links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Setup Dart/Flutter (specific channel)
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.9"
flutter-version: "3.27.3"
channel: "stable"

# Get binary dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.nhost_graphql_adapter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Setup Dart/Flutter (specific channel)
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.9"
flutter-version: "3.27.3"
channel: "stable"

# Get binary dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.nhost_sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Setup Dart/Flutter (specific channel)
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.9"
flutter-version: "3.27.3"
channel: "stable"

# Get binary dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.nhost_storage_dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Setup Dart/Flutter (specific channel)
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.9"
flutter-version: "3.27.3"
channel: "stable"

# Get binary dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.{package}.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Setup Dart/Flutter (specific channel)
uses: subosito/flutter-action@v2
with:
flutter-version: '3.13.9'
flutter-version: "3.27.3"
channel: 'stable'

# Get binary dependencies
Expand Down
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
"flutterMode": "debug",
"type": "dart"
},
{
"name": "nhost_flutter_auth_oauth_webview",
"cwd": "packages/nhost_flutter_auth/example",
"program": "lib/oauth_webview_example.dart",
"request": "launch",
"flutterMode": "debug",
"type": "dart"
},
{
"name": "nhost_flutter_graphql",
"cwd": "packages/nhost_flutter_graphql/example",
Expand Down
3 changes: 3 additions & 0 deletions packages/nhost_flutter_auth/example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
analyzer:
errors:
use_build_context_synchronously: ignore
include: package:flutter_lints/flutter.yaml

linter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion packages/nhost_flutter_auth/example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
38 changes: 28 additions & 10 deletions packages/nhost_flutter_auth/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,51 @@ PODS:
- app_links (0.0.1):
- Flutter
- Flutter (1.0.0)
- shared_preferences_ios (0.0.1):
- flutter_inappwebview_ios (0.0.1):
- Flutter
- flutter_inappwebview_ios/Core (= 0.0.1)
- OrderedSet (~> 6.0.3)
- flutter_inappwebview_ios/Core (0.0.1):
- Flutter
- OrderedSet (~> 6.0.3)
- OrderedSet (6.0.3)
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- url_launcher_ios (0.0.1):
- Flutter

DEPENDENCIES:
- app_links (from `.symlinks/plugins/app_links/ios`)
- Flutter (from `Flutter`)
- shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
- flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

SPEC REPOS:
trunk:
- OrderedSet

EXTERNAL SOURCES:
app_links:
:path: ".symlinks/plugins/app_links/ios"
Flutter:
:path: Flutter
shared_preferences_ios:
:path: ".symlinks/plugins/shared_preferences_ios/ios"
flutter_inappwebview_ios:
:path: ".symlinks/plugins/flutter_inappwebview_ios/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"

SPEC CHECKSUMS:
app_links: ab4ba54d10a13d45825336bc9707b5eadee81191
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad
url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de
app_links: e70ca16b4b0f88253b3b3660200d4a10b4ea9795
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_inappwebview_ios: 6f63631e2c62a7c350263b13fa5427aedefe81d4
OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011

COCOAPODS: 1.11.3
COCOAPODS: 1.15.0
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -156,7 +156,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -217,10 +217,12 @@
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down Expand Up @@ -253,6 +255,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -340,7 +343,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -417,7 +420,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -466,7 +469,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
18 changes: 9 additions & 9 deletions packages/nhost_flutter_auth/example/lib/navigator_2_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,20 @@ class ExampleRouterDelegate extends RouterDelegate<ExampleRoutePath>
auth.authenticationState != AuthenticationState.signedIn;
final needsSignIn = requestedRoutePath is ProtectedRoutePath &&
auth.authenticationState != AuthenticationState.signedIn;

return Navigator(
key: navigatorKey,
pages: [

final pages = [
const MaterialPage(child: AppFrame(child: HomePage())),
if (isSignInPageRequested || needsSignIn)
const MaterialPage(child: AppFrame(child: SignInPage())),
if (requestedRoutePath is AdminRoutePath && !needsSignIn)
const MaterialPage(child: AppFrame(child: AdminPage())),
],
onPopPage: (route, result) {
navigator.requestRoutePath(HomeRoutePath());
notifyListeners();
return route.didPop(result);
];

return Navigator(
key: navigatorKey,
pages: pages,
onDidRemovePage: (page) {
pages.remove(page);
},
);
}
Expand Down
Loading

0 comments on commit fb79943

Please sign in to comment.