Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

feat: add medium sized text field (#7737)

Richard Shiueb12bd8ee8562
diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_email_and_password.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_email_and_password.dart
index 349dd7e0d4..5027874418 100644
--- a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_email_and_password.dart
+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_email_and_password.dart
@@ -60,7 +60,6 @@ class _ContinueWithEmailAndPasswordState
key: emailKey,
controller: controller,
hintText: LocaleKeys.signIn_pleaseInputYourEmail.tr(),
- radius: 10,
onSubmitted: (value) => _signInWithEmail(
context,
value,
diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_magic_link_or_passcode_page.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_magic_link_or_passcode_page.dart
index 8cfc4c1157..ec4fd1bbee 100644
--- a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_magic_link_or_passcode_page.dart
+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_magic_link_or_passcode_page.dart
@@ -101,7 +101,6 @@ class _ContinueWithMagicLinkOrPasscodePageState
controller: passcodeController,
hintText: LocaleKeys.signIn_enterCode.tr(),
keyboardType: TextInputType.number,
- radius: 10,
autoFocus: true,
onSubmitted: (passcode) {
if (passcode.isEmpty) {
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/main.dart b/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/main.dart
index 067e42858b..41548abd08 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/main.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/main.dart
@@ -24,6 +24,8 @@ class MyApp extends StatelessWidget {
return ValueListenableBuilder(
valueListenable: themeMode,
builder: (context, themeMode, child) {
+ final themeData =
+ themeMode == ThemeMode.light ? ThemeData.light() : ThemeData.dark();
return AppFlowyTheme(
data: themeMode == ThemeMode.light
? AppFlowyThemeData.light()
@@ -31,9 +33,7 @@ class MyApp extends StatelessWidget {
child: MaterialApp(
debugShowCheckedModeBanner: false,
title: 'AppFlowy UI Example',
- theme: themeMode == ThemeMode.light
- ? ThemeData.light()
- : ThemeData.dark(),
+ theme: themeData.copyWith(visualDensity: VisualDensity.standard),
home: const MyHomePage(
title: 'AppFlowy UI',
),
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/src/textfield/textfield_page.dart b/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/src/textfield/textfield_page.dart
index 280e43818c..9e3436ecd4 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/src/textfield/textfield_page.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/example/lib/src/textfield/textfield_page.dart
@@ -11,6 +11,19 @@ class TextFieldPage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
+ _buildSection(
+ 'TextField Sizes',
+ [
+ AFTextField(
+ hintText: 'Please enter your name',
+ size: AFTextFieldSize.m,
+ ),
+ AFTextField(
+ hintText: 'Please enter your name',
+ ),
+ ],
+ ),
+ const SizedBox(height: 32),
_buildSection(
'TextField with hint text',
[
diff --git a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/textfield/textfield.dart b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/textfield/textfield.dart
index a934734983..3f5ad4cfed 100644
--- a/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/textfield/textfield.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/textfield/textfield.dart
@@ -1,4 +1,4 @@
-import 'package:appflowy_ui/src/theme/appflowy_theme.dart';
+import 'package:appflowy_ui/src/theme/theme.dart';
import 'package:flutter/material.dart';
typedef AFTextFieldValidator = (bool result, String errorText) Function(
@@ -20,21 +20,17 @@ class AFTextField extends StatefulWidget {
this.hintText,
this.initialText,
this.keyboardType,
- this.radius,
+ this.size = AFTextFieldSize.l,
this.validator,
this.controller,
this.onChanged,
this.onSubmitted,
this.autoFocus,
- this.height = 40.0,
this.obscureText = false,
this.suffixIconBuilder,
this.suffixIconConstraints,
});
- /// The height of the text field.
- final double height;
-
/// The hint text to display when the text field is empty.
final String? hintText;
@@ -44,8 +40,8 @@ class AFTextField extends StatefulWidget {
/// The type of keyboard to display.
final TextInputType? keyboardType;
- /// The radius of the text field.
- final double? radius;
+ /// The size variant of the text field.
+ final AFTextFieldSize size;
/// The validator to use for the text field.
final AFTextFieldValidator? validator;
@@ -115,9 +111,8 @@ class _AFTextFieldState extends AFTextFieldState {
@override
Widget build(BuildContext context) {
final theme = AppFlowyTheme.of(context);
- final borderRadius = BorderRadius.circular(
- widget.radius ?? theme.borderRadius.l,
- );
+ final borderRadius = widget.size.borderRadius(theme);
+ final contentPadding = widget.size.contentPadding(theme);
final errorBorderColor = theme.borderColorScheme.errorThick;
final defaultBorderColor = theme.borderColorScheme.greyTertiary;
@@ -137,10 +132,9 @@ class _AFTextFieldState extends AFTextFieldState {
hintStyle: theme.textStyle.body.standard(
color: theme.textColorScheme.tertiary,
),
- contentPadding: EdgeInsets.symmetric(
- horizontal: theme.spacing.m,
- vertical: 10,
- ),
+ isDense: true,
+ constraints: BoxConstraints(),
+ contentPadding: contentPadding,
border: OutlineInputBorder(
borderSide: BorderSide(
color: hasError ? errorBorderColor : defaultBorderColor,
@@ -179,8 +173,6 @@ class _AFTextFieldState extends AFTextFieldState {
),
);
- child = SizedBox(height: widget.height, child: child);
-
if (hasError && errorText.isNotEmpty) {
child = Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -236,3 +228,27 @@ class _AFTextFieldState extends AFTextFieldState {
});
}
}
+
+enum AFTextFieldSize {
+ m,
+ l;
+
+ EdgeInsetsGeometry contentPadding(AppFlowyThemeData theme) {
+ return EdgeInsets.symmetric(
+ vertical: switch (this) {
+ AFTextFieldSize.m => theme.spacing.s,
+ AFTextFieldSize.l => 10.0,
+ },
+ horizontal: theme.spacing.m,
+ );
+ }
+
+ BorderRadius borderRadius(AppFlowyThemeData theme) {
+ return BorderRadius.circular(
+ switch (this) {
+ AFTextFieldSize.m => theme.borderRadius.m,
+ AFTextFieldSize.l => 10.0,
+ },
+ );
+ }
+}