From dca6a6468cd54f80c5166216f92a0e987b822758 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:54:07 -0300 Subject: [PATCH] remove token from example --- .../todo_list/lib/pages/todo_list_page.dart | 20 ++- examples/todo_list/lib/style/token.dart | 137 ---------------- examples/todo_list/lib/style/token.g.dart | 155 ------------------ 3 files changed, 12 insertions(+), 300 deletions(-) delete mode 100644 examples/todo_list/lib/style/token.dart delete mode 100644 examples/todo_list/lib/style/token.g.dart diff --git a/examples/todo_list/lib/pages/todo_list_page.dart b/examples/todo_list/lib/pages/todo_list_page.dart index d904fde7d..db1cc5702 100644 --- a/examples/todo_list/lib/pages/todo_list_page.dart +++ b/examples/todo_list/lib/pages/todo_list_page.dart @@ -66,14 +66,18 @@ class _TodoListPageState extends State { onPressed: () { Future.delayed( const Duration(milliseconds: 200), - () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => AddTaskPage( - controller: _controller, - ), - ), - ), + () { + if (mounted) { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AddTaskPage( + controller: _controller, + ), + ), + ); + } + }, ); }, ), diff --git a/examples/todo_list/lib/style/token.dart b/examples/todo_list/lib/style/token.dart deleted file mode 100644 index f84c47520..000000000 --- a/examples/todo_list/lib/style/token.dart +++ /dev/null @@ -1,137 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:mix/mix.dart'; -import 'package:mix_annotations/mix_annotations.dart'; - -part 'token.g.dart'; - -final theme = MixThemeData( - colors: const MyThemeColorToken( - primary: Colors.blue, - onPrimary: Colors.white, - surface: ColorSwatch(2, { - 1: Colors.blue, - 2: Colors.blue, - }), - onSurface: Colors.black, - onSurfaceVariant: Colors.grey, - ).toMap, -); - -@MixableToken( - Color, - namespace: 'c', -) -class MyThemeColorToken { - final Color primary; - final Color onPrimary; - final Color onSurface; - - @MixableSwatchColorToken(scale: 12) - final Color onSurfaceVariant; - - final ColorSwatch surface; - - const MyThemeColorToken({ - required this.primary, - required this.onPrimary, - required this.surface, - required this.onSurface, - required this.onSurfaceVariant, - }); - - Map get toMap => _$MyThemeColorTokenToMap(this); -} - -@MixableToken( - TextStyle, - utilityExtension: false, - contextExtension: false, -) -class MyThemeTextStyleToken { - final TextStyle headline1; - final TextStyle headline2; - final TextStyle headline3; - final TextStyle body; - final TextStyle callout; - - const MyThemeTextStyleToken({ - required this.headline1, - required this.headline2, - required this.headline3, - required this.body, - required this.callout, - }); - - Map get toMap => - _$MyThemeTextStyleTokenToMap(this); -} - -@MixableToken(Radius) -class MyThemeRadiusToken { - const MyThemeRadiusToken({ - required this.large, - required this.medium, - }); - - final Radius large; - final Radius medium; - - Map get toMap => _$MyThemeRadiusTokenToMap(this); -} - -@MixableToken(double) -class MyThemeSpaceToken { - const MyThemeSpaceToken({ - required this.medium, - required this.large, - }); - - final double medium; - final double large; - - Map get toMap => _$MyThemeSpaceTokenToMap(this); -} - -final lightBlueTheme = MixThemeData( - colors: const MyThemeColorToken( - primary: Color(0xFF0093B9), - onPrimary: Color(0xFFFAFAFA), - surface: ColorSwatch(0xFFFAFAFA, { - 1: Color(0xFFFAFAFA), - 2: Color(0xFFFAFAFA), - }), - onSurface: Color(0xFF141C24), - onSurfaceVariant: Color(0xFF405473), - ).toMap, - textStyles: MyThemeTextStyleToken( - headline1: GoogleFonts.plusJakartaSans( - fontSize: 22, - fontWeight: FontWeight.bold, - ), - headline2: GoogleFonts.plusJakartaSans( - fontSize: 18, - fontWeight: FontWeight.bold, - ), - headline3: GoogleFonts.plusJakartaSans( - fontSize: 14, - fontWeight: FontWeight.bold, - ), - body: GoogleFonts.plusJakartaSans( - fontSize: 16, - fontWeight: FontWeight.normal, - ), - callout: GoogleFonts.plusJakartaSans( - fontSize: 14, - fontWeight: FontWeight.normal, - ), - ).toMap, - radii: const MyThemeRadiusToken( - large: Radius.circular(100), - medium: Radius.circular(12), - ).toMap, - spaces: const MyThemeSpaceToken( - medium: 16, - large: 24, - ).toMap, -); diff --git a/examples/todo_list/lib/style/token.g.dart b/examples/todo_list/lib/style/token.g.dart deleted file mode 100644 index 7d1d2e4b8..000000000 --- a/examples/todo_list/lib/style/token.g.dart +++ /dev/null @@ -1,155 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'token.dart'; - -// ************************************************************************** -// MixableTokensGenerator -// ************************************************************************** - -class _$MyThemeColorTokenStruct { - _$MyThemeColorTokenStruct(); - - final ColorToken primary = const ColorToken('primary'); - final ColorToken onPrimary = const ColorToken('onPrimary'); - final ColorToken surface = const ColorToken('surface'); - final ColorToken onSurface = const ColorToken('onSurface'); - final ColorSwatchToken onSurfaceVariant = - ColorSwatchToken.scale('onSurfaceVariant', 12); -} - -final _structMyThemeColorToken = _$MyThemeColorTokenStruct(); - -Map _$MyThemeColorTokenToMap(MyThemeColorToken tokens) { - return { - _structMyThemeColorToken.primary: tokens.primary, - _structMyThemeColorToken.onPrimary: tokens.onPrimary, - _structMyThemeColorToken.surface: tokens.surface, - _structMyThemeColorToken.onSurface: tokens.onSurface, - _structMyThemeColorToken.onSurfaceVariant: tokens.onSurfaceVariant, - }; -} - -extension $MyThemeColorTokenColorUtilityX - on ColorUtility { - primary() => ref(_structMyThemeColorToken.primary); - onPrimary() => ref(_structMyThemeColorToken.onPrimary); - surface() => ref(_structMyThemeColorToken.surface); - onSurface() => ref(_structMyThemeColorToken.onSurface); - onSurfaceVariant([int step = 1]) => - ref(_structMyThemeColorToken.onSurfaceVariant[step]); -} - -class BuildContextMyThemeColorTokenMethods { - const BuildContextMyThemeColorTokenMethods(this.context); - - final BuildContext context; - primary() => _structMyThemeColorToken.primary.resolve(context); - onPrimary() => _structMyThemeColorToken.onPrimary.resolve(context); - surface() => _structMyThemeColorToken.surface.resolve(context); - onSurface() => _structMyThemeColorToken.onSurface.resolve(context); - onSurfaceVariant([int step = 1]) => - _structMyThemeColorToken.onSurfaceVariant[step].resolve(context); -} - -extension $BuildContextMyThemeColorTokenX on BuildContext { - BuildContextMyThemeColorTokenMethods get $c => - BuildContextMyThemeColorTokenMethods(this); -} - -class _$MyThemeTextStyleTokenStruct { - _$MyThemeTextStyleTokenStruct(); - - final TextStyleToken headline1 = const TextStyleToken('headline1'); - final TextStyleToken headline2 = const TextStyleToken('headline2'); - final TextStyleToken headline3 = const TextStyleToken('headline3'); - final TextStyleToken body = const TextStyleToken('body'); - final TextStyleToken callout = const TextStyleToken('callout'); -} - -final _structMyThemeTextStyleToken = _$MyThemeTextStyleTokenStruct(); - -Map _$MyThemeTextStyleTokenToMap( - MyThemeTextStyleToken tokens) { - return { - _structMyThemeTextStyleToken.headline1: tokens.headline1, - _structMyThemeTextStyleToken.headline2: tokens.headline2, - _structMyThemeTextStyleToken.headline3: tokens.headline3, - _structMyThemeTextStyleToken.body: tokens.body, - _structMyThemeTextStyleToken.callout: tokens.callout, - }; -} - -class _$MyThemeRadiusTokenStruct { - _$MyThemeRadiusTokenStruct(); - - final RadiusToken large = const RadiusToken('large'); - final RadiusToken medium = const RadiusToken('medium'); -} - -final _structMyThemeRadiusToken = _$MyThemeRadiusTokenStruct(); - -Map _$MyThemeRadiusTokenToMap(MyThemeRadiusToken tokens) { - return { - _structMyThemeRadiusToken.large: tokens.large, - _structMyThemeRadiusToken.medium: tokens.medium, - }; -} - -extension $MyThemeRadiusTokenRadiusUtilityX - on RadiusUtility { - large() => ref(_structMyThemeRadiusToken.large); - medium() => ref(_structMyThemeRadiusToken.medium); -} - -class BuildContextMyThemeRadiusTokenMethods { - const BuildContextMyThemeRadiusTokenMethods(this.context); - - final BuildContext context; - large() => _structMyThemeRadiusToken.large.resolve(context); - medium() => _structMyThemeRadiusToken.medium.resolve(context); -} - -extension $BuildContextMyThemeRadiusTokenX on BuildContext { - BuildContextMyThemeRadiusTokenMethods get $radius => - BuildContextMyThemeRadiusTokenMethods(this); -} - -class _$MyThemeSpaceTokenStruct { - _$MyThemeSpaceTokenStruct(); - - final SpaceToken medium = const SpaceToken('medium'); - final SpaceToken large = const SpaceToken('large'); -} - -final _structMyThemeSpaceToken = _$MyThemeSpaceTokenStruct(); - -Map _$MyThemeSpaceTokenToMap(MyThemeSpaceToken tokens) { - return { - _structMyThemeSpaceToken.medium: tokens.medium, - _structMyThemeSpaceToken.large: tokens.large, - }; -} - -extension $MyThemeSpaceTokenSpacingSideUtilityX - on SpacingSideUtility { - medium() => ref(_structMyThemeSpaceToken.medium); - large() => ref(_structMyThemeSpaceToken.large); -} - -extension $MyThemeSpaceTokenGapUtilityX on GapUtility { - medium() => ref(_structMyThemeSpaceToken.medium); - large() => ref(_structMyThemeSpaceToken.large); -} - -class BuildContextMyThemeSpaceTokenMethods { - const BuildContextMyThemeSpaceTokenMethods(this.context); - - final BuildContext context; - medium() => _structMyThemeSpaceToken.medium.resolve(context); - large() => _structMyThemeSpaceToken.large.resolve(context); -} - -extension $BuildContextMyThemeSpaceTokenX on BuildContext { - BuildContextMyThemeSpaceTokenMethods get $space => - BuildContextMyThemeSpaceTokenMethods(this); -}