feat(proj): init
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:please_pay_me/theme/theme.dart';
|
||||
import 'package:widgetbook/widgetbook.dart';
|
||||
|
||||
String knobText(
|
||||
BuildContext context, {
|
||||
required String label,
|
||||
String initialValue = 'Label',
|
||||
}) {
|
||||
return context.knobs.string(label: label, initialValue: initialValue);
|
||||
}
|
||||
|
||||
bool knobBool(
|
||||
BuildContext context, {
|
||||
required String label,
|
||||
bool initialValue = false,
|
||||
}) {
|
||||
return context.knobs.boolean(label: label, initialValue: initialValue);
|
||||
}
|
||||
|
||||
double knobDouble(
|
||||
BuildContext context, {
|
||||
required String label,
|
||||
double initialValue = 0.5,
|
||||
double min = 0,
|
||||
double max = 1,
|
||||
}) {
|
||||
return context.knobs.double.slider(
|
||||
label: label,
|
||||
initialValue: initialValue,
|
||||
min: min,
|
||||
max: max,
|
||||
);
|
||||
}
|
||||
|
||||
int knobInt(
|
||||
BuildContext context, {
|
||||
required String label,
|
||||
int initialValue = 0,
|
||||
int min = 0,
|
||||
int max = 10,
|
||||
}) {
|
||||
return context.knobs.int.slider(
|
||||
label: label,
|
||||
initialValue: initialValue,
|
||||
min: min,
|
||||
max: max,
|
||||
);
|
||||
}
|
||||
|
||||
Color knobColor(
|
||||
BuildContext context, {
|
||||
required String label,
|
||||
Color? initialValue,
|
||||
}) {
|
||||
return context.knobs.color(
|
||||
label: label,
|
||||
initialValue: initialValue ?? AppColors.of(context, AppColors.accent),
|
||||
);
|
||||
}
|
||||
|
||||
/// Dropdown over iOS system tints used by badges and progress bars.
|
||||
Color knobTint(BuildContext context, {String label = 'Tint'}) {
|
||||
const options = <String, Color>{
|
||||
'accent': AppColors.accent,
|
||||
'red': AppColors.systemRed,
|
||||
'orange': AppColors.systemOrange,
|
||||
'green': AppColors.systemGreen,
|
||||
'gray': AppColors.systemGray,
|
||||
};
|
||||
|
||||
final key = context.knobs.object.dropdown(
|
||||
label: label,
|
||||
options: options.keys.toList(),
|
||||
initialOption: 'accent',
|
||||
);
|
||||
|
||||
return options[key]!;
|
||||
}
|
||||
|
||||
T knobEnum<T extends Enum>(
|
||||
BuildContext context, {
|
||||
required String label,
|
||||
required List<T> values,
|
||||
required T initial,
|
||||
}) {
|
||||
return context.knobs.object.dropdown(
|
||||
label: label,
|
||||
options: values,
|
||||
labelBuilder: (value) => value.name,
|
||||
initialOption: initial,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user