Skip to content

Commit

Permalink
fix: expose snackyBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Mar 1, 2024
1 parent 8a4f471 commit 846f75b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 44 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.0.21

## Feat

- ImpaktfullApp now exposes `snackyBuilder` to set a custom snakcyBuilder

# 0.0.20

## Feat
Expand Down
92 changes: 48 additions & 44 deletions lib/src/impaktfull_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:snacky/snacky.dart';
class ImpaktfullApp extends StatelessWidget {
final String title;
final Widget? home;
final SnackyBuilder? snackyBuilder;
final ImpaktfullTheme? impaktfullTheme;
final ThemeData? materialLightTheme;
final ThemeData? materialDarkTheme;
Expand All @@ -23,6 +24,7 @@ class ImpaktfullApp extends StatelessWidget {
const ImpaktfullApp({
required this.title,
this.home,
this.snackyBuilder,
this.impaktfullTheme,
this.materialLightTheme,
this.materialDarkTheme,
Expand All @@ -43,50 +45,52 @@ class ImpaktfullApp extends StatelessWidget {
setImpaktfullTheme(impaktfullTheme);
setImpaktfullLocale(locale);
return SnackyConfiguratorWidget(
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;
}
},
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,
);
}
},
),
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;
}
},
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,
);
}
},
),
app: Builder(
builder: (context) {
final app = MaterialApp(
Expand Down

0 comments on commit 846f75b

Please sign in to comment.