Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conference app setup #3

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/catalog/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class WidgetbookApp extends StatelessWidget {
extensions: <ThemeExtension<dynamic>>[
/// Use the below format for raw theme data
/// DevFestTheme(textTheme: DevfestTextTheme()),
DevFestTheme.light(),
DevFestThemeData.light(),
],
),
),
Expand All @@ -64,7 +64,7 @@ class WidgetbookApp extends StatelessWidget {
extensions: <ThemeExtension<dynamic>>[
/// Use the below format for raw theme data
/// DevFestTheme(textTheme: DevfestTextTheme()),
DevFestTheme.dark(),
DevFestThemeData.dark(),
],
),
),
Expand All @@ -80,7 +80,7 @@ class WidgetbookApp extends StatelessWidget {
debugShowCheckedModeBanner: false,
theme: theme.copyWith(
extensions: [
isDark ? DevFestTheme.dark() : DevFestTheme.light()
isDark ? DevFestThemeData.dark() : DevFestThemeData.light()
],
),
home: Material(child: child),
Expand Down
2 changes: 1 addition & 1 deletion packages/catalog/lib/usecases/bottom_nav.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Widget devfestBottomNav(BuildContext context) {
int index = 0;
return StatefulBuilder(builder: (context, setState) {
return Scaffold(
backgroundColor: DevFestTheme.of(context).backgroundColor,
backgroundColor: DevfestTheme.of(context).backgroundColor,
bottomNavigationBar: DevfestBottomNav(
index: index,
items: const [
Expand Down
4 changes: 2 additions & 2 deletions packages/catalog/lib/usecases/buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;
@widgetbook.UseCase(name: 'Filled Button', type: DevfestFilledButton)
Widget devfestFilledButton(BuildContext context) {
return Material(
color: DevFestTheme.of(context).backgroundColor,
color: DevfestTheme.of(context).backgroundColor,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
Expand Down Expand Up @@ -46,7 +46,7 @@ Widget devfestFilledButton(BuildContext context) {
@widgetbook.UseCase(name: 'Outlined Button', type: DevfestOutlinedButton)
Widget devfestOutlinedButton(BuildContext context) {
return Material(
color: DevFestTheme.of(context).backgroundColor,
color: DevfestTheme.of(context).backgroundColor,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
Expand Down
2 changes: 1 addition & 1 deletion packages/catalog/lib/usecases/text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;
Widget devfestTextField(BuildContext context) {
return StatefulBuilder(builder: (context, setState) {
return Scaffold(
backgroundColor: DevFestTheme.of(context).backgroundColor,
backgroundColor: DevfestTheme.of(context).backgroundColor,
body: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
Expand Down
27 changes: 12 additions & 15 deletions packages/cave/lib/themes/theme_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'colors.dart';
import 'text_field_theme.dart';
import 'typography.dart';

class DevFestTheme extends ThemeExtension<DevFestTheme> {
class DevFestThemeData extends ThemeExtension<DevFestThemeData> {
/// Create and register new themes here
final DevfestTextTheme? textTheme;
final DevfestButtonTheme? buttonTheme;
Expand All @@ -15,10 +15,7 @@ class DevFestTheme extends ThemeExtension<DevFestTheme> {
final DevfestTextFieldTheme? textFieldTheme;
final Color? backgroundColor;

static DevFestTheme of(BuildContext context) =>
Theme.of(context).extension<DevFestTheme>()!;

const DevFestTheme({
const DevFestThemeData({
this.textTheme,
this.backgroundColor,
this.bottomNavTheme,
Expand All @@ -27,19 +24,19 @@ class DevFestTheme extends ThemeExtension<DevFestTheme> {
this.textFieldTheme,
});

DevFestTheme.light()
DevFestThemeData.light()
: this(
textTheme: const DevfestTextTheme.responsive(),
backgroundColor: DevfestColors.backgroundLight,
textTheme: DevfestTextTheme.light(),
backgroundColor: DevfestColors.primariesYellow100,
buttonTheme: const DevfestButtonTheme.light(),
outlinedButtonTheme: const DevfestOutlinedButtonTheme.light(),
bottomNavTheme: const DevfestBottomNavTheme.light(),
textFieldTheme: DevfestTextFieldTheme.light(),
);

DevFestTheme.dark()
DevFestThemeData.dark()
: this(
textTheme: const DevfestTextTheme.responsive(),
textTheme: DevfestTextTheme.dark(),
backgroundColor: DevfestColors.backgroundDark,
textFieldTheme: DevfestTextFieldTheme.dark(),
buttonTheme: const DevfestButtonTheme.dark(),
Expand All @@ -48,13 +45,13 @@ class DevFestTheme extends ThemeExtension<DevFestTheme> {
);

@override
DevFestTheme copyWith({
DevFestThemeData copyWith({
DevfestTextTheme? textTheme,
DevfestButtonTheme? buttonTheme,
DevfestOutlinedButtonTheme? outlinedButtonTheme,
DevfestBottomNavTheme? bottomNavTheme,
}) {
return DevFestTheme(
return DevFestThemeData(
textTheme: textTheme ?? this.textTheme,
buttonTheme: buttonTheme ?? this.buttonTheme,
outlinedButtonTheme: outlinedButtonTheme ?? this.outlinedButtonTheme,
Expand All @@ -63,9 +60,9 @@ class DevFestTheme extends ThemeExtension<DevFestTheme> {
}

@override
DevFestTheme lerp(DevFestTheme? other, double t) {
if (other is! DevFestTheme) return this;
return DevFestTheme(
DevFestThemeData lerp(DevFestThemeData? other, double t) {
if (other is! DevFestThemeData) return this;
return DevFestThemeData(
textTheme: textTheme?.lerp(other.textTheme, t),
backgroundColor: Color.lerp(backgroundColor, other.backgroundColor, t),
buttonTheme: buttonTheme?.lerp(other.buttonTheme, t),
Expand Down
7 changes: 5 additions & 2 deletions packages/cave/lib/themes/theme_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'theme_data.dart';
import 'package:flutter/material.dart';

class DevfestTheme extends StatelessWidget {
final DevFestTheme data;
final DevFestThemeData data;
final Widget child;

const DevfestTheme({
Expand All @@ -11,12 +11,15 @@ class DevfestTheme extends StatelessWidget {
required this.child,
});

static DevFestThemeData of(BuildContext context) =>
Theme.of(context).extension<DevFestThemeData>()!;

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final themeExtensions = Map<Object, ThemeExtension>.from(theme.extensions);

themeExtensions[DevFestTheme] = data;
themeExtensions[DevFestThemeData] = data;
return Theme(
data: theme.copyWith(extensions: themeExtensions.values),
child: child,
Expand Down
Loading