Skip to content

Commit

Permalink
update the brew crew with new sign in page
Browse files Browse the repository at this point in the history
have issues on the version of the dependencies, settings.graddle,
If you have this issues again, follow this link: firebase/flutterfire#3876
  • Loading branch information
hieugia3030 committed May 23, 2021
1 parent 0b0c71a commit dd83e99
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 98 deletions.
14 changes: 14 additions & 0 deletions brew_crew/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}

plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
100 changes: 2 additions & 98 deletions brew_crew/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:brew_crew/screens/wrapper.dart';
import 'package:flutter/material.dart';

void main() {
Expand All @@ -9,105 +10,8 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
home: Wrapper(),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);

// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.

// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".

final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
18 changes: 18 additions & 0 deletions brew_crew/lib/screens/authenticate/authenticate.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:brew_crew/screens/authenticate/sign_in.dart';
import 'package:flutter/material.dart';

class Authenticate extends StatefulWidget {
const Authenticate({Key key}) : super(key: key);

@override
_AuthenticateState createState() => _AuthenticateState();
}

class _AuthenticateState extends State<Authenticate> {
@override
Widget build(BuildContext context) {
return Container(
child: SignIn(),
);
}
}
31 changes: 31 additions & 0 deletions brew_crew/lib/screens/authenticate/sign_in.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter/material.dart';

class SignIn extends StatefulWidget {
const SignIn({Key key}) : super(key: key);

@override
_SignInState createState() => _SignInState();
}

class _SignInState extends State<SignIn> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.brown[100],
appBar: AppBar(
backgroundColor: Colors.brown[400],
elevation: 0.0,
title: Text('Sign into Brew Crew'),
),
body: Container(
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 50),
child: ElevatedButton(
child: Text('Sign in Anonymously'),
onPressed: () async{

},
),
),
);
}
}
12 changes: 12 additions & 0 deletions brew_crew/lib/screens/home/home.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';

class Home extends StatelessWidget {
const Home({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
child: Text('home'),
);
}
}
15 changes: 15 additions & 0 deletions brew_crew/lib/screens/wrapper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:brew_crew/screens/authenticate/authenticate.dart';
import 'package:brew_crew/screens/home/home.dart';
import 'package:flutter/material.dart';


class Wrapper extends StatelessWidget {
const Wrapper({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {

// return Home or Authenticate depending on the user logged in or not
return Authenticate();
}
}
28 changes: 28 additions & 0 deletions brew_crew/lib/services/auth.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:firebase_auth/firebase_auth.dart';

class AuthService{

final FirebaseAuth _auth = FirebaseAuth.instance;

// sign in anon
Future signInAnon() async{
try{
AuthResult result = await _auth.signInAnonymously();
FirebaseUser user = result.user;
return user;
} catch(e){
print(e.toString());
return null;
}
}

// sign in with email

// register in with email


// sign out



}
90 changes: 90 additions & 0 deletions brew_crew/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
cloud_firestore:
dependency: "direct main"
description:
name: cloud_firestore
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
collection:
dependency: transitive
description:
Expand All @@ -57,6 +64,41 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
firebase:
dependency: transitive
description:
name: firebase
url: "https://pub.dartlang.org"
source: hosted
version: "7.3.3"
firebase_auth:
dependency: "direct main"
description:
name: firebase_auth
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.0+9"
firebase_core:
dependency: transitive
description:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.5"
firebase_core_platform_interface:
dependency: transitive
description:
name: firebase_core_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
firebase_core_web:
dependency: transitive
description:
name: firebase_core_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+2"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -67,6 +109,32 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.2"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
matcher:
dependency: transitive
description:
Expand All @@ -88,6 +156,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -151,3 +240,4 @@ packages:
version: "2.1.0"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.12.13+hotfix.4"
3 changes: 3 additions & 0 deletions brew_crew/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
firebase_auth: ^0.14.0+5
cloud_firestore: ^0.12.9+4


dev_dependencies:
flutter_test:
Expand Down

0 comments on commit dd83e99

Please sign in to comment.