Skip to content

Commit db5a5e1

Browse files
authored
feat(ui): add firebase_ui_auth and oauth providers (#9343)
* feat(ui): add firebase_ui_auth and oauth providers * chore(ui): fix unit tests * chore(ui): fix e2e tests * chore(ui): fix example dependency * chore(ui): fix OAuthProviderButton test * chore(ui): fix email verification domain * fix(ui): fix keyboard overlapping sign in screen ui * feat(ui): reload user when app goes back to foreground * fix(ui): fix reauthenticate dialog * fix(ui): fix dependencies * fix(ui): fix default resizeToAvoidBottomInset * fix(ui): fix review comments * fix(ui): use Text.rich instead of RichText * fix(ui): fix phone and sms code input for RTL locales * fix(ui): fix sign in action button on delete account action * fix(ui): fix description, repository and homepage URLs * chore(ui): trigger CI * docs(ui_auth): fix review commets * chore(ui_auth): drop unnecessary assets folder
1 parent ff05af5 commit db5a5e1

File tree

452 files changed

+26432
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

452 files changed

+26432
-0
lines changed

packages/firebase_ui_auth/.gitignore

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26+
/pubspec.lock
27+
**/doc/api/
28+
.dart_tool/
29+
.packages
30+
build/

packages/firebase_ui_auth/.metadata

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: f1875d570e39de09040c8f79aa13cc56baab8db1
8+
channel: stable
9+
10+
project_type: package
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## 1.0.0-dev.0
2+
3+
- Bump "firebase_ui_auth" to `1.0.0-dev.0`.
4+
5+
## 0.0.1
6+
7+
* TODO: Describe initial release.

packages/firebase_ui_auth/LICENSE

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright 2017, the Chromium project authors. All rights reserved.
2+
Redistribution and use in source and binary forms, with or without
3+
modification, are permitted provided that the following conditions are
4+
met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

packages/firebase_ui_auth/README.md

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Firebase UI Auth
2+
3+
[![pub package](https://img.shields.io/pub/v/firebase_ui_auth.svg)](https://pub.dev/packages/firebase_ui_auth)
4+
5+
Firebase UI Auth is a set of Flutter widgets and utilities designed to help you build and integrate your user interface with Firebase Authentication.
6+
7+
> Please contribute to the [discussion](https://github.com/firebase/flutterfire/discussions/6978) with feedback.
8+
9+
## Platoform support
10+
11+
| Feature/platform | Android | iOS | Web | macOS | Windows | Linux |
12+
| ------------------ | ------- | --- | ---------------- | ---------------- | ---------------- | ---------------- |
13+
| Email ||||| ✓ <sup>(1)</sup> | ✓ <sup>(1)</sup> |
14+
| Phone |||||||
15+
| Email link |||||||
16+
| Email verification ||| ✓ <sup>(2)</sup> | ✓ <sup>(2)</sup> | ✓ <sup>(1)</sup> | ✓ <sup>(1)</sup> |
17+
| Sign in with Apple |||||||
18+
| Google Sign in ||||| ✓ <sup>(1)</sup> | ✓ <sup>(1)</sup> |
19+
| Twitter Login ||||| ✓ <sup>(1)</sup> | ✓ <sup>(1)</sup> |
20+
| Facebook Sign in ||||| ✓ <sup>(1)</sup> | ✓ <sup>(1)</sup> |
21+
22+
1. Available with [flutterfire_desktop](https://github.com/invertase/flutterfire_desktop)
23+
2. No deep-linking into app, so email verification link opens a web page
24+
25+
## Installation
26+
27+
```sh
28+
flutter pub add firebase_ui_auth
29+
```
30+
31+
## Getting Started
32+
33+
Here's a quick example that shows how to build a `SignInScreen` and `ProfileScreen` in your app
34+
35+
```dart
36+
import 'package:flutter/material.dart';
37+
import 'package:firebase_auth/firebase_auth.dart';
38+
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
39+
40+
class MyApp extends StatelessWidget {
41+
@override
42+
Widget build(BuildContext context) {
43+
const providers = [EmailAuthProvider()];
44+
45+
return MaterialApp(
46+
initialRoute: FirebaseAuth.instance.currentUser == null ? '/sign-in' : '/profile',
47+
routes: {
48+
'/sign-in': (context) {
49+
return SignInScreen(
50+
providers: providers,
51+
actions: [
52+
AuthStateChangeAction<SignedIn>((context, state) {
53+
Navigator.pushReplacementNamed(context, '/profile');
54+
}),
55+
],
56+
);
57+
},
58+
'/profile': (context) {
59+
return ProfileScreen(
60+
providers: providers,
61+
actions: [
62+
SignedOutAction((context) {
63+
Navigator.pushReplacementNamed(context, '/sign-in');
64+
}),
65+
],
66+
);
67+
},
68+
},
69+
);
70+
}
71+
}
72+
```
73+
74+
Learn more [here](https://github.com/firebase/flutterfire/packages/firebase_ui_auth/doc/README.md).
75+
76+
## Roadmap / Features
77+
78+
- For issues, please create a new [issue on the repository](https://github.com/firebase/flutterfire/issues).
79+
- For feature requests, & questions, please participate on the [discussion](https://github.com/firebase/flutterfire/discussions/6978) thread.
80+
- To contribute a change to this plugin, please review our [contribution guide](https://github.com/firebase/flutterfire/blob/master/CONTRIBUTING.md) and open a [pull request](https://github.com/firebase/flutterfire/pulls).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
# Additional information about this file can be found at
4+
# https://dart.dev/guides/language/analysis-options
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Firebase UI for authentication
2+
3+
Firebase UI for authentication provides a simple and easy way to implement authentication in your Flutter app.
4+
The library provides fully featured UI screens to drop into new or existing applications, along with
5+
lower level abstractions for developers looking for tighter control.
6+
7+
## Installation
8+
9+
Activate FlutterFire CLI
10+
11+
```sh
12+
dart pub global activate flutterfire_cli
13+
```
14+
15+
Install dependencies
16+
17+
```sh
18+
flutter pub add firebase_core
19+
flutter pub add firebase_auth
20+
# required for email link sign in and email verification
21+
flutter pub add firebase_dynamic_links
22+
flutter pub add firebase_ui_auth
23+
```
24+
25+
## Configuration
26+
27+
Configure firebase using cli:
28+
29+
```sh
30+
flutterfire configure
31+
```
32+
33+
Initialize firebase app:
34+
35+
```dart
36+
void main() {
37+
WidgetsFlutterBinding.ensureInitialized();
38+
39+
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
40+
}
41+
```
42+
43+
## macOS entitlements
44+
45+
If you're building for macOS, make sure to add necessary entitlements. Learn more [from the official Flutter documentation](https://docs.flutter.dev/development/platform-integration/macos/building).
46+
47+
## Next steps
48+
49+
To understand what Firebase UI for authentication offers, the following documentation pages walk you through the various topics on
50+
how to use the package within your Flutter app.
51+
52+
- Available auth providers:
53+
54+
- [EmaiAuthProvider](./providers/email.md) - allows registering and signing in using email and password.
55+
- [EmailLinkAuthProvider](./providers/email-link.md) - allows registering and signing in using a link sent to email.
56+
- [PhoneAuthProvider](./providers/phone.md) - allows registering and signing in using a phone number
57+
- [UniversalEmailSignInProvider](./providers/universal-email-sign-in.md) - gets all connected auth providers for a given email.
58+
- [OAuth](./providers/oauth.md)
59+
60+
- [Localization](../../firebase_ui_localizations/README.md)
61+
- [Theming](./theming.md)
62+
- [Navigation](./navigation.md)
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Navigation
2+
3+
Firebase UI uses Flutter navigation capabilities to navigate between pages.
4+
5+
By default, it uses "Navigator 1." when a new screen needs to be shown as a result of user interaction (`Navigator.push(context, route)` is used).
6+
7+
For applications using the standard navigation APIs, navigation will work out of the box and require no intervention. However, for applications using
8+
a custom routing package, you will need to override the default navigation actions to integrate with your routing strategy.
9+
10+
## Custom routing
11+
12+
For this example, the application will create [named routes](https://docs.flutter.dev/cookbook/navigation/named-routes). Within the UI logic, we can
13+
override the default actions (e.g. signing in or signing out) the UI performs to instead integrate with those named routes.
14+
15+
First, we define the root route that checks for authentication state and renders a `SignInScreen` or `ProfileScreen`:
16+
17+
```dart
18+
class MyApp extends StatelessWidget {
19+
@override
20+
Widget build(BuildContext context) {
21+
const providers = [EmailProvider()];
22+
23+
return MaterialApp(
24+
initialRoute: FirebaseAuth.instance.currentUser == null ? '/sign-in' : '/profile',
25+
routes: {
26+
'/sign-in': (context) => SignInScreen(providers: providers),
27+
'/profile': (context) => ProfileScreen(providers: providers),
28+
},
29+
);
30+
}
31+
}
32+
```
33+
34+
By default, when a user triggers a sign-in via the `SignInScreen`, no action default occurs. Since we are not subscribing to the authentication
35+
state (via the `authStateChanges` API), we need to manually force the navigator to push to a new screen (the `/profile` route).
36+
37+
To do this, add a `AuthStateChangeAction` action to the `actions` property of the widget, for example for a successful sign in:
38+
39+
```dart
40+
SignInScreen(
41+
actions: [
42+
AuthStateChangeAction<SignedIn>((context, _) {
43+
Navigator.of(context).pushReplacementNamed('/profile');
44+
}),
45+
],
46+
// ...
47+
)
48+
```
49+
50+
You could also react to the user signing out in a similar manner:
51+
52+
```dart
53+
ProfileScreen(
54+
actions: [
55+
SignedOutAction((context, _) {
56+
Navigator.of(context).pushReplacementNamed('/sign-in');
57+
}),
58+
],
59+
// ...
60+
)
61+
```
62+
63+
Some UI widgets also come with internal actions which triggers navigation to a new screen. For example the `SignInScreen` widget allows users to
64+
reset their password by pressing the "Forgot Password" button, which internally navigates to a `ForgotPasswordScreen`. To override this action and
65+
navigate to a named route, provide the `actions` list with a `ForgotPasswordAction`:
66+
67+
```dart
68+
class MyApp extends StatelessWidget {
69+
@override
70+
Widget build(BuildContext context) {
71+
const providers = [EmailProvider()];
72+
73+
return MaterialApp(
74+
initialRoute: FirebaseAuth.instance.currentUser == null ? '/sign-in' : '/profile',
75+
routes: {
76+
'/sign-in': (context) {
77+
return SignInScreen(
78+
providers: providers,
79+
actions: [
80+
ForgotPasswordAction((context, email) {
81+
Navigator.of(context).pushNamed(
82+
'/forgot-password',
83+
arguments: {'email': email},
84+
);
85+
}),
86+
],
87+
);
88+
},
89+
'/profile': (context) => ProfileScreen(providers: providers),
90+
'/forgot-password': (context) => MyCustomForgotPasswordScreen(),
91+
},
92+
);
93+
}
94+
}
95+
```
96+
97+
To learn more about the available actions, check out the [FirebaseUIActions API reference](https://pub.dev/documentation/firebase_ui_auth/latest/firebase_ui_auth/FirebaseUIActions-class.html).
98+
99+
## Other topics
100+
101+
## Other topics
102+
103+
- [EmaiAuthProvider](./providers/email.md) - allows registering and signing using email and password.
104+
- [EmailLinkAuthProvider](./providers/email-link.md) - allows registering and signing using a link sent to email.
105+
- [PhoneAuthProvider](./providers/phone.md) - allows registering and signing using a phone number
106+
- [UniversalEmailSignInProvider](./providers/universal-email-sign-in.md) - gets all connected auth providers for a given email.
107+
- [OAuth](./providers/oauth.md)
108+
- [Localization](../../firebase_ui_localizations/README.md)
109+
- [Theming](./theming.md)

0 commit comments

Comments
 (0)