-
Notifications
You must be signed in to change notification settings - Fork 71
Included idx specific changes #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a8b0b11
Included idx specific changes
maneesht 23179f2
Cleanup
maneesht c6f42f2
Added untracked files
maneesht e5184e0
Updated idx script
maneesht 31c0b74
Brought back windows and ios
maneesht ee5f0e0
Removed unnecessary .dataconnect files
maneesht 51da0cb
Fixed assets link
maneesht 0fd800f
Updated IDX readme
maneesht 8f74516
Update data_connect/README.idx.md
maneesht File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| # Firebase Data Connect Quickstart | ||
|
|
||
| ## Introduction | ||
|
|
||
| This quickstart is a movie review app to demonstrate the use of Firebase Data Connect with a Cloud SQL database. For more information about Firebase Data Connect visit [the docs](https://firebase.google.com/docs/data-connect/). | ||
|
|
||
|
|
||
| ## Getting Started | ||
|
|
||
| Follow these steps to get up and running with Firebase Data Connect. For more detailed instructions, check out the [official documentation](https://firebase.google.com/docs/data-connect/quickstart). | ||
|
|
||
| ### 1. Connect to your Firebase project | ||
|
|
||
| 1. If you haven't already, create a Firebase project. | ||
| 1. In the [Firebase console](https://console.firebase.google.com), click | ||
| **Add project**, then follow the on-screen instructions. | ||
| 2. Enable Email/Password Sign-in method [here](https://console.firebase.google.com/project/_/authentication/providers). | ||
|
|
||
| ### 2. Cloning the repository | ||
|
|
||
| 1. Configure flutterfire | ||
| This will automatically download and set up firebase for your project: | ||
| ```sh | ||
| flutterfire configure -y -a com.example.dataconnect | ||
| ``` | ||
|
|
||
| ### 3. Start Emulators | ||
|
|
||
| 1. Click on the Firebase Data Connect icon on the VS Code sidebar to load the Extension. | ||
| a. Sign in with your Google Account if you haven't already. | ||
| 2. Click on "Connect a Firebase project" and choose the project where you have set up Data Connect. | ||
| 3. Click on "Start Emulators" - this should generate the Flutter SDK for you and start the emulators. | ||
|
|
||
| ### 4. Populate the database | ||
| In VS Code, open the `quickstart-flutter/dataconnect/dataconnect/moviedata_insert.gql` file and click the | ||
| `Run (local)` button at the top of the file. | ||
|
|
||
| If you’d like to confirm that the data was correctly inserted, | ||
| open `quickstart-flutter/dataconnect/movie-connector/queries.gql` and run the `ListMovies` query. | ||
|
|
||
| ### 5. Running the app | ||
|
|
||
| The app should already be running in the preview. If there's no preview, try one of the following: | ||
| * Ctrl/Cmd + SHIFT + P, Reload Window | ||
| * Ctrl/Cmd + SHIFT + P, Open Web Preview | ||
This file contains hidden or 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 hidden or 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,14 @@ | ||
| { | ||
| "dataconnect": { | ||
| "source": "dataconnect" | ||
| }, | ||
| "emulators": { | ||
| "dataconnect": { | ||
| "port": 9403 | ||
| }, | ||
| "ui": { | ||
| "enabled": false | ||
| }, | ||
| "singleProjectMode": true | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,185 @@ | ||
| import 'package:dataconnect/models/movie.dart'; | ||
| import 'package:dataconnect/movie_state.dart'; | ||
| import 'package:dataconnect/router.dart'; | ||
| import 'package:dataconnect/widgets/list_movies.dart'; | ||
| import 'package:flutter/foundation.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:firebase_core/firebase_core.dart'; | ||
| import 'firebase_options.dart'; | ||
| import 'package:flutter_web_plugins/url_strategy.dart'; | ||
| import 'util/auth.dart'; | ||
| import 'movies_connector/movies.dart'; | ||
|
|
||
| bool isSetup = false; | ||
| void main() async { | ||
| WidgetsFlutterBinding.ensureInitialized(); | ||
| usePathUrlStrategy(); | ||
| try { | ||
| await Firebase.initializeApp( | ||
| options: DefaultFirebaseOptions.currentPlatform, | ||
| ); | ||
| isSetup = true; | ||
|
|
||
| await Auth.instance.init(); | ||
| int port = 443; | ||
| String hostName = Uri.base.host; | ||
| bool isSecure = true; | ||
| if (!kIsWeb) { | ||
| hostName = '10.0.2.2'; | ||
| port = 9403; | ||
| isSecure = false; | ||
| } | ||
| MoviesConnector.instance.dataConnect | ||
| .useDataConnectEmulator(hostName, port, isSecure: isSecure); | ||
| } catch (_) { | ||
| // The user hasn't run ./installDeps.sh yet | ||
| } | ||
|
|
||
| runApp(const MyApp()); | ||
| } | ||
|
|
||
| class MyApp extends StatelessWidget { | ||
| const MyApp({super.key}); | ||
|
|
||
| // This widget is the root of your application. | ||
| @override | ||
| Widget build(BuildContext context) { | ||
| return MaterialApp.router( | ||
| theme: ThemeData.dark(), | ||
| routerConfig: router, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class MyHomePage extends StatefulWidget { | ||
| const MyHomePage({super.key}); | ||
|
|
||
| @override | ||
| State<MyHomePage> createState() => _MyHomePageState(); | ||
| } | ||
|
|
||
| class _MyHomePageState extends State<MyHomePage> { | ||
| List<ListMoviesMovies> _topMovies = []; | ||
| List<ListMoviesMovies> _latestMovies = []; | ||
| bool _showMessage = true; | ||
|
|
||
| @override | ||
| void initState() { | ||
| super.initState(); | ||
|
|
||
| if (isSetup) { | ||
| MovieState.getTopTenMovies().then((res) { | ||
| if (res.data.movies.isNotEmpty) { | ||
| if (mounted) { | ||
| setState(() { | ||
| _showMessage = false; | ||
| _topMovies = res.data.movies; | ||
| }); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| MovieState.getTopTenMovies().then((res) { | ||
| setState(() { | ||
| _latestMovies = res.data.movies; | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Scaffold( | ||
| body: SafeArea( | ||
| child: SingleChildScrollView( | ||
| child: _showMessage || !isSetup | ||
| ? Center( | ||
| child: Column( | ||
| mainAxisAlignment: MainAxisAlignment.center, | ||
| crossAxisAlignment: CrossAxisAlignment.start, | ||
| children: [ | ||
| Padding( | ||
| padding: const EdgeInsets.all(30.0), | ||
| child: isSetup | ||
| ? Text( | ||
| 'Go to the Firebase Data Connect extension, and click start Emulators. ${_latestMovies.isEmpty ? 'Then open dataconnect/moviedata_insert.gql and the click "Run(local)".' : ''} Then, refresh the page.') | ||
| : const NumberedList(bullets: [ | ||
| 'Make sure you already have a Firebase Project', | ||
| 'In the sidebar, open The Firebase Data Connect Extension', | ||
| 'Sign into your google account associated with your firebase project', | ||
| 'Select your firebase project', | ||
| 'Open a new terminal (by clicking the + icon below) and Run "flutterfire configure -y -a com.example.dataconnect"', | ||
| 'Refresh this preview page' | ||
| ])) | ||
| ], | ||
| )) | ||
| : Column( | ||
| children: <Widget>[ | ||
| ListMovies( | ||
| title: 'Top 10 Movies', | ||
| movies: _topMovies | ||
| .map( | ||
| (e) => Movie( | ||
| id: e.id, | ||
| title: e.title, | ||
| imageUrl: e.imageUrl, | ||
| description: e.description), | ||
| ) | ||
| .toList()), | ||
| ListMovies( | ||
| title: 'Latest Movies', | ||
| movies: _latestMovies | ||
| .map( | ||
| (e) => Movie( | ||
| id: e.id, | ||
| title: e.title, | ||
| imageUrl: e.imageUrl, | ||
| description: e.description), | ||
| ) | ||
| .toList()), | ||
| ], | ||
| ), | ||
| )), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class NumberedList extends StatelessWidget { | ||
| const NumberedList({super.key, required this.bullets}); | ||
|
|
||
| final List<String> bullets; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Container( | ||
| alignment: Alignment.centerLeft, | ||
| padding: const EdgeInsets.fromLTRB(16, 15, 16, 16), | ||
| child: Column( | ||
| children: bullets | ||
| .asMap() | ||
| .keys | ||
| .map((index) => Row(children: [ | ||
| Text( | ||
| "${index + 1}.", | ||
| style: const TextStyle( | ||
| fontSize: 16, height: 1.55, color: Colors.white), | ||
| ), | ||
| const SizedBox( | ||
| width: 5, | ||
| ), | ||
| Expanded( | ||
| child: Text( | ||
| bullets[index], | ||
| textAlign: TextAlign.left, | ||
| softWrap: true, | ||
| style: const TextStyle( | ||
| fontSize: 16, | ||
| color: Colors.white, | ||
| height: 1.55, | ||
| ), | ||
| ), | ||
| ) | ||
| ])) | ||
| .toList())); | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.