diff --git a/learning/tour-of-beam/frontend/README.md b/learning/tour-of-beam/frontend/README.md index 492548c829606..cba80719dfec7 100644 --- a/learning/tour-of-beam/frontend/README.md +++ b/learning/tour-of-beam/frontend/README.md @@ -36,7 +36,7 @@ However, after changes you may need to re-run code generation: cd beam ./gradlew :playground:frontend:playground_components:generateCode cd learning/tour-of-beam/frontend -flutter pub run build_runner build +flutter pub run build_runner build --delete-conflicting-outputs ``` ### Run diff --git a/learning/tour-of-beam/frontend/lib/auth/method.dart b/learning/tour-of-beam/frontend/lib/auth/method.dart deleted file mode 100644 index ccc3d63116d98..0000000000000 --- a/learning/tour-of-beam/frontend/lib/auth/method.dart +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import 'package:enum_map/enum_map.dart'; - -part 'method.g.dart'; - -@unmodifiableEnumMap -enum AuthMethod { - google, - github, -} diff --git a/learning/tour-of-beam/frontend/lib/auth/method.g.dart b/learning/tour-of-beam/frontend/lib/auth/method.g.dart deleted file mode 100644 index e9f7c3dfb64b7..0000000000000 --- a/learning/tour-of-beam/frontend/lib/auth/method.g.dart +++ /dev/null @@ -1,162 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'method.dart'; - -// ************************************************************************** -// UnmodifiableEnumMapGenerator -// ************************************************************************** - -class UnmodifiableAuthMethodMap extends UnmodifiableEnumMap { - final V google; - final V github; - - const UnmodifiableAuthMethodMap({ - required this.google, - required this.github, - }); - - @override - Map cast() { - return Map.castFrom(this); - } - - @override - bool containsValue(Object? value) { - if (this.google == value) return true; - if (this.github == value) return true; - return false; - } - - @override - bool containsKey(Object? key) { - return key.runtimeType == AuthMethod; - } - - @override - V? operator [](Object? key) { - switch (key) { - case AuthMethod.google: - return this.google; - case AuthMethod.github: - return this.github; - } - - return null; - } - - @override - void operator []=(AuthMethod key, V value) { - throw Exception("Cannot modify this map."); - } - - @override - Iterable> get entries { - return [ - MapEntry(AuthMethod.google, this.google), - MapEntry(AuthMethod.github, this.github), - ]; - } - - @override - Map map(MapEntry transform(AuthMethod key, V value)) { - final google = transform(AuthMethod.google, this.google); - final github = transform(AuthMethod.github, this.github); - return { - google.key: google.value, - github.key: github.value, - }; - } - - @override - void addEntries(Iterable> newEntries) { - throw Exception("Cannot modify this map."); - } - - @override - V update(AuthMethod key, V update(V value), {V Function()? ifAbsent}) { - throw Exception("Cannot modify this map."); - } - - @override - void updateAll(V update(AuthMethod key, V value)) { - throw Exception("Cannot modify this map."); - } - - @override - void removeWhere(bool test(AuthMethod key, V value)) { - throw Exception("Objects in this map cannot be removed."); - } - - @override - V putIfAbsent(AuthMethod key, V ifAbsent()) { - return this.get(key); - } - - @override - void addAll(Map other) { - throw Exception("Cannot modify this map."); - } - - @override - V? remove(Object? key) { - throw Exception("Objects in this map cannot be removed."); - } - - @override - void clear() { - throw Exception("Objects in this map cannot be removed."); - } - - @override - void forEach(void action(AuthMethod key, V value)) { - action(AuthMethod.google, this.google); - action(AuthMethod.github, this.github); - } - - @override - Iterable get keys { - return AuthMethod.values; - } - - @override - Iterable get values { - return [ - this.google, - this.github, - ]; - } - - @override - int get length { - return 2; - } - - @override - bool get isEmpty { - return false; - } - - @override - bool get isNotEmpty { - return true; - } - - V get(AuthMethod key) { - switch (key) { - case AuthMethod.google: - return this.google; - case AuthMethod.github: - return this.github; - } - } - - @override - String toString() { - final buffer = StringBuffer("{"); - buffer.write("AuthMethod.google: ${this.google}"); - buffer.write(", "); - buffer.write("AuthMethod.github: ${this.github}"); - buffer.write("}"); - return buffer.toString(); - } -} diff --git a/learning/tour-of-beam/frontend/lib/auth/notifier.dart b/learning/tour-of-beam/frontend/lib/auth/notifier.dart index c6b147ad02d07..2eb7be819f39c 100644 --- a/learning/tour-of-beam/frontend/lib/auth/notifier.dart +++ b/learning/tour-of-beam/frontend/lib/auth/notifier.dart @@ -19,15 +19,10 @@ import 'dart:async'; import 'package:firebase_auth/firebase_auth.dart'; +import 'package:firebase_auth_platform_interface/firebase_auth_platform_interface.dart'; import 'package:flutter/material.dart'; -import 'method.dart'; class AuthNotifier extends ChangeNotifier { - final _authProviders = UnmodifiableAuthMethodMap( - google: GoogleAuthProvider(), - github: GithubAuthProvider(), - ); - AuthNotifier() { FirebaseAuth.instance.authStateChanges().listen((user) { notifyListeners(); @@ -40,8 +35,8 @@ class AuthNotifier extends ChangeNotifier { return await FirebaseAuth.instance.currentUser?.getIdToken(); } - Future logIn(AuthMethod authMethod) async { - await FirebaseAuth.instance.signInWithPopup(_authProviders.get(authMethod)); + Future logIn(AuthProvider authProvider) async { + await FirebaseAuth.instance.signInWithPopup(authProvider); } Future logOut() async { diff --git a/learning/tour-of-beam/frontend/lib/cache/cache.dart b/learning/tour-of-beam/frontend/lib/cache/cache.dart index a77876d27023f..c11e2790c4227 100644 --- a/learning/tour-of-beam/frontend/lib/cache/cache.dart +++ b/learning/tour-of-beam/frontend/lib/cache/cache.dart @@ -20,6 +20,7 @@ import 'package:flutter/material.dart'; import '../repositories/client/client.dart'; +/// A base class for caching entities from network requests. abstract class Cache extends ChangeNotifier { final TobClient client; diff --git a/learning/tour-of-beam/frontend/lib/cache/content_tree.dart b/learning/tour-of-beam/frontend/lib/cache/content_tree.dart index b7ce82ac3af3e..5f35af7e55e03 100644 --- a/learning/tour-of-beam/frontend/lib/cache/content_tree.dart +++ b/learning/tour-of-beam/frontend/lib/cache/content_tree.dart @@ -30,8 +30,7 @@ class ContentTreeCache extends Cache { final _futuresBySdkId = >{}; ContentTreeModel? getContentTree(String sdkId) { - final future = _futuresBySdkId[sdkId]; - if (future == null) { + if (_futuresBySdkId.containsKey(sdkId)) { unawaited(_loadContentTree(sdkId)); } diff --git a/learning/tour-of-beam/frontend/lib/components/login/content.dart b/learning/tour-of-beam/frontend/lib/components/login/content.dart index 1fb4e42310561..ae1fe80fa0281 100644 --- a/learning/tour-of-beam/frontend/lib/components/login/content.dart +++ b/learning/tour-of-beam/frontend/lib/components/login/content.dart @@ -17,13 +17,13 @@ */ import 'package:easy_localization/easy_localization.dart'; +import 'package:firebase_auth_platform_interface/firebase_auth_platform_interface.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:get_it/get_it.dart'; import 'package:playground_components/playground_components.dart'; import '../../assets/assets.gen.dart'; -import '../../auth/method.dart'; import '../../auth/notifier.dart'; import '../../constants/sizes.dart'; @@ -132,7 +132,7 @@ class _BrandedLoginButtons extends StatelessWidget { const SizedBox(height: BeamSizes.size16), ElevatedButton.icon( onPressed: () async { - await authNotifier.logIn(AuthMethod.google); + await authNotifier.logIn(GoogleAuthProvider()); onLoggedIn(); }, style: isLightTheme ? googleLightButtonStyle : darkButtonStyle, diff --git a/learning/tour-of-beam/frontend/pubspec.lock b/learning/tour-of-beam/frontend/pubspec.lock index ce97b23ebec96..0f19f8a44aabc 100644 --- a/learning/tour-of-beam/frontend/pubspec.lock +++ b/learning/tour-of-beam/frontend/pubspec.lock @@ -14,7 +14,7 @@ packages: name: _flutterfire_internals url: "https://pub.dartlang.org" source: hosted - version: "1.0.9" + version: "1.0.12" aligned_dialog: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: app_state url: "https://pub.dartlang.org" source: hosted - version: "0.8.1" + version: "0.8.4" archive: dependency: transitive description: @@ -155,20 +155,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.1" - cloud_firestore_platform_interface: - dependency: transitive - description: - name: cloud_firestore_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "5.9.0" - cloud_firestore_web: - dependency: transitive - description: - name: cloud_firestore_web - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" code_builder: dependency: transitive description: @@ -254,19 +240,12 @@ packages: source: hosted version: "0.0.2" enum_map: - dependency: "direct main" + dependency: transitive description: name: enum_map url: "https://pub.dartlang.org" source: hosted version: "0.2.1" - enum_map_gen: - dependency: "direct dev" - description: - name: enum_map_gen - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.0" equatable: dependency: "direct dev" description: @@ -303,12 +282,12 @@ packages: source: hosted version: "4.1.4" firebase_auth_platform_interface: - dependency: transitive + dependency: "direct main" description: name: firebase_auth_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "6.11.3" + version: "6.11.7" firebase_auth_web: dependency: transitive description: @@ -322,7 +301,7 @@ packages: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.4.1" firebase_core_platform_interface: dependency: transitive description: @@ -336,7 +315,7 @@ packages: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.1.0" fixnum: dependency: transitive description: @@ -355,7 +334,7 @@ packages: name: flutter_code_editor url: "https://pub.dartlang.org" source: hosted - version: "0.2.1" + version: "0.2.5" flutter_driver: dependency: transitive description: flutter diff --git a/learning/tour-of-beam/frontend/pubspec.yaml b/learning/tour-of-beam/frontend/pubspec.yaml index 3813ca17fbd8a..0d6a7329edf27 100644 --- a/learning/tour-of-beam/frontend/pubspec.yaml +++ b/learning/tour-of-beam/frontend/pubspec.yaml @@ -32,8 +32,8 @@ dependencies: easy_localization: ^3.0.1 easy_localization_ext: ^0.1.0 easy_localization_loader: ^1.0.0 - enum_map: ^0.2.1 firebase_auth: ^4.1.1 + firebase_auth_platform_interface: ^6.11.7 firebase_core: ^2.1.1 flutter: { sdk: flutter } flutter_markdown: ^0.6.12 @@ -52,7 +52,6 @@ dependencies: dev_dependencies: build_runner: ^2.2.0 - enum_map_gen: ^0.2.0 equatable: ^2.0.5 flutter_gen_runner: ^4.3.0 flutter_test: { sdk: flutter } diff --git a/learning/tour-of-beam/frontend/test/main_test.dart b/learning/tour-of-beam/frontend/test/main_test.dart index b68d73ad670a8..dc0b1dd00b038 100644 --- a/learning/tour-of-beam/frontend/test/main_test.dart +++ b/learning/tour-of-beam/frontend/test/main_test.dart @@ -17,5 +17,5 @@ */ void main() { - // TODO(nausharipov): add unit and integration tests + // TODO(nausharipov): add unit and integration tests: // https://github.com/apache/beam/issues/24982 }