@ -0,0 +1,22 @@
|
|||||||
|
name: authentication_repository
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- "packages/authentication_repository/**"
|
||||||
|
- ".github/workflows/authentication_repository.yaml"
|
||||||
|
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- "packages/authentication_repository/**"
|
||||||
|
- ".github/workflows/authentication_repository.yaml"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_package.yml@v1
|
||||||
|
with:
|
||||||
|
working_directory: packages/authentication_repository
|
@ -0,0 +1,76 @@
|
|||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pinball/l10n/l10n.dart';
|
||||||
|
import 'package:pinball_ui/pinball_ui.dart';
|
||||||
|
|
||||||
|
/// {@template footer}
|
||||||
|
/// Footer widget with links to the main tech stack.
|
||||||
|
/// {@endtemplate}
|
||||||
|
class Footer extends StatelessWidget {
|
||||||
|
/// {@macro footer}
|
||||||
|
const Footer({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(50, 0, 50, 32),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: const [
|
||||||
|
_MadeWithFlutterAndFirebase(),
|
||||||
|
_GoogleIO(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GoogleIO extends StatelessWidget {
|
||||||
|
const _GoogleIO({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final l10n = context.l10n;
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
return Text(
|
||||||
|
l10n.footerGoogleIOText,
|
||||||
|
style: theme.textTheme.bodyText1!.copyWith(color: PinballColors.white),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MadeWithFlutterAndFirebase extends StatelessWidget {
|
||||||
|
const _MadeWithFlutterAndFirebase({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final l10n = context.l10n;
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
return RichText(
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
text: TextSpan(
|
||||||
|
text: l10n.footerMadeWithText,
|
||||||
|
style: theme.textTheme.bodyText1!.copyWith(color: PinballColors.white),
|
||||||
|
children: <TextSpan>[
|
||||||
|
TextSpan(
|
||||||
|
text: l10n.footerFlutterLinkText,
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () => openLink('https://flutter.dev'),
|
||||||
|
style: const TextStyle(
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const TextSpan(text: ' & '),
|
||||||
|
TextSpan(
|
||||||
|
text: l10n.footerFirebaseLinkText,
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () => openLink('https://firebase.google.com'),
|
||||||
|
style: const TextStyle(
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"@@locale": "es",
|
|
||||||
"play": "Jugar",
|
|
||||||
"@play": {
|
|
||||||
"description": "Text displayed on the landing page play button"
|
|
||||||
},
|
|
||||||
"start": "Comienzo",
|
|
||||||
"@start": {
|
|
||||||
"description": "Text displayed on the character selection page start button"
|
|
||||||
},
|
|
||||||
"characterSelectionTitle": "¡Elige a tu personaje!",
|
|
||||||
"@characterSelectionTitle": {
|
|
||||||
"description": "Title text displayed on the character selection page"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
export 'app_colors.dart';
|
|
||||||
export 'app_text_style.dart';
|
|
@ -0,0 +1,39 @@
|
|||||||
|
# Miscellaneous
|
||||||
|
*.class
|
||||||
|
*.log
|
||||||
|
*.pyc
|
||||||
|
*.swp
|
||||||
|
.DS_Store
|
||||||
|
.atom/
|
||||||
|
.buildlog/
|
||||||
|
.history
|
||||||
|
.svn/
|
||||||
|
|
||||||
|
# IntelliJ related
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# VSCode related
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# Flutter/Dart/Pub related
|
||||||
|
**/doc/api/
|
||||||
|
**/ios/Flutter/.last_build_id
|
||||||
|
.dart_tool/
|
||||||
|
.flutter-plugins
|
||||||
|
.flutter-plugins-dependencies
|
||||||
|
.packages
|
||||||
|
.pub-cache/
|
||||||
|
.pub/
|
||||||
|
/build/
|
||||||
|
|
||||||
|
# Web related
|
||||||
|
lib/generated_plugin_registrant.dart
|
||||||
|
|
||||||
|
# Symbolication related
|
||||||
|
app.*.symbols
|
||||||
|
|
||||||
|
# Obfuscation related
|
||||||
|
app.*.map.json
|
@ -0,0 +1,11 @@
|
|||||||
|
# authentication_repository
|
||||||
|
|
||||||
|
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
|
||||||
|
[![License: MIT][license_badge]][license_link]
|
||||||
|
|
||||||
|
Repository to manage user authentication.
|
||||||
|
|
||||||
|
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
|
||||||
|
[license_link]: https://opensource.org/licenses/MIT
|
||||||
|
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg
|
||||||
|
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis
|
@ -0,0 +1 @@
|
|||||||
|
include: package:very_good_analysis/analysis_options.2.4.0.yaml
|
@ -0,0 +1,3 @@
|
|||||||
|
library authentication_repository;
|
||||||
|
|
||||||
|
export 'src/authentication_repository.dart';
|
@ -0,0 +1,36 @@
|
|||||||
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
|
|
||||||
|
/// {@template authentication_exception}
|
||||||
|
/// Exception for authentication repository failures.
|
||||||
|
/// {@endtemplate}
|
||||||
|
class AuthenticationException implements Exception {
|
||||||
|
/// {@macro authentication_exception}
|
||||||
|
const AuthenticationException(this.error, this.stackTrace);
|
||||||
|
|
||||||
|
/// The error that was caught.
|
||||||
|
final Object error;
|
||||||
|
|
||||||
|
/// The Stacktrace associated with the [error].
|
||||||
|
final StackTrace stackTrace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// {@template authentication_repository}
|
||||||
|
/// Repository to manage user authentication.
|
||||||
|
/// {@endtemplate}
|
||||||
|
class AuthenticationRepository {
|
||||||
|
/// {@macro authentication_repository}
|
||||||
|
AuthenticationRepository(this._firebaseAuth);
|
||||||
|
|
||||||
|
final FirebaseAuth _firebaseAuth;
|
||||||
|
|
||||||
|
/// Sign in the existing user anonymously using [FirebaseAuth]. If the
|
||||||
|
/// authentication process can't be completed, it will throw an
|
||||||
|
/// [AuthenticationException].
|
||||||
|
Future<void> authenticateAnonymously() async {
|
||||||
|
try {
|
||||||
|
await _firebaseAuth.signInAnonymously();
|
||||||
|
} on Exception catch (error, stackTrace) {
|
||||||
|
throw AuthenticationException(error, stackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
name: authentication_repository
|
||||||
|
description: Repository to manage user authentication.
|
||||||
|
version: 1.0.0+1
|
||||||
|
publish_to: none
|
||||||
|
|
||||||
|
environment:
|
||||||
|
sdk: ">=2.16.0 <3.0.0"
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
firebase_auth: ^3.3.16
|
||||||
|
flutter:
|
||||||
|
sdk: flutter
|
||||||
|
|
||||||
|
dev_dependencies:
|
||||||
|
flutter_test:
|
||||||
|
sdk: flutter
|
||||||
|
mocktail: ^0.2.0
|
||||||
|
very_good_analysis: ^2.4.0
|
@ -0,0 +1,40 @@
|
|||||||
|
import 'package:authentication_repository/authentication_repository.dart';
|
||||||
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:mocktail/mocktail.dart';
|
||||||
|
|
||||||
|
class MockFirebaseAuth extends Mock implements FirebaseAuth {}
|
||||||
|
|
||||||
|
class MockUserCredential extends Mock implements UserCredential {}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
late FirebaseAuth firebaseAuth;
|
||||||
|
late UserCredential userCredential;
|
||||||
|
late AuthenticationRepository authenticationRepository;
|
||||||
|
|
||||||
|
group('AuthenticationRepository', () {
|
||||||
|
setUp(() {
|
||||||
|
firebaseAuth = MockFirebaseAuth();
|
||||||
|
userCredential = MockUserCredential();
|
||||||
|
authenticationRepository = AuthenticationRepository(firebaseAuth);
|
||||||
|
});
|
||||||
|
|
||||||
|
group('authenticateAnonymously', () {
|
||||||
|
test('completes if no exception is thrown', () async {
|
||||||
|
when(() => firebaseAuth.signInAnonymously())
|
||||||
|
.thenAnswer((_) async => userCredential);
|
||||||
|
await authenticationRepository.authenticateAnonymously();
|
||||||
|
verify(() => firebaseAuth.signInAnonymously()).called(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('throws AuthenticationException when firebase auth fails', () async {
|
||||||
|
when(() => firebaseAuth.signInAnonymously())
|
||||||
|
.thenThrow(Exception('oops'));
|
||||||
|
expect(
|
||||||
|
() => authenticationRepository.authenticateAnonymously(),
|
||||||
|
throwsA(isA<AuthenticationException>()),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
After Width: | Height: | Size: 1.3 MiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 156 KiB |
@ -0,0 +1,26 @@
|
|||||||
|
// ignore_for_file: public_member_api_docs
|
||||||
|
|
||||||
|
import 'package:flame/components.dart';
|
||||||
|
import 'package:pinball_components/pinball_components.dart';
|
||||||
|
|
||||||
|
class BoardBackgroundSpriteComponent extends SpriteComponent with HasGameRef {
|
||||||
|
BoardBackgroundSpriteComponent()
|
||||||
|
: super(
|
||||||
|
anchor: Anchor.center,
|
||||||
|
priority: RenderPriority.boardBackground,
|
||||||
|
position: Vector2(0, -1),
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> onLoad() async {
|
||||||
|
await super.onLoad();
|
||||||
|
|
||||||
|
final sprite = Sprite(
|
||||||
|
gameRef.images.fromCache(
|
||||||
|
Assets.images.boardBackground.keyName,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
this.sprite = sprite;
|
||||||
|
size = sprite.originalSize / 10;
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,8 @@
|
|||||||
|
// ignore_for_file: public_member_api_docs
|
||||||
|
|
||||||
part of 'sparky_bumper_cubit.dart';
|
part of 'sparky_bumper_cubit.dart';
|
||||||
|
|
||||||
/// Indicates the [SparkyBumperCubit]'s current state.
|
|
||||||
enum SparkyBumperState {
|
enum SparkyBumperState {
|
||||||
/// A lit up bumper.
|
lit,
|
||||||
active,
|
dimmed,
|
||||||
|
|
||||||
/// A dimmed bumper.
|
|
||||||
inactive,
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
import 'package:dashbook/dashbook.dart';
|
|
||||||
import 'package:sandbox/common/common.dart';
|
|
||||||
import 'package:sandbox/stories/sparky_bumper/sparky_bumper_game.dart';
|
|
||||||
|
|
||||||
void addSparkyBumperStories(Dashbook dashbook) {
|
|
||||||
dashbook.storiesOf('Sparky Bumpers').addGame(
|
|
||||||
title: 'Traced',
|
|
||||||
description: SparkyBumperGame.description,
|
|
||||||
gameBuilder: (_) => SparkyBumperGame(),
|
|
||||||
);
|
|
||||||
}
|
|
@ -0,0 +1,31 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flame/input.dart';
|
||||||
|
import 'package:pinball_components/pinball_components.dart';
|
||||||
|
import 'package:pinball_flame/pinball_flame.dart';
|
||||||
|
import 'package:sandbox/stories/ball/basic_ball_game.dart';
|
||||||
|
|
||||||
|
class SparkyComputerGame extends BallGame {
|
||||||
|
static const description = '''
|
||||||
|
Shows how the SparkyComputer is rendered.
|
||||||
|
|
||||||
|
- Activate the "trace" parameter to overlay the body.
|
||||||
|
- Tap anywhere on the screen to spawn a ball into the game.
|
||||||
|
''';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> onLoad() async {
|
||||||
|
await super.onLoad();
|
||||||
|
|
||||||
|
await images.loadAll([
|
||||||
|
Assets.images.sparky.computer.base.keyName,
|
||||||
|
Assets.images.sparky.computer.top.keyName,
|
||||||
|
Assets.images.sparky.computer.glow.keyName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
camera.followVector2(Vector2(-10, -40));
|
||||||
|
await addFromBlueprint(SparkyComputer());
|
||||||
|
await ready();
|
||||||
|
await traceAllBodies();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
import 'package:dashbook/dashbook.dart';
|
||||||
|
import 'package:sandbox/common/common.dart';
|
||||||
|
import 'package:sandbox/stories/sparky_scorch/sparky_bumper_game.dart';
|
||||||
|
import 'package:sandbox/stories/sparky_scorch/sparky_computer_game.dart';
|
||||||
|
|
||||||
|
void addSparkyScorchStories(Dashbook dashbook) {
|
||||||
|
dashbook.storiesOf('Sparky Scorch')
|
||||||
|
..addGame(
|
||||||
|
title: 'Sparky Computer',
|
||||||
|
description: SparkyComputerGame.description,
|
||||||
|
gameBuilder: (_) => SparkyComputerGame(),
|
||||||
|
)
|
||||||
|
..addGame(
|
||||||
|
title: 'Sparky Bumper',
|
||||||
|
description: SparkyBumperGame.description,
|
||||||
|
gameBuilder: (_) => SparkyBumperGame(),
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
// ignore_for_file: cascade_invocations
|
||||||
|
|
||||||
|
import 'package:flame/components.dart';
|
||||||
|
import 'package:flame_test/flame_test.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pinball_components/pinball_components.dart';
|
||||||
|
|
||||||
|
import '../../helpers/helpers.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
final assets = [
|
||||||
|
Assets.images.boardBackground.keyName,
|
||||||
|
];
|
||||||
|
final flameTester = FlameTester(() => TestGame(assets));
|
||||||
|
|
||||||
|
group('BoardBackgroundSpriteComponent', () {
|
||||||
|
flameTester.test(
|
||||||
|
'loads correctly',
|
||||||
|
(game) async {
|
||||||
|
final boardBackground = BoardBackgroundSpriteComponent();
|
||||||
|
await game.ensureAdd(boardBackground);
|
||||||
|
|
||||||
|
expect(game.contains(boardBackground), isTrue);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
flameTester.testGameWidget(
|
||||||
|
'renders correctly',
|
||||||
|
setUp: (game, tester) async {
|
||||||
|
await game.images.loadAll(assets);
|
||||||
|
final boardBackground = BoardBackgroundSpriteComponent();
|
||||||
|
await game.ensureAdd(boardBackground);
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
game.camera
|
||||||
|
..followVector2(Vector2.zero())
|
||||||
|
..zoom = 3.7;
|
||||||
|
},
|
||||||
|
verify: (game, tester) async {
|
||||||
|
await expectLater(
|
||||||
|
find.byGame<TestGame>(),
|
||||||
|
matchesGoldenFile('golden/board-background.png'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
After Width: | Height: | Size: 1.5 MiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 209 KiB |
@ -0,0 +1,16 @@
|
|||||||
|
/// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
/// *****************************************************
|
||||||
|
/// FlutterGen
|
||||||
|
/// *****************************************************
|
||||||
|
|
||||||
|
// ignore_for_file: directives_ordering,unnecessary_import
|
||||||
|
|
||||||
|
class FontFamily {
|
||||||
|
FontFamily._();
|
||||||
|
|
||||||
|
/// Font family: PixeloidMono
|
||||||
|
static const String pixeloidMono = 'PixeloidMono';
|
||||||
|
|
||||||
|
/// Font family: PixeloidSans
|
||||||
|
static const String pixeloidSans = 'PixeloidSans';
|
||||||
|
}
|
@ -1,3 +1,8 @@
|
|||||||
library pinball_ui;
|
library pinball_ui;
|
||||||
|
|
||||||
|
export 'package:url_launcher/url_launcher.dart';
|
||||||
|
export 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart';
|
||||||
|
|
||||||
export 'src/dialog/dialog.dart';
|
export 'src/dialog/dialog.dart';
|
||||||
|
export 'src/external_links/external_links.dart';
|
||||||
|
export 'src/theme/theme.dart';
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
/// Opens the given [url] in a new tab of the host browser
|
||||||
|
Future<void> openLink(String url, {VoidCallback? onError}) async {
|
||||||
|
final uri = Uri.parse(url);
|
||||||
|
if (await canLaunchUrl(uri)) {
|
||||||
|
await launchUrl(uri);
|
||||||
|
} else if (onError != null) {
|
||||||
|
onError();
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,11 @@
|
|||||||
// ignore_for_file: public_member_api_docs
|
// ignore_for_file: public_member_api_docs
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
abstract class AppColors {
|
abstract class PinballColors {
|
||||||
static const Color white = Color(0xFFFFFFFF);
|
static const Color white = Color(0xFFFFFFFF);
|
||||||
|
|
||||||
static const Color darkBlue = Color(0xFF0C32A4);
|
static const Color darkBlue = Color(0xFF0C32A4);
|
||||||
|
|
||||||
static const Color yellow = Color(0xFFFFEE02);
|
static const Color yellow = Color(0xFFFFEE02);
|
||||||
|
|
||||||
static const Color orange = Color(0xFFE5AB05);
|
static const Color orange = Color(0xFFE5AB05);
|
||||||
|
|
||||||
static const Color blue = Color(0xFF4B94F6);
|
static const Color blue = Color(0xFF4B94F6);
|
||||||
|
|
||||||
static const Color transparent = Color(0x00000000);
|
static const Color transparent = Color(0x00000000);
|
||||||
}
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pinball_ui/pinball_ui.dart';
|
||||||
|
|
||||||
|
/// Pinball theme
|
||||||
|
class PinballTheme {
|
||||||
|
/// Standard [ThemeData] for Pinball UI
|
||||||
|
static ThemeData get standard {
|
||||||
|
return ThemeData(
|
||||||
|
textTheme: _textTheme,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static TextTheme get _textTheme {
|
||||||
|
return const TextTheme(
|
||||||
|
headline1: PinballTextStyle.headline1,
|
||||||
|
headline2: PinballTextStyle.headline2,
|
||||||
|
headline3: PinballTextStyle.headline3,
|
||||||
|
headline4: PinballTextStyle.headline4,
|
||||||
|
subtitle1: PinballTextStyle.subtitle1,
|
||||||
|
subtitle2: PinballTextStyle.subtitle2,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
export 'pinball_colors.dart';
|
||||||
|
export 'pinball_text_style.dart';
|
||||||
|
export 'pinball_theme.dart';
|
@ -0,0 +1,81 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:mocktail/mocktail.dart';
|
||||||
|
import 'package:pinball_ui/pinball_ui.dart';
|
||||||
|
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
||||||
|
|
||||||
|
class MockUrlLauncher extends Mock
|
||||||
|
with MockPlatformInterfaceMixin
|
||||||
|
implements UrlLauncherPlatform {}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
late UrlLauncherPlatform urlLauncher;
|
||||||
|
|
||||||
|
setUp(() {
|
||||||
|
urlLauncher = MockUrlLauncher();
|
||||||
|
UrlLauncherPlatform.instance = urlLauncher;
|
||||||
|
});
|
||||||
|
|
||||||
|
group('openLink', () {
|
||||||
|
test('launches the link', () async {
|
||||||
|
when(
|
||||||
|
() => urlLauncher.canLaunch(any()),
|
||||||
|
).thenAnswer(
|
||||||
|
(_) async => true,
|
||||||
|
);
|
||||||
|
when(
|
||||||
|
() => urlLauncher.launch(
|
||||||
|
any(),
|
||||||
|
useSafariVC: any(named: 'useSafariVC'),
|
||||||
|
useWebView: any(named: 'useWebView'),
|
||||||
|
enableJavaScript: any(named: 'enableJavaScript'),
|
||||||
|
enableDomStorage: any(named: 'enableDomStorage'),
|
||||||
|
universalLinksOnly: any(named: 'universalLinksOnly'),
|
||||||
|
headers: any(named: 'headers'),
|
||||||
|
),
|
||||||
|
).thenAnswer(
|
||||||
|
(_) async => true,
|
||||||
|
);
|
||||||
|
await openLink('uri');
|
||||||
|
verify(
|
||||||
|
() => urlLauncher.launch(
|
||||||
|
any(),
|
||||||
|
useSafariVC: any(named: 'useSafariVC'),
|
||||||
|
useWebView: any(named: 'useWebView'),
|
||||||
|
enableJavaScript: any(named: 'enableJavaScript'),
|
||||||
|
enableDomStorage: any(named: 'enableDomStorage'),
|
||||||
|
universalLinksOnly: any(named: 'universalLinksOnly'),
|
||||||
|
headers: any(named: 'headers'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('executes the onError callback when it cannot launch', () async {
|
||||||
|
var wasCalled = false;
|
||||||
|
when(
|
||||||
|
() => urlLauncher.canLaunch(any()),
|
||||||
|
).thenAnswer(
|
||||||
|
(_) async => false,
|
||||||
|
);
|
||||||
|
when(
|
||||||
|
() => urlLauncher.launch(
|
||||||
|
any(),
|
||||||
|
useSafariVC: any(named: 'useSafariVC'),
|
||||||
|
useWebView: any(named: 'useWebView'),
|
||||||
|
enableJavaScript: any(named: 'enableJavaScript'),
|
||||||
|
enableDomStorage: any(named: 'enableDomStorage'),
|
||||||
|
universalLinksOnly: any(named: 'universalLinksOnly'),
|
||||||
|
headers: any(named: 'headers'),
|
||||||
|
),
|
||||||
|
).thenAnswer(
|
||||||
|
(_) async => true,
|
||||||
|
);
|
||||||
|
await openLink(
|
||||||
|
'url',
|
||||||
|
onError: () {
|
||||||
|
wasCalled = true;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await expectLater(wasCalled, isTrue);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pinball_ui/pinball_ui.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('PinballColors', () {
|
||||||
|
test('white is 0xFFFFFFFF', () {
|
||||||
|
expect(PinballColors.white, const Color(0xFFFFFFFF));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('darkBlue is 0xFF0C32A4', () {
|
||||||
|
expect(PinballColors.darkBlue, const Color(0xFF0C32A4));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('yellow is 0xFFFFEE02', () {
|
||||||
|
expect(PinballColors.yellow, const Color(0xFFFFEE02));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('orange is 0xFFE5AB05', () {
|
||||||
|
expect(PinballColors.orange, const Color(0xFFE5AB05));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('blue is 0xFF4B94F6', () {
|
||||||
|
expect(PinballColors.blue, const Color(0xFF4B94F6));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('transparent is 0x00000000', () {
|
||||||
|
expect(PinballColors.transparent, const Color(0x00000000));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pinball_ui/pinball_ui.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('PinballTextStyle', () {
|
||||||
|
test('headline1 has fontSize 28 and white color', () {
|
||||||
|
const style = PinballTextStyle.headline1;
|
||||||
|
expect(style.fontSize, 28);
|
||||||
|
expect(style.color, PinballColors.white);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('headline2 has fontSize 24', () {
|
||||||
|
const style = PinballTextStyle.headline2;
|
||||||
|
expect(style.fontSize, 24);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('headline3 has fontSize 20 and white color', () {
|
||||||
|
const style = PinballTextStyle.headline3;
|
||||||
|
expect(style.fontSize, 20);
|
||||||
|
expect(style.color, PinballColors.white);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('headline4 has fontSize 16 and white color', () {
|
||||||
|
const style = PinballTextStyle.headline4;
|
||||||
|
expect(style.fontSize, 16);
|
||||||
|
expect(style.color, PinballColors.white);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtitle1 has fontSize 10 and yellow color', () {
|
||||||
|
const style = PinballTextStyle.subtitle1;
|
||||||
|
expect(style.fontSize, 10);
|
||||||
|
expect(style.color, PinballColors.yellow);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtitle2 has fontSize 16 and white color', () {
|
||||||
|
const style = PinballTextStyle.subtitle2;
|
||||||
|
expect(style.fontSize, 16);
|
||||||
|
expect(style.color, PinballColors.white);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pinball_ui/pinball_ui.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('PinballTheme', () {
|
||||||
|
group('standard', () {
|
||||||
|
test('headline1 matches PinballTextStyle#headline1', () {
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.headline1!.fontSize,
|
||||||
|
PinballTextStyle.headline1.fontSize,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.headline1!.color,
|
||||||
|
PinballTextStyle.headline1.color,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.headline1!.fontFamily,
|
||||||
|
PinballTextStyle.headline1.fontFamily,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('headline2 matches PinballTextStyle#headline2', () {
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.headline2!.fontSize,
|
||||||
|
PinballTextStyle.headline2.fontSize,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.headline2!.fontFamily,
|
||||||
|
PinballTextStyle.headline2.fontFamily,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.headline2!.fontWeight,
|
||||||
|
PinballTextStyle.headline2.fontWeight,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('headline3 matches PinballTextStyle#headline3', () {
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.headline3!.fontSize,
|
||||||
|
PinballTextStyle.headline3.fontSize,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.headline3!.color,
|
||||||
|
PinballTextStyle.headline3.color,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.headline3!.fontFamily,
|
||||||
|
PinballTextStyle.headline3.fontFamily,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('headline4 matches PinballTextStyle#headline4', () {
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.headline4!.fontSize,
|
||||||
|
PinballTextStyle.headline4.fontSize,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.headline4!.color,
|
||||||
|
PinballTextStyle.headline4.color,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.headline4!.fontFamily,
|
||||||
|
PinballTextStyle.headline4.fontFamily,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtitle1 matches PinballTextStyle#subtitle1', () {
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.subtitle1!.fontSize,
|
||||||
|
PinballTextStyle.subtitle1.fontSize,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.subtitle1!.color,
|
||||||
|
PinballTextStyle.subtitle1.color,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.subtitle1!.fontFamily,
|
||||||
|
PinballTextStyle.subtitle1.fontFamily,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtitle2 matches PinballTextStyle#subtitle2', () {
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.subtitle2!.fontSize,
|
||||||
|
PinballTextStyle.subtitle2.fontSize,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.subtitle2!.color,
|
||||||
|
PinballTextStyle.subtitle2.color,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
PinballTheme.standard.textTheme.subtitle2!.fontFamily,
|
||||||
|
PinballTextStyle.subtitle2.fontFamily,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:mocktail/mocktail.dart';
|
||||||
|
import 'package:pinball/footer/footer.dart';
|
||||||
|
import 'package:pinball_ui/pinball_ui.dart';
|
||||||
|
|
||||||
|
import '../helpers/helpers.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('Footer', () {
|
||||||
|
late UrlLauncherPlatform urlLauncher;
|
||||||
|
|
||||||
|
setUp(() async {
|
||||||
|
urlLauncher = MockUrlLauncher();
|
||||||
|
UrlLauncherPlatform.instance = urlLauncher;
|
||||||
|
});
|
||||||
|
testWidgets('renders "Made with..." and "Google I/O"', (tester) async {
|
||||||
|
await tester.pumpApp(const Footer());
|
||||||
|
expect(find.text('Google I/O'), findsOneWidget);
|
||||||
|
expect(
|
||||||
|
find.byWidgetPredicate(
|
||||||
|
(widget) =>
|
||||||
|
widget is RichText &&
|
||||||
|
widget.text.toPlainText() == 'Made with Flutter & Firebase',
|
||||||
|
),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'tapping on "Flutter" opens the flutter website',
|
||||||
|
(tester) async {
|
||||||
|
when(() => urlLauncher.canLaunch(any())).thenAnswer((_) async => true);
|
||||||
|
when(
|
||||||
|
() => urlLauncher.launch(
|
||||||
|
any(),
|
||||||
|
useSafariVC: any(named: 'useSafariVC'),
|
||||||
|
useWebView: any(named: 'useWebView'),
|
||||||
|
enableJavaScript: any(named: 'enableJavaScript'),
|
||||||
|
enableDomStorage: any(named: 'enableDomStorage'),
|
||||||
|
universalLinksOnly: any(named: 'universalLinksOnly'),
|
||||||
|
headers: any(named: 'headers'),
|
||||||
|
),
|
||||||
|
).thenAnswer((_) async => true);
|
||||||
|
await tester.pumpApp(const Footer());
|
||||||
|
final flutterTextFinder = find.byWidgetPredicate(
|
||||||
|
(widget) => widget is RichText && tapTextSpan(widget, 'Flutter'),
|
||||||
|
);
|
||||||
|
await tester.tap(flutterTextFinder);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
verify(
|
||||||
|
() => urlLauncher.launch(
|
||||||
|
'https://flutter.dev',
|
||||||
|
useSafariVC: any(named: 'useSafariVC'),
|
||||||
|
useWebView: any(named: 'useWebView'),
|
||||||
|
enableJavaScript: any(named: 'enableJavaScript'),
|
||||||
|
enableDomStorage: any(named: 'enableDomStorage'),
|
||||||
|
universalLinksOnly: any(named: 'universalLinksOnly'),
|
||||||
|
headers: any(named: 'headers'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'tapping on "Firebase" opens the firebase website',
|
||||||
|
(tester) async {
|
||||||
|
when(() => urlLauncher.canLaunch(any())).thenAnswer((_) async => true);
|
||||||
|
when(
|
||||||
|
() => urlLauncher.launch(
|
||||||
|
any(),
|
||||||
|
useSafariVC: any(named: 'useSafariVC'),
|
||||||
|
useWebView: any(named: 'useWebView'),
|
||||||
|
enableJavaScript: any(named: 'enableJavaScript'),
|
||||||
|
enableDomStorage: any(named: 'enableDomStorage'),
|
||||||
|
universalLinksOnly: any(named: 'universalLinksOnly'),
|
||||||
|
headers: any(named: 'headers'),
|
||||||
|
),
|
||||||
|
).thenAnswer((_) async => true);
|
||||||
|
await tester.pumpApp(const Footer());
|
||||||
|
final firebaseTextFinder = find.byWidgetPredicate(
|
||||||
|
(widget) => widget is RichText && tapTextSpan(widget, 'Firebase'),
|
||||||
|
);
|
||||||
|
await tester.tap(firebaseTextFinder);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
verify(
|
||||||
|
() => urlLauncher.launch(
|
||||||
|
'https://firebase.google.com',
|
||||||
|
useSafariVC: any(named: 'useSafariVC'),
|
||||||
|
useWebView: any(named: 'useWebView'),
|
||||||
|
enableJavaScript: any(named: 'enableJavaScript'),
|
||||||
|
enableDomStorage: any(named: 'enableDomStorage'),
|
||||||
|
universalLinksOnly: any(named: 'universalLinksOnly'),
|
||||||
|
headers: any(named: 'headers'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
bool tapTextSpan(RichText richText, String text) {
|
||||||
|
final isTapped = !richText.text.visitChildren(
|
||||||
|
(visitor) => _findTextAndTap(visitor, text),
|
||||||
|
);
|
||||||
|
return isTapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _findTextAndTap(InlineSpan visitor, String text) {
|
||||||
|
if (visitor is TextSpan && visitor.text == text) {
|
||||||
|
(visitor.recognizer as TapGestureRecognizer?)?.onTap?.call();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
if (typeof firebase === 'undefined') throw new Error('hosting/init-error: Firebase SDK not detected. You must include it before /__/firebase/init.js');
|
if (typeof firebase === 'undefined') throw new Error('hosting/init-error: Firebase SDK not detected. You must include it before /__/firebase/init.js');
|
||||||
firebase.initializeApp({
|
firebase.initializeApp({
|
||||||
"apiKey": "API_KEY",
|
"apiKey": "AIzaSyBgMVAvYccjNypCDdpW0ol6syCcISU2yjM",
|
||||||
"appId": "APP_ID",
|
"appId": "1:725488140557:web:7c61a0755fc23436fe7044",
|
||||||
"authDomain": "AUTH_DOMAIN",
|
"authDomain": "pinball-dev.firebaseapp.com",
|
||||||
"databaseURL": "",
|
"databaseURL": "",
|
||||||
"measurementId": "MEASUREMENT_ID",
|
"measurementId": "G-9NW8SZRFJR",
|
||||||
"messagingSenderId": "MEASUREMENT_SENDER_ID",
|
"messagingSenderId": "725488140557",
|
||||||
"projectId": "PROJECT_ID",
|
"projectId": "pinball-dev",
|
||||||
"storageBucket": "STORAGE_BUCKET"
|
"storageBucket": "pinball-dev.appspot.com"
|
||||||
});
|
});
|