parent
63833144bb
commit
cfe32bfc83
|
|
@ -3,6 +3,7 @@ plugins {
|
|||
id("kotlin-android")
|
||||
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
||||
id("dev.flutter.flutter-gradle-plugin")
|
||||
id("com.google.gms.google-services")
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"project_info": {
|
||||
"project_number": "219079385989",
|
||||
"project_id": "klimatologiot",
|
||||
"storage_bucket": "klimatologiot.firebasestorage.app"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:219079385989:android:1304b7433feb658ba0daec",
|
||||
"android_client_info": {
|
||||
"package_name": "com.example.klimatologiot"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyAN_9rnFxG99yficqRzTKJ7751D0GC0iXA"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
|
|
@ -1,3 +1,13 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("com.google.gms:google-services:4.4.2")
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:klimatologiot/app_view.dart';
|
||||
import 'package:user_repository/user_repository.dart';
|
||||
import 'blocs/authentication_bloc/authentication_bloc.dart';
|
||||
|
||||
|
|
@ -12,9 +13,8 @@ class MyApp extends StatelessWidget {
|
|||
return RepositoryProvider<AuthenticationBloc>(
|
||||
create: (context) => AuthenticationBloc(
|
||||
userRepository: userRepository
|
||||
|
||||
),
|
||||
child: MyAppView(),
|
||||
child: const MyAppView(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class MyAppView extends StatelessWidget {
|
||||
const MyAppView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Klimatologi IOT',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: ThemeData(
|
||||
colorScheme: ColorScheme.light(
|
||||
background: Colors.grey.shade100,
|
||||
onBackground: Colors.black,
|
||||
primary: Colors.blue,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:user_repository/user_repository.dart';
|
||||
|
|
@ -6,9 +8,28 @@ part 'authentication_event.dart';
|
|||
part 'authentication_state.dart';
|
||||
|
||||
class AuthenticationBloc extends Bloc<AuthenticationEvent, AuthenticationState> {
|
||||
AuthenticationBloc() : super(AuthenticationInitial()) {
|
||||
on<AuthenticationEvent>((event, emit) {
|
||||
// TODO: implement event handler
|
||||
final UserRepository userRepository;
|
||||
late final StreamSubscription<MyUser?> _userSubscription;
|
||||
|
||||
AuthenticationBloc({
|
||||
required this.userRepository
|
||||
}) : super(const AuthenticationState.unknown()) {
|
||||
_userSubscription = userRepository.user.listen((user) {
|
||||
add(AuthenticationUserChanged(user));
|
||||
});
|
||||
|
||||
|
||||
on<AuthenticationUserChanged>((event, emit) {
|
||||
if(event.user != MyUser.empty) {
|
||||
emit(AuthenticationState.authenticated(event.user!));
|
||||
} else {
|
||||
emit(AuthenticationState.unauthenticated());
|
||||
}
|
||||
});
|
||||
}
|
||||
@override
|
||||
Future<void> close() {
|
||||
_userSubscription.cancel();
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,7 @@ sealed class AuthenticationEvent extends Equatable {
|
|||
}
|
||||
|
||||
class AuthenticationUserChanged extends AuthenticationEvent {
|
||||
final MyUser user;
|
||||
final MyUser? user;
|
||||
|
||||
const AuthenticationUserChanged(this.user);
|
||||
|
||||
@override
|
||||
List<Object> get props => [user ?? 'no-user'];
|
||||
}
|
||||
|
|
@ -9,6 +9,4 @@ void main() async {
|
|||
await Firebase.initializeApp();
|
||||
Bloc.observer = SimpleBlocObserver();
|
||||
runApp(MyApp(FirebaseUserRepo()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -8,9 +8,11 @@ import Foundation
|
|||
import cloud_firestore
|
||||
import firebase_auth
|
||||
import firebase_core
|
||||
import google_sign_in_ios
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin"))
|
||||
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
|
||||
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
|
||||
FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))
|
||||
}
|
||||
|
|
|
|||
52
pubspec.lock
52
pubspec.lock
|
|
@ -184,6 +184,54 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
google_identity_services_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: google_identity_services_web
|
||||
sha256: "5d187c46dc59e02646e10fe82665fc3884a9b71bc1c90c2b8b749316d33ee454"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.3+1"
|
||||
google_sign_in:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: google_sign_in
|
||||
sha256: "521031b65853b4409b8213c0387d57edaad7e2a949ce6dea0d8b2afc9cb29763"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.2.0"
|
||||
google_sign_in_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: google_sign_in_android
|
||||
sha256: "5ec98ab35387c68c0050495bb211bd88375873723a80fae7c2e9266ea0bdd8bb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.2.7"
|
||||
google_sign_in_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: google_sign_in_ios
|
||||
sha256: "234fc2830b55d1bbeb7e05662967691f5994143ff43dc70d3f139d1bbb3b8fb2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.2.5"
|
||||
google_sign_in_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: google_sign_in_platform_interface
|
||||
sha256: "7f59208c42b415a3cca203571128d6f84f885fead2d5b53eb65a9e27f2965bb5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
google_sign_in_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: google_sign_in_web
|
||||
sha256: "2fc1f941e6443b2d6984f4056a727a3eaeab15d8ee99ba7125d79029be75a1da"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
http:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -389,5 +437,5 @@ packages:
|
|||
source: hosted
|
||||
version: "1.1.1"
|
||||
sdks:
|
||||
dart: ">=3.8.0-0 <4.0.0"
|
||||
flutter: ">=3.22.0"
|
||||
dart: ">=3.9.0 <4.0.0"
|
||||
flutter: ">=3.35.0"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ dependencies:
|
|||
firebase_auth: ^6.1.3
|
||||
cloud_firestore: ^6.1.1
|
||||
rxdart: ^0.27.7
|
||||
google_sign_in: ^7.2.0
|
||||
|
||||
bloc: ^8.1.0
|
||||
flutter_bloc: ^8.1.0
|
||||
|
|
|
|||
Loading…
Reference in New Issue