-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui_storage): configuration API and UploadButton widget (#10699)
* feat(ui_storage): configuration API and UploadButton widget * chore(ui_storage): add license header * chore(ui_storage): format * chore(ui_shared): drop unnecessary test * fix review comments
- Loading branch information
Showing
148 changed files
with
5,516 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
/pubspec.lock | ||
**/doc/api/ | ||
.dart_tool/ | ||
.packages | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
channel: stable | ||
|
||
project_type: package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## 0.1.0-dev.0 | ||
|
||
- Initial Firebase UI Stroage release with top-level configuration and UploadButton | ||
- `i18n` is not yet supported and will be coming in future releases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Copyright 2017, the Chromium project authors. All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Google Inc. nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
## Firebase UI Storage | ||
|
||
[![pub package](https://img.shields.io/pub/v/firebase_ui_storage.svg)](https://pub.dev/packages/firebase_ui_storage) | ||
|
||
Firebase UI Storage is a set of Flutter widgets and utilities designed to help you build and integrate your user interface with Firebase Storage. | ||
|
||
## Installation | ||
|
||
Intall dependencies | ||
|
||
```sh | ||
flutter pub add firebase_core firebase_storage firebase_ui_storage | ||
``` | ||
|
||
Donwload Firebase project config | ||
|
||
```sh | ||
flutterfire configure | ||
``` | ||
|
||
## Configuration | ||
|
||
This section will walk you through the configuration process of the Firebase UI Storage | ||
|
||
### macOS | ||
|
||
If you're building for macOS, you will need to add an entitlement for either read-only access if you only upload files: | ||
|
||
```xml | ||
<key>com.apple.security.files.user-selected.read-only</key> | ||
<true/> | ||
``` | ||
|
||
or read/write access if you want to be able to download files as well: | ||
|
||
```xml | ||
<key>com.apple.security.files.user-selected.read-write</key> | ||
<true/> | ||
``` | ||
|
||
Make sure to add network client entitlement as well: | ||
|
||
```xml | ||
<key>com.apple.security.network.client</key> | ||
<true/> | ||
``` | ||
|
||
### FirebaseUIStorage.configure() | ||
|
||
To reduce boilerplate for widgets, `FirebaseUIStroage` has a top-level configuration: | ||
|
||
```dart | ||
import 'package:firebase_core/firebase_core.dart'; | ||
import 'package:firebase_storage/firebase_storage.dart'; | ||
import 'package:firebase_ui_storage/firebase_ui_storage.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'firebase_options.dart'; | ||
Future<void> main() async { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); | ||
final storage = FirebaseStorage.instance; | ||
final config = FirebaseUIStorageConfiguration(storage: storage); | ||
await FirebaseUIStorage.configure(config); | ||
runApp(const MyApp()); | ||
} | ||
``` | ||
|
||
See [API docs](https://pub.dev/documentation/firebase_ui_storage/latest/firebase_ui_storage/FirebaseUIStorageConfiguration-class.html) for more configuration options. | ||
|
||
### Overriding configuration | ||
|
||
It is possible to override a top-level configuration for a widget subtree: | ||
|
||
```dart | ||
class MyWidget extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return FirebaseUIStorageConfigOverride( | ||
config: FirebaseUIStorageConfiguration( | ||
uploadRoot: storage.ref('${FirebaseAuth.instance.currentUser.uid}/'), | ||
namingPolicy: const UuidFileUploadNamingPolicy(), | ||
child: const MyUserPage(), | ||
), | ||
); | ||
} | ||
} | ||
``` | ||
|
||
## Widgets | ||
|
||
### UploadButton | ||
|
||
```dart | ||
class MyUploadPage extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: Center( | ||
child: UploadButton( | ||
mimeTypes: const ['image/png', 'image/jpeg'], | ||
onError: (err, stackTrace) { | ||
print(err.toString()); | ||
}, | ||
onUploadComplete: (ref) { | ||
print('File uploaded to ${ref.path}'); | ||
} | ||
), | ||
), | ||
); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Android Studio will place build artifacts here | ||
/android/app/debug | ||
/android/app/profile | ||
/android/app/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled. | ||
|
||
version: | ||
revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
channel: stable | ||
|
||
project_type: app | ||
|
||
# Tracks metadata for the flutter migrate command | ||
migration: | ||
platforms: | ||
- platform: root | ||
create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
- platform: android | ||
create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
- platform: ios | ||
create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
- platform: linux | ||
create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
- platform: macos | ||
create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
- platform: web | ||
create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
- platform: windows | ||
create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 | ||
|
||
# User provided section | ||
|
||
# List of Local paths (relative to this file) that should be | ||
# ignored by the migrate tool. | ||
# | ||
# Files that are not part of the templates will be ignored by default. | ||
unmanaged_files: | ||
- 'lib/main.dart' | ||
- 'ios/Runner.xcodeproj/project.pbxproj' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# firebase_ui_storage_example | ||
|
||
Example app that showcases widgets available in `firebase_ui_storage`. | ||
|
||
See [README](https://github.com/firebase/flutterfire/blob/master/packages/firebase_ui_storage/README.md) and [API docs](https://pub.dev/documentation/firebase_ui_storage/latest/firebase_ui_storage/firebase_ui_storage-library.html) for more details |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: package:flutter_lints/flutter.yaml |
Oops, something went wrong.