Skip to content
Open
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
123 changes: 123 additions & 0 deletions lib/custom button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import 'package:flutter/material.dart';

void main() {
runApp(const MyApp());
}
Comment on lines +3 to +5
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preview화면을 요청한 것이 아닌, 컴포넌트만 정의된 파일을 의미했습니다. 작동 확인할 수 있는 화면은 제거해 주시고 본 파일에는 컴포넌트 관련 코드만 남겨주세요.


const Color lightPrimaryColor = Color(0xFF6C98FF);
const Color lightSecondaryColor = Color(0xFF87A9F7);

const Color darkPrimaryColor = Color(0xFF497BEE);
const Color darkSecondaryColor = Color(0xFF6C98FF);

const Color disabledColor = Color(0xFF808080);
Comment on lines +7 to +13
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이미 app/view/core/design에 색상들이 정의된 파일을 생성해 두었습니다. 그 파일을 이용해 주시고, app/view/register/step_4.dart 파일과 app/view/core/components/custom_text_field.dart에서 사용한 방식을 참고해 주세요.


class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Button Variants Demo',
themeMode: ThemeMode.system,
theme: ThemeData(
useMaterial3: true,
brightness: Brightness.light,
colorScheme: ColorScheme.light(
primary: lightPrimaryColor,
secondary: lightSecondaryColor,
),
),
darkTheme: ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
colorScheme: ColorScheme.dark(
primary: darkPrimaryColor,
secondary: darkSecondaryColor,
),
),
Comment on lines +23 to +38
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme, darkTheme 모두 app/view/core/design/fliggle_theme_data.dart에 관련 스타일이 정의되어 있습니다. 만약 추가적인 스타일이 필요하다면 app/view/core/design 폴더 내에 있는 요소를 변경하거나, 추가해 주세요.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

또한, 위에서 언급드린 것처럼 app은 건들지 말아주세요. app.dart에 수정 사항이 필요하다면 app/app.dart의 내용을 수정해 주세요.

home: const ButtonDemoPage(),
);
}
}

class ButtonDemoPage extends StatelessWidget {
const ButtonDemoPage({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Button Variants")),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: const [
CustomButton(variant: 'surface', disabled: false),
SizedBox(height: 10),
CustomButton(variant: 'surface', disabled: true),
SizedBox(height: 10),
CustomButton(variant: 'outline', disabled: false),
SizedBox(height: 10),
CustomButton(variant: 'outline', disabled: true),
],
),
),
);
}
}
Comment on lines +44 to +67
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

데모는 지워주세요


class CustomButton extends StatelessWidget {
final String variant;
final bool disabled;

const CustomButton({
super.key,
required this.variant,
required this.disabled,
});

@override
Widget build(BuildContext context) {
final bool isOutline = variant == 'outline';
final colorScheme = Theme.of(context).colorScheme;
final Color primary = colorScheme.primary;
Comment on lines +82 to +83
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것 또한 별도로 구현해 놓은 FliggleThemeDataFliggleColors를 이용해 주세요.


return SizedBox(
width: 120,
height: 34,
Comment on lines +86 to +87
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text에 따라 위젯의 크기가 동적으로 변할 수 있습니다. SizedBox를 제거해주세요

child: ElevatedButton(
onPressed: disabled ? null : () {},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onTap을 property로 넘길 수 있게 해주세요

style: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith<Color>((states) {
if (states.contains(WidgetState.disabled)) {
return isOutline ? Colors.white : disabledColor;
}
return isOutline ? Colors.white : primary;
}),
Comment on lines +89 to +96
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위젯의 disabled 값과 WidgetState.disabled가 혼용되는 것 같아요 코드 전체에서

foregroundColor: WidgetStateProperty.resolveWith<Color>((states) {
if (states.contains(WidgetState.disabled)) {
return isOutline ? disabledColor : Colors.white;
}
return isOutline ? primary : Colors.white;
}),
side: WidgetStateProperty.resolveWith<BorderSide>((states) {
if (!isOutline) return BorderSide.none;
return BorderSide(
color: states.contains(WidgetState.disabled)
? disabledColor
: primary,
);
}),
padding: WidgetStateProperty.all(
const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

피그마와 동일하게

),
elevation: WidgetStateProperty.all(0),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),

피그마와 동일하게 맞춰주세요

),
),
child: const Text('Button', style: TextStyle(fontSize: 12)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text를 property로 넘길 수 있게 해주세요

),
);
Comment on lines +85 to +121
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

실행 화면 스크린샷 올려주세요

}
}