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 3 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
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