feat(proj): init
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:please_pay_me/theme/theme.dart';
|
||||
import 'package:please_pay_me/ui/ui.dart';
|
||||
import 'package:please_pay_me_widgetbook/knobs/common_knobs.dart';
|
||||
import 'package:please_pay_me_widgetbook/support/preview.dart';
|
||||
import 'package:widgetbook/widgetbook.dart';
|
||||
|
||||
WidgetbookComponent buttonsComponent() {
|
||||
return WidgetbookComponent(
|
||||
name: 'AppButton',
|
||||
useCases: [
|
||||
WidgetbookUseCase(
|
||||
name: 'Playground',
|
||||
builder: (context) {
|
||||
return IosPreview(
|
||||
stretch: true,
|
||||
child: AppButton(
|
||||
label: knobText(context, label: 'Label', initialValue: 'Сохранить'),
|
||||
style: knobEnum(
|
||||
context,
|
||||
label: 'Style',
|
||||
values: AppButtonStyle.values,
|
||||
initial: AppButtonStyle.filled,
|
||||
),
|
||||
size: knobEnum(
|
||||
context,
|
||||
label: 'Size',
|
||||
values: AppButtonSize.values,
|
||||
initial: AppButtonSize.large,
|
||||
),
|
||||
expanded: knobBool(context, label: 'Expanded', initialValue: true),
|
||||
loading: knobBool(context, label: 'Loading'),
|
||||
icon: knobBool(context, label: 'Icon') ? CupertinoIcons.plus : null,
|
||||
onPressed:
|
||||
knobBool(context, label: 'Enabled', initialValue: true) ? () {} : null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
WidgetbookUseCase(
|
||||
name: 'All styles',
|
||||
builder: (context) {
|
||||
return IosPreview(
|
||||
stretch: true,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
for (final style in AppButtonStyle.values) ...[
|
||||
AppButton(label: style.name, style: style, onPressed: () {}),
|
||||
const SizedBox(height: AppSpacing.s3),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
WidgetbookUseCase(
|
||||
name: 'Sizes',
|
||||
builder: (context) {
|
||||
return IosPreview.centered(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final size in AppButtonSize.values) ...[
|
||||
AppButton(
|
||||
label: 'Размер ${size.name}',
|
||||
size: size,
|
||||
expanded: false,
|
||||
onPressed: () {},
|
||||
),
|
||||
const SizedBox(height: AppSpacing.s3),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:please_pay_me/theme/theme.dart';
|
||||
import 'package:please_pay_me/ui/ui.dart';
|
||||
import 'package:please_pay_me_widgetbook/knobs/common_knobs.dart';
|
||||
import 'package:please_pay_me_widgetbook/support/preview.dart';
|
||||
import 'package:widgetbook/widgetbook.dart';
|
||||
|
||||
const _icons = <IconData>[
|
||||
CupertinoIcons.house_fill,
|
||||
CupertinoIcons.cart_fill,
|
||||
CupertinoIcons.bag_fill,
|
||||
CupertinoIcons.money_rubl_circle_fill,
|
||||
CupertinoIcons.chart_pie_fill,
|
||||
CupertinoIcons.calendar,
|
||||
CupertinoIcons.bell_fill,
|
||||
CupertinoIcons.gear_alt_fill,
|
||||
CupertinoIcons.person_fill,
|
||||
CupertinoIcons.creditcard_fill,
|
||||
];
|
||||
|
||||
WidgetbookComponent iconsComponent() {
|
||||
return WidgetbookComponent(
|
||||
name: 'Icons',
|
||||
useCases: [
|
||||
WidgetbookUseCase(
|
||||
name: 'Glyphs',
|
||||
builder: (context) {
|
||||
final size = knobDouble(context, label: 'Size', initialValue: 24, min: 12, max: 48);
|
||||
final tint = knobTint(context);
|
||||
return IosPreview(
|
||||
child: Wrap(
|
||||
spacing: AppSpacing.s5,
|
||||
runSpacing: AppSpacing.s5,
|
||||
alignment: WrapAlignment.center,
|
||||
children: [
|
||||
for (final icon in _icons) AppIcon(icon, size: size, color: tint),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
WidgetbookUseCase(
|
||||
name: 'Badges',
|
||||
builder: (context) {
|
||||
return IosPreview(
|
||||
child: Wrap(
|
||||
spacing: AppSpacing.s4,
|
||||
runSpacing: AppSpacing.s4,
|
||||
alignment: WrapAlignment.center,
|
||||
children: [
|
||||
for (final (index, icon) in _icons.indexed)
|
||||
AppIconBadge(
|
||||
icon: icon,
|
||||
color: switch (index % 4) {
|
||||
0 => AppColors.accent,
|
||||
1 => AppColors.systemRed,
|
||||
2 => AppColors.systemOrange,
|
||||
_ => AppColors.systemGray,
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:please_pay_me/theme/theme.dart';
|
||||
import 'package:please_pay_me/ui/ui.dart';
|
||||
import 'package:please_pay_me_widgetbook/knobs/common_knobs.dart';
|
||||
import 'package:please_pay_me_widgetbook/support/preview.dart';
|
||||
import 'package:widgetbook/widgetbook.dart';
|
||||
|
||||
WidgetbookComponent textFieldsComponent() {
|
||||
return WidgetbookComponent(
|
||||
name: 'AppTextField',
|
||||
useCases: [
|
||||
WidgetbookUseCase(
|
||||
name: 'Playground',
|
||||
builder: (context) {
|
||||
final error = knobText(context, label: 'Error', initialValue: '');
|
||||
return IosPreview(
|
||||
stretch: true,
|
||||
padding: const EdgeInsets.all(AppSpacing.s4),
|
||||
child: AppTextField(
|
||||
label: knobText(context, label: 'Label', initialValue: 'Сумма'),
|
||||
placeholder: knobText(context, label: 'Placeholder', initialValue: '0 ₽'),
|
||||
enabled: knobBool(context, label: 'Enabled', initialValue: true),
|
||||
obscureText: knobBool(context, label: 'Obscure'),
|
||||
clearable: knobBool(context, label: 'Clear button', initialValue: true),
|
||||
prefixIcon: knobBool(context, label: 'Prefix icon')
|
||||
? CupertinoIcons.search
|
||||
: null,
|
||||
errorText: error.isEmpty ? null : error,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
WidgetbookUseCase(
|
||||
name: 'Form group',
|
||||
builder: (context) {
|
||||
return const IosPreview(
|
||||
stretch: true,
|
||||
padding: EdgeInsets.all(AppSpacing.s4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
AppTextField(label: 'Название', placeholder: 'Продукты'),
|
||||
SizedBox(height: AppSpacing.s4),
|
||||
AppTextField(
|
||||
label: 'Сумма',
|
||||
placeholder: '0 ₽',
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
SizedBox(height: AppSpacing.s4),
|
||||
AppTextField(
|
||||
label: 'Комментарий',
|
||||
placeholder: 'Необязательно',
|
||||
errorText: 'Слишком длинный комментарий',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:please_pay_me/theme/theme.dart';
|
||||
import 'package:please_pay_me/ui/ui.dart';
|
||||
import 'package:please_pay_me_widgetbook/knobs/common_knobs.dart';
|
||||
import 'package:please_pay_me_widgetbook/support/preview.dart';
|
||||
import 'package:widgetbook/widgetbook.dart';
|
||||
|
||||
WidgetbookComponent typographyComponent() {
|
||||
return WidgetbookComponent(
|
||||
name: 'Typography',
|
||||
useCases: [
|
||||
WidgetbookUseCase(
|
||||
name: 'iOS scale',
|
||||
builder: (context) {
|
||||
final sample = knobText(context, label: 'Sample', initialValue: 'Бюджет на неделю');
|
||||
return IosPreview(
|
||||
stretch: true,
|
||||
padding: const EdgeInsets.all(AppSpacing.s4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppText.largeTitle(sample),
|
||||
const SizedBox(height: AppSpacing.s3),
|
||||
AppText.title(sample),
|
||||
const SizedBox(height: AppSpacing.s3),
|
||||
AppText.headline(sample),
|
||||
const SizedBox(height: AppSpacing.s3),
|
||||
AppText.body(sample),
|
||||
const SizedBox(height: AppSpacing.s3),
|
||||
AppText.callout(sample),
|
||||
const SizedBox(height: AppSpacing.s3),
|
||||
AppText.subhead(sample),
|
||||
const SizedBox(height: AppSpacing.s3),
|
||||
AppText.footnote(sample),
|
||||
const SizedBox(height: AppSpacing.s3),
|
||||
AppText.caption(sample),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
WidgetbookUseCase(
|
||||
name: 'Section header',
|
||||
builder: (context) {
|
||||
return IosPreview(
|
||||
stretch: true,
|
||||
child: AppListSection(
|
||||
header: knobText(context, label: 'Header', initialValue: 'Настройки'),
|
||||
footer: knobText(
|
||||
context,
|
||||
label: 'Footer',
|
||||
initialValue: 'Пояснение под группой, как в iOS Settings.',
|
||||
),
|
||||
children: const [
|
||||
AppListTile(title: 'Строка', value: 'Значение'),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user