feat(proj): init
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:please_pay_me/theme/tokens.dart';
|
||||
|
||||
/// App glyph: rounded green tile with a ruble, same language as [AppIconBadge].
|
||||
class AppBrandMark extends StatelessWidget {
|
||||
const AppBrandMark({super.key, this.size = 96});
|
||||
|
||||
final double size;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final radius = size * 0.235;
|
||||
return Container(
|
||||
width: size,
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context, AppColors.accent),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.of(context, AppColors.accent).withValues(alpha: 0.28),
|
||||
blurRadius: size * 0.28,
|
||||
offset: Offset(0, size * 0.08),
|
||||
),
|
||||
],
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Icon(
|
||||
CupertinoIcons.money_rubl,
|
||||
size: size * 0.52,
|
||||
color: const Color(0xFFFFFFFF),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:please_pay_me/theme/tokens.dart';
|
||||
|
||||
/// iOS 15+ button styles.
|
||||
enum AppButtonStyle { filled, tinted, gray, plain, destructive }
|
||||
|
||||
/// Apple control sizes: large 50pt, medium 44pt, small 34pt.
|
||||
enum AppButtonSize { large, medium, small }
|
||||
|
||||
class AppButton extends StatelessWidget {
|
||||
const AppButton({
|
||||
super.key,
|
||||
required this.label,
|
||||
this.onPressed,
|
||||
this.style = AppButtonStyle.filled,
|
||||
this.size = AppButtonSize.large,
|
||||
this.expanded = true,
|
||||
this.icon,
|
||||
this.loading = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final VoidCallback? onPressed;
|
||||
final AppButtonStyle style;
|
||||
final AppButtonSize size;
|
||||
final bool expanded;
|
||||
final IconData? icon;
|
||||
final bool loading;
|
||||
|
||||
double get _height => switch (size) {
|
||||
AppButtonSize.large => AppSizes.buttonLarge,
|
||||
AppButtonSize.medium => AppSizes.buttonMedium,
|
||||
AppButtonSize.small => AppSizes.buttonSmall,
|
||||
};
|
||||
|
||||
TextStyle get _textStyle => switch (size) {
|
||||
AppButtonSize.large => AppTypography.headline,
|
||||
AppButtonSize.medium => AppTypography.body,
|
||||
AppButtonSize.small => AppTypography.subhead.copyWith(fontWeight: FontWeight.w600),
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final accent = AppColors.of(context, AppColors.accent);
|
||||
final red = AppColors.of(context, AppColors.systemRed);
|
||||
|
||||
final (Color background, Color foreground) = switch (style) {
|
||||
AppButtonStyle.filled => (accent, const Color(0xFFFFFFFF)),
|
||||
AppButtonStyle.tinted => (accent.withValues(alpha: 0.15), accent),
|
||||
AppButtonStyle.gray => (
|
||||
AppColors.of(context, AppColors.systemGray5),
|
||||
AppColors.of(context, AppColors.label),
|
||||
),
|
||||
AppButtonStyle.plain => (const Color(0x00000000), accent),
|
||||
AppButtonStyle.destructive => (red.withValues(alpha: 0.15), red),
|
||||
};
|
||||
|
||||
final disabled = onPressed == null || loading;
|
||||
final content = loading
|
||||
? CupertinoActivityIndicator(
|
||||
radius: size == AppButtonSize.small ? 8 : 10,
|
||||
color: foreground,
|
||||
)
|
||||
: Row(
|
||||
mainAxisSize: expanded ? MainAxisSize.max : MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(icon, size: size == AppButtonSize.small ? 16 : 19, color: foreground),
|
||||
const SizedBox(width: AppSpacing.s2),
|
||||
],
|
||||
Flexible(
|
||||
child: Text(
|
||||
label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: GoogleFonts.inter(textStyle: _textStyle, color: foreground),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
return Opacity(
|
||||
opacity: disabled && !loading ? 0.35 : 1,
|
||||
child: SizedBox(
|
||||
height: _height,
|
||||
width: expanded ? double.infinity : null,
|
||||
child: CupertinoButton(
|
||||
onPressed: disabled ? null : onPressed,
|
||||
color: style == AppButtonStyle.plain ? null : background,
|
||||
disabledColor: background,
|
||||
borderRadius: BorderRadius.circular(
|
||||
size == AppButtonSize.small ? AppRadii.md : AppRadii.lg,
|
||||
),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: size == AppButtonSize.small ? AppSpacing.s3 : AppSpacing.s4,
|
||||
),
|
||||
minimumSize: Size.zero,
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:please_pay_me/theme/tokens.dart';
|
||||
|
||||
class AppIcon extends StatelessWidget {
|
||||
const AppIcon(
|
||||
this.icon, {
|
||||
super.key,
|
||||
this.size = 22,
|
||||
this.color = AppColors.label,
|
||||
this.semanticLabel,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final double size;
|
||||
final Color color;
|
||||
final String? semanticLabel;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Icon(
|
||||
icon,
|
||||
size: size,
|
||||
color: AppColors.of(context, color),
|
||||
semanticLabel: semanticLabel,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Settings-style rounded square glyph used as a list row leading item.
|
||||
class AppIconBadge extends StatelessWidget {
|
||||
const AppIconBadge({
|
||||
super.key,
|
||||
required this.icon,
|
||||
this.size = 29,
|
||||
this.color = AppColors.accent,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final double size;
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: size,
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context, color),
|
||||
borderRadius: BorderRadius.circular(size * 0.235),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Icon(icon, size: size * 0.6, color: const Color(0xFFFFFFFF)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:please_pay_me/theme/tokens.dart';
|
||||
|
||||
/// Semantic text following the iOS type scale.
|
||||
class AppText extends StatelessWidget {
|
||||
const AppText(
|
||||
this.data, {
|
||||
super.key,
|
||||
this.style = AppTypography.body,
|
||||
this.color = AppColors.label,
|
||||
this.maxLines,
|
||||
this.overflow,
|
||||
this.textAlign,
|
||||
});
|
||||
|
||||
const AppText.largeTitle(this.data, {super.key, this.color = AppColors.label, this.maxLines, this.overflow, this.textAlign})
|
||||
: style = AppTypography.largeTitle;
|
||||
|
||||
const AppText.title(this.data, {super.key, this.color = AppColors.label, this.maxLines, this.overflow, this.textAlign})
|
||||
: style = AppTypography.title2;
|
||||
|
||||
const AppText.headline(this.data, {super.key, this.color = AppColors.label, this.maxLines, this.overflow, this.textAlign})
|
||||
: style = AppTypography.headline;
|
||||
|
||||
const AppText.body(this.data, {super.key, this.color = AppColors.label, this.maxLines, this.overflow, this.textAlign})
|
||||
: style = AppTypography.body;
|
||||
|
||||
const AppText.callout(this.data, {super.key, this.color = AppColors.secondaryLabel, this.maxLines, this.overflow, this.textAlign})
|
||||
: style = AppTypography.callout;
|
||||
|
||||
const AppText.subhead(this.data, {super.key, this.color = AppColors.secondaryLabel, this.maxLines, this.overflow, this.textAlign})
|
||||
: style = AppTypography.subhead;
|
||||
|
||||
const AppText.footnote(this.data, {super.key, this.color = AppColors.secondaryLabel, this.maxLines, this.overflow, this.textAlign})
|
||||
: style = AppTypography.footnote;
|
||||
|
||||
const AppText.caption(this.data, {super.key, this.color = AppColors.tertiaryLabel, this.maxLines, this.overflow, this.textAlign})
|
||||
: style = AppTypography.caption1;
|
||||
|
||||
final String data;
|
||||
final TextStyle style;
|
||||
final Color color;
|
||||
final int? maxLines;
|
||||
final TextOverflow? overflow;
|
||||
final TextAlign? textAlign;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text(
|
||||
data,
|
||||
maxLines: maxLines,
|
||||
overflow: overflow,
|
||||
textAlign: textAlign,
|
||||
style: GoogleFonts.inter(
|
||||
textStyle: style,
|
||||
color: AppColors.of(context, color),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Uppercase grouped-list header, e.g. `НАСТРОЙКИ`.
|
||||
class AppSectionHeader extends StatelessWidget {
|
||||
const AppSectionHeader(this.text, {super.key, this.padding});
|
||||
|
||||
final String text;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: padding ??
|
||||
const EdgeInsets.fromLTRB(
|
||||
AppSpacing.gutter,
|
||||
AppSpacing.s4,
|
||||
AppSpacing.gutter,
|
||||
AppSpacing.s2,
|
||||
),
|
||||
child: Text(
|
||||
text.toUpperCase(),
|
||||
style: GoogleFonts.inter(
|
||||
textStyle: AppTypography.footnote,
|
||||
color: AppColors.of(context, AppColors.secondaryLabel),
|
||||
letterSpacing: 0.4,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:please_pay_me/theme/tokens.dart';
|
||||
import 'package:please_pay_me/ui/atoms/app_text.dart';
|
||||
|
||||
/// Rounded iOS text field with optional grouped-style caption and error.
|
||||
class AppTextField extends StatelessWidget {
|
||||
const AppTextField({
|
||||
super.key,
|
||||
this.label,
|
||||
this.placeholder,
|
||||
this.controller,
|
||||
this.onChanged,
|
||||
this.keyboardType,
|
||||
this.obscureText = false,
|
||||
this.enabled = true,
|
||||
this.errorText,
|
||||
this.prefixIcon,
|
||||
this.clearable = true,
|
||||
this.maxLines = 1,
|
||||
});
|
||||
|
||||
final String? label;
|
||||
final String? placeholder;
|
||||
final TextEditingController? controller;
|
||||
final ValueChanged<String>? onChanged;
|
||||
final TextInputType? keyboardType;
|
||||
final bool obscureText;
|
||||
final bool enabled;
|
||||
final String? errorText;
|
||||
final IconData? prefixIcon;
|
||||
final bool clearable;
|
||||
final int maxLines;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final hasError = errorText != null && errorText!.isNotEmpty;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (label != null) AppSectionHeader(label!, padding: const EdgeInsets.only(bottom: AppSpacing.s2)),
|
||||
Opacity(
|
||||
opacity: enabled ? 1 : 0.4,
|
||||
child: CupertinoTextField(
|
||||
controller: controller,
|
||||
onChanged: onChanged,
|
||||
keyboardType: keyboardType,
|
||||
obscureText: obscureText,
|
||||
enabled: enabled,
|
||||
maxLines: maxLines,
|
||||
placeholder: placeholder,
|
||||
clearButtonMode: clearable ? OverlayVisibilityMode.editing : OverlayVisibilityMode.never,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.s3,
|
||||
vertical: AppSpacing.s3,
|
||||
),
|
||||
prefix: prefixIcon == null
|
||||
? null
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(left: AppSpacing.s3),
|
||||
child: Icon(
|
||||
prefixIcon,
|
||||
size: 20,
|
||||
color: AppColors.of(context, AppColors.secondaryLabel),
|
||||
),
|
||||
),
|
||||
placeholderStyle: GoogleFonts.inter(
|
||||
textStyle: AppTypography.body,
|
||||
color: AppColors.of(context, AppColors.tertiaryLabel),
|
||||
),
|
||||
style: GoogleFonts.inter(
|
||||
textStyle: AppTypography.body,
|
||||
color: AppColors.of(context, AppColors.label),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context, AppColors.groupedSurface),
|
||||
borderRadius: BorderRadius.circular(AppRadii.md),
|
||||
border: Border.all(
|
||||
color: hasError
|
||||
? AppColors.of(context, AppColors.systemRed)
|
||||
: AppColors.of(context, AppColors.opaqueSeparator),
|
||||
width: AppSizes.hairline,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (hasError)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: AppSpacing.s2, left: AppSpacing.s1),
|
||||
child: AppText.footnote(errorText!, color: AppColors.systemRed),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user