fix: fix colors for buttons and allow more customization (#1465)

This commit is contained in:
Richard Shiue 2022-11-21 08:23:37 +08:00 committed by GitHub
parent dcf6628aa3
commit 67a253c9c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 45 deletions

View File

@ -14,7 +14,6 @@ import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:clipboard/clipboard.dart'; import 'package:clipboard/clipboard.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/widget/rounded_button.dart'; import 'package:flowy_infra_ui/widget/rounded_button.dart';
import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/log.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
@ -176,9 +175,6 @@ class ShareActionList extends StatelessWidget {
buildChild: (controller) { buildChild: (controller) {
return RoundedTextButton( return RoundedTextButton(
title: LocaleKeys.shareAction_buttonText.tr(), title: LocaleKeys.shareAction_buttonText.tr(),
fontSize: FontSizes.s12,
borderRadius: Corners.s6Border,
color: Theme.of(context).colorScheme.primary,
onPressed: () => controller.show(), onPressed: () => controller.show(),
); );
}, },

View File

@ -115,7 +115,6 @@ class SignUpButton extends StatelessWidget {
return RoundedTextButton( return RoundedTextButton(
title: LocaleKeys.signUp_getStartedText.tr(), title: LocaleKeys.signUp_getStartedText.tr(),
height: 48, height: 48,
color: Theme.of(context).colorScheme.primary,
onPressed: () { onPressed: () {
context context
.read<SignUpBloc>() .read<SignUpBloc>()

View File

@ -141,9 +141,9 @@ class GoButton extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return RoundedTextButton( return RoundedTextButton(
title: LocaleKeys.letsGoButtonText.tr(), title: LocaleKeys.letsGoButtonText.tr(),
fontSize: FontSizes.s16,
height: 50, height: 50,
borderRadius: Corners.s10Border, borderRadius: Corners.s10Border,
color: Theme.of(context).colorScheme.primary,
onPressed: onPressed, onPressed: onPressed,
); );
} }

View File

@ -7,7 +7,6 @@ import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flowy_infra_ui/style_widget/extension.dart'; import 'package:flowy_infra_ui/style_widget/extension.dart';
import 'package:app_flowy/generated/locale_keys.g.dart'; import 'package:app_flowy/generated/locale_keys.g.dart';
// ignore: implementation_imports
class NewAppButton extends StatelessWidget { class NewAppButton extends StatelessWidget {
final Function(String)? press; final Function(String)? press;
@ -17,9 +16,9 @@ class NewAppButton extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final child = FlowyTextButton( final child = FlowyTextButton(
LocaleKeys.newPageText.tr(), LocaleKeys.newPageText.tr(),
fillColor: Colors.transparent,
hoverColor: Colors.transparent, hoverColor: Colors.transparent,
fontSize: FontSizes.s12, fontColor: Theme.of(context).colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w500,
onPressed: () async => await _showCreateAppDialog(context), onPressed: () async => await _showCreateAppDialog(context),
heading: svgWithSize("home/new_app", const Size(16, 16)), heading: svgWithSize("home/new_app", const Size(16, 16)),
padding: EdgeInsets.symmetric(horizontal: Insets.l, vertical: 20), padding: EdgeInsets.symmetric(horizontal: Insets.l, vertical: 20),

View File

@ -3,6 +3,7 @@ import 'package:app_flowy/workspace/presentation/home/toast.dart';
import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart'; import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart';
import 'package:appflowy_popover/appflowy_popover.dart'; import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/style_widget/button.dart'; import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_infra_ui/widget/spacing.dart';
@ -45,11 +46,9 @@ class BubbleActionList extends StatelessWidget {
return FlowyTextButton( return FlowyTextButton(
'?', '?',
tooltip: LocaleKeys.questionBubble_help.tr(), tooltip: LocaleKeys.questionBubble_help.tr(),
fontSize: 12,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fillColor: Theme.of(context).colorScheme.secondaryContainer,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
radius: BorderRadius.circular(10), radius: Corners.s10Border,
onPressed: () => controller.show(), onPressed: () => controller.show(),
); );
}, },

View File

@ -1,4 +1,5 @@
import 'package:flowy_infra/color_extension.dart'; import 'package:flowy_infra/color_extension.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/style_widget/hover.dart'; import 'package:flowy_infra_ui/style_widget/hover.dart';
import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_infra_ui/widget/spacing.dart';
@ -75,9 +76,10 @@ class FlowyButton extends StatelessWidget {
class FlowyTextButton extends StatelessWidget { class FlowyTextButton extends StatelessWidget {
final String text; final String text;
final double fontSize; final FontWeight? fontWeight;
final Color? fontColor;
final double? fontSize;
final TextOverflow overflow; final TextOverflow overflow;
final FontWeight fontWeight;
final VoidCallback? onPressed; final VoidCallback? onPressed;
final EdgeInsets padding; final EdgeInsets padding;
@ -93,9 +95,10 @@ class FlowyTextButton extends StatelessWidget {
this.text, { this.text, {
Key? key, Key? key,
this.onPressed, this.onPressed,
this.fontSize = 16, this.fontSize,
this.fontColor,
this.overflow = TextOverflow.ellipsis, this.overflow = TextOverflow.ellipsis,
this.fontWeight = FontWeight.w400, this.fontWeight,
this.padding = const EdgeInsets.symmetric(horizontal: 8, vertical: 6), this.padding = const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
this.hoverColor, this.hoverColor,
this.fillColor, this.fillColor,
@ -118,6 +121,7 @@ class FlowyTextButton extends StatelessWidget {
overflow: overflow, overflow: overflow,
fontWeight: fontWeight, fontWeight: fontWeight,
fontSize: fontSize, fontSize: fontSize,
color: fontColor ?? Theme.of(context).colorScheme.onSecondary,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
); );
@ -135,9 +139,8 @@ class FlowyTextButton extends StatelessWidget {
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
hoverElevation: 0, hoverElevation: 0,
highlightElevation: 0, highlightElevation: 0,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(borderRadius: radius ?? Corners.s6Border),
borderRadius: radius ?? BorderRadius.circular(2)), fillColor: fillColor ?? Theme.of(context).colorScheme.secondaryContainer,
fillColor: fillColor,
hoverColor: hoverColor ?? Theme.of(context).colorScheme.secondary, hoverColor: hoverColor ?? Theme.of(context).colorScheme.secondary,
focusColor: Colors.transparent, focusColor: Colors.transparent,
splashColor: Colors.transparent, splashColor: Colors.transparent,

View File

@ -1,6 +1,7 @@
import 'dart:math'; import 'dart:math';
import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/image.dart';
import 'package:flowy_infra/size.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class FlowyIconButton extends StatelessWidget { class FlowyIconButton extends StatelessWidget {
@ -49,8 +50,8 @@ class FlowyIconButton extends StatelessWidget {
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
hoverElevation: 0, hoverElevation: 0,
highlightElevation: 0, highlightElevation: 0,
shape: RoundedRectangleBorder( shape:
borderRadius: radius ?? BorderRadius.circular(2)), RoundedRectangleBorder(borderRadius: radius ?? Corners.s6Border),
fillColor: fillColor, fillColor: fillColor,
hoverColor: hoverColor ?? Theme.of(context).colorScheme.secondary, hoverColor: hoverColor ?? Theme.of(context).colorScheme.secondary,
focusColor: Colors.transparent, focusColor: Colors.transparent,

View File

@ -1,5 +1,5 @@
import 'package:flowy_infra/size.dart'; import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class RoundedTextButton extends StatelessWidget { class RoundedTextButton extends StatelessWidget {
@ -7,11 +7,12 @@ class RoundedTextButton extends StatelessWidget {
final String? title; final String? title;
final double? width; final double? width;
final double? height; final double? height;
final BorderRadius borderRadius; final BorderRadius? borderRadius;
final Color borderColor; final Color borderColor;
final Color? color; final Color? fillColor;
final Color textColor; final Color? hoverColor;
final double fontSize; final Color? textColor;
final double? fontSize;
const RoundedTextButton({ const RoundedTextButton({
Key? key, Key? key,
@ -19,11 +20,12 @@ class RoundedTextButton extends StatelessWidget {
this.title, this.title,
this.width, this.width,
this.height, this.height,
this.borderRadius = Corners.s12Border, this.borderRadius,
this.borderColor = Colors.transparent, this.borderColor = Colors.transparent,
this.color, this.fillColor,
this.textColor = Colors.white, this.hoverColor,
this.fontSize = 16, this.textColor,
this.fontSize,
}) : super(key: key); }) : super(key: key);
@override @override
@ -35,21 +37,17 @@ class RoundedTextButton extends StatelessWidget {
minHeight: 10, minHeight: 10,
maxHeight: height ?? 60, maxHeight: height ?? 60,
), ),
child: Container(
decoration: BoxDecoration(
border: Border.all(color: borderColor),
borderRadius: borderRadius,
color: color ?? Theme.of(context).colorScheme.primary,
),
child: SizedBox.expand( child: SizedBox.expand(
child: TextButton( child: FlowyTextButton(
onPressed: onPressed,
child: FlowyText.medium(
title ?? '', title ?? '',
onPressed: onPressed,
fontSize: fontSize, fontSize: fontSize,
color: textColor, mainAxisAlignment: MainAxisAlignment.center,
), radius: borderRadius ?? Corners.s6Border,
), fontColor: textColor ?? Theme.of(context).colorScheme.onPrimary,
fillColor: fillColor ?? Theme.of(context).colorScheme.primary,
hoverColor:
hoverColor ?? Theme.of(context).colorScheme.primaryContainer,
), ),
), ),
); );