Skip to content

Commit

Permalink
chore: Format.
Browse files Browse the repository at this point in the history
  • Loading branch information
coire1 committed May 9, 2024
1 parent f8e4a94 commit 3981421
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import 'package:catalyst_voices_brands/src/themes/fallback.dart';
import 'package:flutter/material.dart';

/// A utility class to build themes dynamically based on brand keys.
///
///
/// [buildTheme] can be used to obtain the corresponding theme data for the
/// [BrandKey] passed to the method.
///
///
/// [buildDarkTheme] operates in the same way but picks the dark version of the
/// theme for a specific brand.
///
/// For each brand there is a specific key defined in the [BrandKey] enum
/// theme for a specific brand.
///
/// For each brand there is a specific key defined in the [BrandKey] enum
/// and a corresponding [ThemeData] in the `themes` folder.
/// For each brand a light and a dark [ThemeData] should be defined.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,46 @@ void main() {
const fallbackKey = Key('F');

Widget buildApp() => BlocProvider(
create: (context) => BrandBloc(),
child: BlocBuilder<BrandBloc, BrandState>(
builder: (context, state) {
return MaterialApp(
home: Builder(
builder: (context) => Scaffold(
body: Row(
children: [
MaterialButton(
key: catalystKey,
color: Theme.of(context).primaryColor,
onPressed: () {
context.read<BrandBloc>().add(
const BrandChangedEvent(BrandKey.catalyst),
);
},
child: const Text('Catalyst'),
create: (context) => BrandBloc(),
child: BlocBuilder<BrandBloc, BrandState>(
builder: (context, state) {
return MaterialApp(
home: Builder(
builder: (context) => Scaffold(
body: Row(
children: [
MaterialButton(
key: catalystKey,
color: Theme.of(context).primaryColor,
onPressed: () {
context.read<BrandBloc>().add(
const BrandChangedEvent(BrandKey.catalyst),
);
},
child: const Text('Catalyst'),
),
MaterialButton(
key: fallbackKey,
color: Theme.of(context).primaryColor,
child: const Text('Fallback'),
onPressed: () {
context.read<BrandBloc>().add(
const BrandChangedEvent(BrandKey.fallback),
);
},
),
],
),
MaterialButton(
key: fallbackKey,
color: Theme.of(context).primaryColor,
child: const Text('Fallback'),
onPressed: () {
context.read<BrandBloc>().add(
const BrandChangedEvent(BrandKey.fallback),
);
},
),
],
),
),
),
),
theme: ThemeBuilder.buildTheme(state.brandKey),
darkTheme: ThemeBuilder.buildTheme(state.brandKey),
);
},
),
);
theme: ThemeBuilder.buildTheme(state.brandKey),
darkTheme: ThemeBuilder.buildTheme(state.brandKey),
);
},
),
);

group('Test brands', () {

// Colors used in the Brand themes as primary. They are used for
// the color of the widgets we are testing and they are the colors
// we will check against to ensure correct rendering.
Expand Down Expand Up @@ -86,10 +85,10 @@ void main() {

expect(catalystButton, findsOneWidget);
expect(fallbackButton, findsOneWidget);

await tester.tap(fallbackButton);
// We need to wait for the animation to complete
await tester.pumpAndSettle();
await tester.pumpAndSettle();
expect(
tester.widget<MaterialButton>(catalystButton).color,
fallbackColor,
Expand All @@ -110,14 +109,14 @@ void main() {

expect(catalystButton, findsOneWidget);
expect(fallbackButton, findsOneWidget);

// We first switch do FallbackBrand, we wait for the animation completion
// and then we switch back to the CatalystBrand to check the correct
// color is applied.
await tester.tap(fallbackButton);
await tester.pumpAndSettle();
await tester.tap(catalystButton);
await tester.pumpAndSettle();
await tester.pumpAndSettle();
expect(
tester.widget<MaterialButton>(catalystButton).color,
catalystColor,
Expand All @@ -127,7 +126,5 @@ void main() {
catalystColor,
);
});

});

}

0 comments on commit 3981421

Please sign in to comment.