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

[Flutter][3.22.0] fix accentColor & textTheme #276

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions example/lib/accessibility/neumorphic_accessibility.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:example/lib/color_selector.dart';
import 'package:flutter/material.dart';
import 'package:flutter_neumorphic/flutter_neumorphic.dart';

class NeumorphicAccessibility extends StatefulWidget {
Expand Down Expand Up @@ -71,7 +70,7 @@ class __PageState extends State<_Page> {
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
color: Theme.of(context).accentColor,
color: Theme.of(context).colorScheme.secondary,
child: Text(
"back",
style: TextStyle(color: Colors.white),
Expand Down Expand Up @@ -104,7 +103,7 @@ class __PageState extends State<_Page> {
int selectedConfiguratorIndex = 0;

Widget _configurators() {
final Color buttonActiveColor = Theme.of(context).accentColor;
final Color buttonActiveColor = Theme.of(context).colorScheme.secondary;
final Color buttonInnactiveColor = Colors.white;

final Color textActiveColor = Colors.white;
Expand Down Expand Up @@ -513,7 +512,7 @@ class __PageState extends State<_Page> {
}

Widget shapeWidget() {
final Color buttonActiveColor = Theme.of(context).accentColor;
final Color buttonActiveColor = Theme.of(context).colorScheme.secondary;
final Color buttonInnactiveColor = Colors.white;

final Color iconActiveColor = Colors.white;
Expand Down
8 changes: 4 additions & 4 deletions example/lib/playground/neumorphic_playground.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class __PageState extends State<_Page> {
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
color: Theme.of(context).accentColor,
color: Theme.of(context).colorScheme.secondary,
child: Text(
"back",
style: TextStyle(color: Colors.white),
Expand Down Expand Up @@ -102,7 +102,7 @@ class __PageState extends State<_Page> {
int selectedConfiguratorIndex = 0;

Widget _configurators() {
final Color buttonActiveColor = Theme.of(context).accentColor;
final Color buttonActiveColor = Theme.of(context).colorScheme.secondary;
final Color buttonInnactiveColor = Colors.white;

final Color textActiveColor = Colors.white;
Expand Down Expand Up @@ -622,7 +622,7 @@ class __PageState extends State<_Page> {
}

Widget boxshapeWidget() {
final Color buttonActiveColor = Theme.of(context).accentColor;
final Color buttonActiveColor = Theme.of(context).colorScheme.secondary;
final Color buttonInnactiveColor = Colors.white;

final Color textActiveColor = Colors.white;
Expand Down Expand Up @@ -756,7 +756,7 @@ class __PageState extends State<_Page> {
}

Widget shapeWidget() {
final Color buttonActiveColor = Theme.of(context).accentColor;
final Color buttonActiveColor = Theme.of(context).colorScheme.secondary;
final Color buttonInnactiveColor = Colors.white;

final Color iconActiveColor = Colors.white;
Expand Down
9 changes: 4 additions & 5 deletions example/lib/playground/text_playground.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:example/lib/color_selector.dart';
import 'package:flutter/material.dart';
import 'package:flutter_neumorphic/flutter_neumorphic.dart';

class NeumorphicTextPlayground extends StatefulWidget {
Expand Down Expand Up @@ -92,7 +91,7 @@ class __PageState extends State<_Page> {
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
color: Theme.of(context).accentColor,
color: Theme.of(context).colorScheme.secondary,
child: Text(
"back",
style: TextStyle(color: Colors.white),
Expand Down Expand Up @@ -125,7 +124,7 @@ class __PageState extends State<_Page> {
int selectedConfiguratorIndex = 0;

Widget _configurators() {
final Color buttonActiveColor = Theme.of(context).accentColor;
final Color buttonActiveColor = Theme.of(context).colorScheme.secondary;
final Color buttonInnactiveColor = Colors.white;

final Color textActiveColor = Colors.white;
Expand Down Expand Up @@ -238,7 +237,7 @@ class __PageState extends State<_Page> {
}

Widget shapeWidget() {
final Color buttonActiveColor = Theme.of(context).accentColor;
final Color buttonActiveColor = Theme.of(context).colorScheme.secondary;
final Color buttonInnactiveColor = Colors.white;

final Color iconActiveColor = Colors.white;
Expand Down Expand Up @@ -444,7 +443,7 @@ class __PageState extends State<_Page> {
}

FontWeight _fontWeight() {
switch ((this.fontWeight / 100).toInt()) {
switch (this.fontWeight ~/ 100) {
case 1:
return FontWeight.w100;
case 2:
Expand Down
6 changes: 2 additions & 4 deletions example/lib/sample_neumorphic_playground.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:example/lib/color_selector.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_neumorphic/flutter_neumorphic.dart';

void main() => runApp(NeumorphicPlayground());
Expand Down Expand Up @@ -85,7 +83,7 @@ class __PageState extends State<_Page> {
}

Widget _configurators() {
final Color buttonActiveColor = Theme.of(context).accentColor;
final Color buttonActiveColor = Theme.of(context).colorScheme.secondary;
final Color buttonInnactiveColor = Colors.white;

final Color textActiveColor = Colors.white;
Expand Down Expand Up @@ -246,7 +244,7 @@ class __PageState extends State<_Page> {
}

Widget shapeWidget() {
final Color buttonActiveColor = Theme.of(context).accentColor;
final Color buttonActiveColor = Theme.of(context).colorScheme.secondary;
final Color buttonInnactiveColor = Colors.white;

final Color iconActiveColor = Colors.white;
Expand Down
2 changes: 0 additions & 2 deletions example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Generated file. Do not edit.
//

// clang-format off

import FlutterMacOS
import Foundation

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description: A new Flutter project.
version: 1.0.0+1

environment:
sdk: ">=2.6.0 <3.0.0"
sdk: '>=3.2.6 <4.0.0'

dependencies:
flutter:
Expand Down
6 changes: 0 additions & 6 deletions lib/src/widget/app.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:flutter_neumorphic/flutter_neumorphic.dart';

class NeumorphicApp extends StatelessWidget {
Expand Down Expand Up @@ -86,13 +85,8 @@ class NeumorphicApp extends StatelessWidget {

return ThemeData(
primaryColor: theme.accentColor,
accentColor: theme.variantColor,
iconTheme: theme.iconTheme,
brightness: ThemeData.estimateBrightnessForColor(theme.baseColor),
primaryColorBrightness:
ThemeData.estimateBrightnessForColor(theme.accentColor),
accentColorBrightness:
ThemeData.estimateBrightnessForColor(theme.variantColor),
textTheme: theme.textTheme,
scaffoldBackgroundColor: theme.baseColor,
);
Expand Down
15 changes: 6 additions & 9 deletions lib/src/widget/app_bar.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_neumorphic/flutter_neumorphic.dart';
import 'package:flutter_neumorphic/src/widget/back_button.dart';

class NeumorphicAppBar extends StatefulWidget implements PreferredSizeWidget {
static const toolbarHeight = kToolbarHeight + 16 * 2;
Expand Down Expand Up @@ -102,9 +99,9 @@ class NeumorphicAppBar extends StatefulWidget implements PreferredSizeWidget {
@override
NeumorphicAppBarState createState() => NeumorphicAppBarState();

bool _getEffectiveCenterTitle(ThemeData theme, NeumorphicThemeData nTheme) {
if (centerTitle != null || nTheme.appBarTheme.centerTitle != null)
return centerTitle ?? nTheme.appBarTheme.centerTitle!;
bool _getEffectiveCenterTitle(ThemeData theme, NeumorphicThemeData? nTheme) {
if (centerTitle != null || nTheme?.appBarTheme.centerTitle != null)
return centerTitle ?? nTheme?.appBarTheme.centerTitle ?? false;
switch (theme.platform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
Expand Down Expand Up @@ -180,8 +177,8 @@ class NeumorphicAppBarState extends State<NeumorphicAppBar> {
if (title != null) {
final AppBarTheme appBarTheme = AppBarTheme.of(context);
title = DefaultTextStyle(
style: (appBarTheme.textTheme?.headline5 ??
Theme.of(context).textTheme.headline5!)
style: (appBarTheme.titleTextStyle ??
Theme.of(context).textTheme.titleMedium!)
.merge(widget.textStyle ?? nTheme?.current?.appBarTheme.textStyle),
softWrap: false,
overflow: TextOverflow.ellipsis,
Expand Down Expand Up @@ -235,7 +232,7 @@ class NeumorphicAppBarState extends State<NeumorphicAppBar> {
middle: title,
trailing: actions,
centerMiddle:
widget._getEffectiveCenterTitle(theme, nTheme!.current!),
widget._getEffectiveCenterTitle(theme, nTheme?.current),
middleSpacing: widget.titleSpacing,
),
),
Expand Down
6 changes: 3 additions & 3 deletions lib/src/widget/container.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:flutter/material.dart' as material;
import 'package:flutter/widgets.dart';

import '../neumorphic_box_shape.dart';
import '../decoration/neumorphic_decorations.dart';
import '../neumorphic_box_shape.dart';
import '../theme/neumorphic_theme.dart';
import 'clipper/neumorphic_box_shape_clipper.dart';

export '../neumorphic_box_shape.dart';
export '../decoration/neumorphic_decorations.dart';
export '../neumorphic_box_shape.dart';
export '../theme/neumorphic_theme.dart';

/// The main container of the Neumorphic UI KIT
Expand Down Expand Up @@ -118,7 +118,7 @@ class _NeumorphicContainer extends StatelessWidget {
final shape = this.style.boxShape ?? NeumorphicBoxShape.rect();

return DefaultTextStyle(
style: this.textStyle ?? material.Theme.of(context).textTheme.bodyText2!,
style: this.textStyle ?? material.Theme.of(context).textTheme.bodyMedium!,
child: AnimatedContainer(
margin: this.margin,
duration: this.duration,
Expand Down
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ homepage: https://github.com/Idean/Flutter-Neumorphic
issue_tracker: https://github.com/Idean/Flutter-Neumorphic/issues

environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.13.18"
sdk: '>=3.2.6 <4.0.0'
flutter: '>=1.13.18'

dependencies:
flutter:
Expand All @@ -23,6 +23,6 @@ dev_dependencies:

flutter:
fonts:
- family: NeumorphicIcons
fonts:
- asset: fonts/NeumorphicIcons.ttf
- family: NeumorphicIcons
fonts:
- asset: fonts/NeumorphicIcons.ttf