Skip to content

Commit

Permalink
feat: changed the ThemeConfiguratorWidget to ImpaktfullThemeConfigura…
Browse files Browse the repository at this point in the history
…torWidget
  • Loading branch information
vanlooverenkoen committed Oct 1, 2024
1 parent f270ac9 commit 894d78f
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 94 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.12.0

## Breaking

- Changed ThemeConfiguratorWidget to ImpaktfullThemeConfiguratorWidget

# 0.11.0

## Fix
Expand Down
186 changes: 96 additions & 90 deletions lib/src/impaktfull_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:impaktfull_ui/src/theme/impaktfull_theme.dart';
import 'package:impaktfull_ui/src/theme/theme_configurator.dart';
import 'package:impaktfull_ui/src/theme/theme_configurator_widget.dart';
import 'package:intl/intl.dart' as intl;
import 'package:snacky/snacky.dart';

Expand Down Expand Up @@ -47,97 +48,102 @@ class ImpaktfullApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
setImpaktfullTheme(impaktfullTheme);
setImpaktfullLocale(locale);
return SnackyConfiguratorWidget(
textDirection: intl.Bidi.isRtlLanguage(locale?.languageCode ?? '')
? TextDirection.rtl
: TextDirection.ltr,
snackyController: snackyController,
snackyBuilder: snackyBuilder ??
SimpleSnackyBuilder(
borderRadius:
BorderRadius.circular(theme.dimens.generalBorderRadius),
colorBuilder: (snacky) {
switch (snacky.type) {
case SnackyType.error:
return Color.lerp(theme.colors.error, Colors.white, 0.8) ??
theme.colors.error;
case SnackyType.info:
return Color.lerp(theme.colors.info, Colors.white, 0.8) ??
theme.colors.info;
case SnackyType.success:
return Color.lerp(theme.colors.success, Colors.white, 0.8) ??
theme.colors.success;
case SnackyType.warning:
return Color.lerp(theme.colors.warning, Colors.white, 0.8) ??
theme.colors.warning;
case SnackyType.branded:
return Color.lerp(theme.colors.accent1, Colors.white, 0.8) ??
theme.colors.accent1;
}
},
borderBuilder: (snacky) {
final width = theme.dimens.borderWidth;
switch (snacky.type) {
case SnackyType.error:
return Border.all(
color: theme.colors.error,
width: width,
);
case SnackyType.info:
return Border.all(
color: theme.colors.info,
width: width,
);
case SnackyType.success:
return Border.all(
color: theme.colors.success,
width: width,
);
case SnackyType.warning:
return Border.all(
color: theme.colors.warning,
width: width,
);
case SnackyType.branded:
return Border.all(
color: theme.colors.accent1,
width: width,
);
}
},
),
app: Builder(
builder: (context) {
final app = MaterialApp(
title: title,
home: home,
debugShowCheckedModeBanner: showDebugFlag,
locale: locale,
theme: (materialLightTheme ?? Theme.of(context))
.removeUnwantedBehavior(
targetPlatform: targetPlatform,
return ImpaktfullThemeConfiguratorWidget(
theme: impaktfullTheme,
locale: locale,
child: SnackyConfiguratorWidget(
textDirection: intl.Bidi.isRtlLanguage(locale?.languageCode ?? '')
? TextDirection.rtl
: TextDirection.ltr,
snackyController: snackyController,
snackyBuilder: snackyBuilder ??
SimpleSnackyBuilder(
borderRadius:
BorderRadius.circular(theme.dimens.generalBorderRadius),
colorBuilder: (snacky) {
switch (snacky.type) {
case SnackyType.error:
return Color.lerp(theme.colors.error, Colors.white, 0.8) ??
theme.colors.error;
case SnackyType.info:
return Color.lerp(theme.colors.info, Colors.white, 0.8) ??
theme.colors.info;
case SnackyType.success:
return Color.lerp(
theme.colors.success, Colors.white, 0.8) ??
theme.colors.success;
case SnackyType.warning:
return Color.lerp(
theme.colors.warning, Colors.white, 0.8) ??
theme.colors.warning;
case SnackyType.branded:
return Color.lerp(
theme.colors.accent1, Colors.white, 0.8) ??
theme.colors.accent1;
}
},
borderBuilder: (snacky) {
final width = theme.dimens.borderWidth;
switch (snacky.type) {
case SnackyType.error:
return Border.all(
color: theme.colors.error,
width: width,
);
case SnackyType.info:
return Border.all(
color: theme.colors.info,
width: width,
);
case SnackyType.success:
return Border.all(
color: theme.colors.success,
width: width,
);
case SnackyType.warning:
return Border.all(
color: theme.colors.warning,
width: width,
);
case SnackyType.branded:
return Border.all(
color: theme.colors.accent1,
width: width,
);
}
},
),
darkTheme: (materialLightTheme ?? Theme.of(context))
.removeUnwantedBehavior(
targetPlatform: targetPlatform,
),
supportedLocales: supportedLocales,
localizationsDelegates: localizationsDelegates,
navigatorKey: navigatorKey,
initialRoute: initialRoute,
onGenerateRoute: onGenerateRoute,
navigatorObservers: [
SnackyNavigationObserver(),
...navigatorObservers,
],
);
if (builder == null) {
return app;
}
return builder!(context, app);
},
app: Builder(
builder: (context) {
final app = MaterialApp(
title: title,
home: home,
debugShowCheckedModeBanner: showDebugFlag,
locale: locale,
theme: (materialLightTheme ?? Theme.of(context))
.removeUnwantedBehavior(
targetPlatform: targetPlatform,
),
darkTheme: (materialLightTheme ?? Theme.of(context))
.removeUnwantedBehavior(
targetPlatform: targetPlatform,
),
supportedLocales: supportedLocales,
localizationsDelegates: localizationsDelegates,
navigatorKey: navigatorKey,
initialRoute: initialRoute,
onGenerateRoute: onGenerateRoute,
navigatorObservers: [
SnackyNavigationObserver(),
...navigatorObservers,
],
);
if (builder == null) {
return app;
}
return builder!(context, app);
},
),
),
);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/src/theme/theme_configurator_widget.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import 'package:impaktfull_ui/impaktfull_ui.dart';
import 'package:impaktfull_ui/src/theme/theme_configurator.dart';

class ThemeConfiguratorWidget extends StatelessWidget {
class ImpaktfullThemeConfiguratorWidget extends StatelessWidget {
final ImpaktfullTheme? theme;
final Locale locale;
final Locale? locale;
final Widget child;

const ThemeConfiguratorWidget({
const ImpaktfullThemeConfiguratorWidget({
required this.child,
this.theme,
this.locale = const Locale('en'),
this.locale,
super.key,
});

Expand Down

0 comments on commit 894d78f

Please sign in to comment.