Skip to content

Commit

Permalink
feat: Add new theme animations - CU-86c0287m8
Browse files Browse the repository at this point in the history
  • Loading branch information
basemosama committed Aug 22, 2024
1 parent 454b409 commit 6e17197
Show file tree
Hide file tree
Showing 8 changed files with 381 additions and 222 deletions.
44 changes: 23 additions & 21 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import 'package:playx_theme/playx_theme.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();

/// * boot the core
await PlayxCore.bootCore();

/// boot the AppTheme
await PlayxTheme.boot(config: ThemeConfig());

Expand All @@ -20,19 +17,14 @@ class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return PlayxThemeBuilder(
duration: const Duration(milliseconds: 300),
builder: (ctx, xTheme) {
return MaterialApp(
title: 'Flutter Demo',
theme: xTheme.themeBuilder?.call(const Locale('en')) ??
xTheme.themeData,
initialRoute: '/',
routes: {
'/': (context) => const HomeScreen(),
},
);
});
return PlayxThemeBuilder(builder: (ctx, xTheme) {
return MaterialApp(
title: 'Flutter Demo',
theme:
xTheme.themeBuilder?.call(const Locale('en')) ?? xTheme.themeData,
home: const HomeScreen(),
);
});
}
}

Expand Down Expand Up @@ -88,8 +80,7 @@ class HomeScreen extends StatelessWidget {
.supportedThemes[
index]
.id
? PlayxColors.of(context)
.primary
? context.playxColors.primary
: Colors.transparent,
),
),
Expand All @@ -111,8 +102,15 @@ class HomeScreen extends StatelessWidget {
Navigator.of(dialogContext)
.pop(); // Dismiss alert dialog

PlayxTheme.updateById(PlayxTheme
.supportedThemes[index].id);
PlayxTheme.updateById(
PlayxTheme
.supportedThemes[index]
.id,
animation:
const PlayxThemeAnimation(
clipper:
ThemeSwitcherBoxClipper(),
));
},
),
)),
Expand Down Expand Up @@ -143,6 +141,9 @@ class HomeScreen extends StatelessWidget {
onPressed: () {
PlayxTheme.next(
context: ctx,
animation: const PlayxThemeAnimation(
duration: Duration(milliseconds: 500),
type: PlayxThemeAnimationType.fade),
);
},
child: const Text('Next Theme'),
Expand All @@ -155,7 +156,8 @@ class HomeScreen extends StatelessWidget {
builder: (ctx, theme) => FloatingActionButton(
onPressed: () {
PlayxTheme.next(
context: ctx, clipper: const ThemeSwitcherBoxClipper());
context: ctx,
);
},
tooltip: 'Next Theme',
child: Icon(
Expand Down
2 changes: 2 additions & 0 deletions lib/playx_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export 'package:playx_core/playx_core.dart';

export 'src/config/config.dart';
export 'src/model/playx_colors.dart';
export 'src/model/playx_theme_animation.dart';
export 'src/model/playx_theme_animation_type.dart';
export 'src/model/x_theme.dart';
export 'src/playx_theme.dart';
export 'src/utils/build_context_extension.dart';
Expand Down
Loading

0 comments on commit 6e17197

Please sign in to comment.