Initial commit: Grounded Flutter frontend
A to-do app that doesn't believe you — an enforcement layer rather than a
neutral ledger.
Architecture ported from Autoreceptives/Frontend/Receptive: stacked MVVM with
the mandatory 4-file screen pattern, one ParentViewModel owning the loading /
network / error overlays and the handleError decision tree, one AppDataManager
gateway, dio comms carrying the three identity headers, secure storage with
random-suffixed keys, and a single-chokepoint Navigator. Package root and Dart
package name are both Grounded; org is nya.
The enforcement engine, one unit per formula in utils/:
- DebtEngine w(class) x severity(d) x decay(t), sublinear severity so old
misses cannot swamp the score; abandonment 2x with 30-day
decay immunity; late complete retains 30%
- StandingEngine Good -> Warned -> Grounded -> Lockdown, derived not set;
Grounded replaces home with the overdue queue
- CapacityEngine blocks over-scheduling against p50 of historically completed
minutes, with a learned per-category estimation multiplier
- IntegrityEngine session integrity, weekly volume, plyometric contact ceiling
and enforced recovery gaps
- ExcuseAnalyser on-device excuse clustering plus the confrontation copy
- GuardrailEngine distress detection and rationed amnesty
- ToneEngine all enforcement copy, so the tone cap lives in one place
CommitmentEvent is append-only and is the source of truth rather than the
status field, which is what makes honest history and excuse analysis possible.
Goals contain commitments via parentId, and a task can be run from a
full-screen runner that derives elapsed time from wall-clock so screen-off
cannot lose time. Backgrounding pauses the clock and is counted. The runner is
mirrored into an ongoing notification, with alarm-class full-screen intents
reserved for non-negotiables.
Design language, fonts, icon and native splash are in place; Mason bricks are
retargeted to this project and verified end-to-end.
flutter analyze lib/ reports no errors.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mfu2gQLSFN21YRBcU2NrTt
This commit is contained in:
202
frontend/lib/Grounded/designs/Component.dart
Normal file
202
frontend/lib/Grounded/designs/Component.dart
Normal file
@@ -0,0 +1,202 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../about/internal/application/TextType.dart';
|
||||
import '../utils/Colors.dart';
|
||||
import 'text/Text.dart';
|
||||
|
||||
/// The font families, wrapped so no screen ever names a family directly.
|
||||
/// General Sans — see fonts/LICENSE-GeneralSans.txt.
|
||||
String getTextType(TextType type) {
|
||||
switch (type) {
|
||||
case TextType.Bold:
|
||||
return "GroundedBold";
|
||||
case TextType.Light:
|
||||
return "GroundedLight";
|
||||
case TextType.Regular:
|
||||
return "GroundedRegular";
|
||||
case TextType.Medium:
|
||||
return "GroundedMedium";
|
||||
}
|
||||
}
|
||||
|
||||
/// A labelled pill — the standing chip, the class chip, the proof chip. One
|
||||
/// implementation so they stay visually identical everywhere.
|
||||
Widget pill(
|
||||
String label,
|
||||
Color foreground,
|
||||
Color background, {
|
||||
IconData? icon,
|
||||
double textSize = 10,
|
||||
}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: background,
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
border: Border.all(color: foreground.withValues(alpha: 0.20), width: 1),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(icon, size: textSize + 2, color: foreground),
|
||||
const SizedBox(width: 5),
|
||||
],
|
||||
text(
|
||||
label.toUpperCase(),
|
||||
textSize,
|
||||
TextType.Bold,
|
||||
color: foreground,
|
||||
letterSpacing: 0.7,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The standard card surface.
|
||||
Widget card({
|
||||
required Widget child,
|
||||
EdgeInsets padding = const EdgeInsets.all(16),
|
||||
EdgeInsets margin = EdgeInsets.zero,
|
||||
Color? background,
|
||||
Color? borderColor,
|
||||
double radius = 16,
|
||||
VoidCallback? onTap,
|
||||
}) {
|
||||
final Widget body = Container(
|
||||
width: double.infinity,
|
||||
padding: padding,
|
||||
margin: margin,
|
||||
decoration: BoxDecoration(
|
||||
color: background ?? colorCard,
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
border: Border.all(color: borderColor ?? colorBorder, width: 1),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x08000000),
|
||||
blurRadius: 18,
|
||||
offset: Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
|
||||
if (onTap == null) {
|
||||
return body;
|
||||
}
|
||||
|
||||
return GestureDetector(onTap: onTap, child: body);
|
||||
}
|
||||
|
||||
/// Section heading — small all-caps label over a large light title, the
|
||||
/// house style used on every screen header.
|
||||
Widget sectionHeader(String label, String title, {Color? titleColor}) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
text(label.toUpperCase(), 11, TextType.Bold,
|
||||
color: colorGrey2, letterSpacing: 1.2),
|
||||
const SizedBox(height: 8),
|
||||
text(title, 32, TextType.Light, color: titleColor ?? colorPrimaryDark),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// A labelled statistic, used across the report card and the debt header.
|
||||
Widget statTile(
|
||||
String label,
|
||||
String value, {
|
||||
Color? valueColor,
|
||||
String? caption,
|
||||
}) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
text(label.toUpperCase(), 10, TextType.Bold,
|
||||
color: colorGrey2, letterSpacing: 0.8),
|
||||
const SizedBox(height: 6),
|
||||
text(value, 26, TextType.Bold, color: valueColor ?? colorPrimaryDark),
|
||||
if (caption != null) ...[
|
||||
const SizedBox(height: 2),
|
||||
text(caption, 11, TextType.Regular, color: colorGrey2),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// A hairline divider at the house opacity.
|
||||
Widget hairline({EdgeInsets margin = EdgeInsets.zero}) {
|
||||
return Container(
|
||||
height: 1,
|
||||
margin: margin,
|
||||
color: colorDivider,
|
||||
);
|
||||
}
|
||||
|
||||
/// Empty state. Deliberately plain — an empty queue is good news and should
|
||||
/// not be celebrated with confetti.
|
||||
Widget emptyState(
|
||||
IconData icon,
|
||||
String title,
|
||||
String description, {
|
||||
Color? accent,
|
||||
}) {
|
||||
final Color tone = accent ?? colorGrey2;
|
||||
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 48),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 76,
|
||||
height: 76,
|
||||
decoration: BoxDecoration(
|
||||
color: tone.withValues(alpha: 0.08),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(icon, size: 32, color: tone),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
text(title, 18, TextType.Bold,
|
||||
color: colorPrimaryDark, align: TextAlign.center),
|
||||
const SizedBox(height: 8),
|
||||
text(description, 13, TextType.Regular,
|
||||
color: colorGrey2, align: TextAlign.center, height: 1.5),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// A progress bar with the house geometry.
|
||||
Widget meter(
|
||||
double fraction, {
|
||||
Color? fill,
|
||||
Color? track,
|
||||
double height = 8,
|
||||
}) {
|
||||
final double clamped = fraction.isNaN
|
||||
? 0
|
||||
: fraction < 0
|
||||
? 0
|
||||
: fraction > 1
|
||||
? 1
|
||||
: fraction;
|
||||
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
child: LinearProgressIndicator(
|
||||
value: clamped,
|
||||
minHeight: height,
|
||||
backgroundColor: track ?? colorMuted,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(fill ?? colorPrimary),
|
||||
),
|
||||
);
|
||||
}
|
||||
53
frontend/lib/Grounded/designs/Responsive.dart
Normal file
53
frontend/lib/Grounded/designs/Responsive.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../about/internal/application/TextType.dart';
|
||||
import 'text/Text.dart';
|
||||
|
||||
class Responsive extends StatelessWidget {
|
||||
final Widget mobile;
|
||||
final Widget tablet;
|
||||
final Widget desktop;
|
||||
|
||||
const Responsive({
|
||||
super.key,
|
||||
required this.desktop,
|
||||
required this.mobile,
|
||||
required this.tablet,
|
||||
});
|
||||
|
||||
/// mobile < 650
|
||||
static bool isMobile(BuildContext context) =>
|
||||
MediaQuery.sizeOf(context).width < 650;
|
||||
|
||||
/// tablet >= 650
|
||||
static bool isTablet(BuildContext context) =>
|
||||
MediaQuery.sizeOf(context).width >= 650;
|
||||
|
||||
/// desktop >= 1100
|
||||
static bool isDesktop(BuildContext context) =>
|
||||
MediaQuery.sizeOf(context).width >= 1100;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
if (isDesktop(context)) {
|
||||
return desktop;
|
||||
} else if (isTablet(context)) {
|
||||
return tablet;
|
||||
} else if (isMobile(context)) {
|
||||
return mobile;
|
||||
} else {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [text("NOT SUPPORTED", 12, TextType.Bold)],
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
287
frontend/lib/Grounded/designs/Shell.dart
Normal file
287
frontend/lib/Grounded/designs/Shell.dart
Normal file
@@ -0,0 +1,287 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../about/internal/application/TextType.dart';
|
||||
import '../utils/Colors.dart';
|
||||
import 'Component.dart';
|
||||
import 'text/Text.dart';
|
||||
|
||||
/// The house layout: black chrome at the top, a white sheet rising into it with
|
||||
/// a large corner radius. Every screen is built from this so the app reads as
|
||||
/// one object rather than a stack of pages.
|
||||
class Sheet extends StatelessWidget {
|
||||
/// Small all-caps label rendered in the black chrome, above the title.
|
||||
final String eyebrow;
|
||||
|
||||
/// The chrome title — small and centred, not the display title.
|
||||
final String title;
|
||||
|
||||
final Widget child;
|
||||
|
||||
final VoidCallback? onBack;
|
||||
|
||||
/// Optional trailing control in the chrome.
|
||||
final Widget? action;
|
||||
|
||||
/// Chrome colour. Defaults to near-black; standing screens tint it.
|
||||
final Color? chrome;
|
||||
|
||||
/// Rendered inside the chrome beneath the title — the standing strip.
|
||||
final Widget? banner;
|
||||
|
||||
final bool scrollable;
|
||||
|
||||
const Sheet({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.child,
|
||||
this.eyebrow = "",
|
||||
this.onBack,
|
||||
this.action,
|
||||
this.chrome,
|
||||
this.banner,
|
||||
this.scrollable = true,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Color chromeColor = chrome ?? colorPrimaryDark;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: chromeColor,
|
||||
body: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SafeArea(
|
||||
bottom: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 4, 12, 16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 44,
|
||||
child: onBack == null
|
||||
? null
|
||||
: _chromeButton(
|
||||
Icons.arrow_back_ios_new_rounded, onBack!),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (eyebrow.isNotEmpty) ...[
|
||||
text(
|
||||
eyebrow.toUpperCase(),
|
||||
9,
|
||||
TextType.Bold,
|
||||
color: colorWhite.withValues(alpha: 0.45),
|
||||
letterSpacing: 1.2,
|
||||
align: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
],
|
||||
text(
|
||||
title,
|
||||
15,
|
||||
TextType.Medium,
|
||||
color: colorWhite,
|
||||
align: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 44,
|
||||
child: action == null
|
||||
? null
|
||||
: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: action,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (banner != null) ...[
|
||||
const SizedBox(height: 16),
|
||||
banner!,
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: colorPrimaryLight,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(28),
|
||||
topRight: Radius.circular(28),
|
||||
),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: scrollable
|
||||
? SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(20, 28, 20, 40),
|
||||
child: child,
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 28, 20, 0),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _chromeButton(IconData icon, VoidCallback onTap) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
width: 38,
|
||||
height: 38,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: colorWhite.withValues(alpha: 0.10),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(icon, size: 15, color: colorWhite),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A circular control for the black chrome, with an optional unread dot.
|
||||
Widget chromeAction(
|
||||
IconData icon,
|
||||
VoidCallback onTap, {
|
||||
bool dotted = false,
|
||||
Color? dotColor,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Container(
|
||||
width: 38,
|
||||
height: 38,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: colorWhite.withValues(alpha: 0.10),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(icon, size: 17, color: colorWhite),
|
||||
),
|
||||
if (dotted)
|
||||
Positioned(
|
||||
top: 1,
|
||||
right: 1,
|
||||
child: Container(
|
||||
width: 9,
|
||||
height: 9,
|
||||
decoration: BoxDecoration(
|
||||
color: dotColor ?? colorAccent,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: colorPrimaryDark, width: 1.5),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The label/value pair — a tiny grey all-caps label sitting directly above a
|
||||
/// value. The core unit of the whole interface.
|
||||
Widget labelled(
|
||||
String label,
|
||||
String value, {
|
||||
double valueSize = 15,
|
||||
TextType valueType = TextType.Medium,
|
||||
Color? valueColor,
|
||||
Color? labelColor,
|
||||
CrossAxisAlignment align = CrossAxisAlignment.start,
|
||||
}) {
|
||||
return Column(
|
||||
crossAxisAlignment: align,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
text(
|
||||
label.toUpperCase(),
|
||||
9,
|
||||
TextType.Bold,
|
||||
color: labelColor ?? colorGrey2,
|
||||
letterSpacing: 1.0,
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
text(value, valueSize, valueType,
|
||||
color: valueColor ?? colorPrimaryDark),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// A row of metadata above a display title, as on the reference: small grey
|
||||
/// pairs separated by generous space.
|
||||
Widget metaRow(List<Widget> items) {
|
||||
final List<Widget> spaced = <Widget>[];
|
||||
|
||||
for (int index = 0; index < items.length; index++) {
|
||||
spaced.add(items[index]);
|
||||
if (index != items.length - 1) {
|
||||
spaced.add(const SizedBox(width: 28));
|
||||
}
|
||||
}
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: spaced,
|
||||
);
|
||||
}
|
||||
|
||||
/// The oversized light display title that opens a section.
|
||||
Widget displayTitle(String value, {Color? color, double size = 34}) {
|
||||
return text(value, size, TextType.Light,
|
||||
color: color ?? colorPrimaryDark, height: 1.15);
|
||||
}
|
||||
|
||||
/// A section break: hairline, then a small bold heading with an optional
|
||||
/// trailing chip.
|
||||
Widget sectionBreak(String heading, {Widget? trailing, String caption = ""}) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
hairline(margin: const EdgeInsets.only(bottom: 20)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
text(heading, 17, TextType.Bold, color: colorPrimaryDark),
|
||||
if (caption.isNotEmpty) ...[
|
||||
const SizedBox(width: 10),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 2),
|
||||
child: text(caption, 11, TextType.Regular,
|
||||
color: colorGrey2),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailing != null) trailing,
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
);
|
||||
}
|
||||
178
frontend/lib/Grounded/designs/buttons/Buttons.dart
Normal file
178
frontend/lib/Grounded/designs/buttons/Buttons.dart
Normal file
@@ -0,0 +1,178 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../about/internal/application/TextType.dart';
|
||||
import '../../utils/Colors.dart';
|
||||
import '../Component.dart';
|
||||
import '../text/Text.dart';
|
||||
|
||||
/// The primary action. One per screen — if a screen appears to need two, one
|
||||
/// of them is secondary.
|
||||
Widget roundedCornerButton(
|
||||
String label,
|
||||
VoidCallback onPressed, {
|
||||
Color? background,
|
||||
Color? foreground,
|
||||
IconData? icon,
|
||||
bool enabled = true,
|
||||
double radius = 14,
|
||||
double verticalPadding = 16,
|
||||
}) {
|
||||
final Color bg = enabled ? (background ?? colorPrimaryDark) : colorGrey;
|
||||
final Color fg = foreground ?? colorWhite;
|
||||
|
||||
return ElevatedButton(
|
||||
onPressed: enabled ? onPressed : null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor: bg,
|
||||
disabledBackgroundColor: colorGrey.withValues(alpha: 0.4),
|
||||
padding: EdgeInsets.symmetric(vertical: verticalPadding),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(icon, size: 16, color: fg),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
text(label, 14, TextType.Bold, color: fg),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The secondary action — outlined, never filled, so the hierarchy is never
|
||||
/// ambiguous.
|
||||
Widget outlinedActionButton(
|
||||
String label,
|
||||
VoidCallback onPressed, {
|
||||
Color? foreground,
|
||||
IconData? icon,
|
||||
bool enabled = true,
|
||||
double radius = 14,
|
||||
}) {
|
||||
final Color fg = enabled ? (foreground ?? colorPrimaryDark) : colorGrey;
|
||||
|
||||
return OutlinedButton(
|
||||
onPressed: enabled ? onPressed : null,
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: BorderSide(color: fg.withValues(alpha: 0.35), width: 1),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(icon, size: 16, color: fg),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
text(label, 14, TextType.Bold, color: fg),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget textButton(
|
||||
String label,
|
||||
VoidCallback onPressed, {
|
||||
Color? color,
|
||||
double textSize = 13,
|
||||
TextType type = TextType.Regular,
|
||||
}) {
|
||||
return TextButton(
|
||||
onPressed: onPressed,
|
||||
child: text(label, textSize, type, color: color ?? colorGrey2),
|
||||
);
|
||||
}
|
||||
|
||||
Widget iconButton(
|
||||
Widget icon,
|
||||
VoidCallback onPressed, {
|
||||
bool bordered = false,
|
||||
Color? borderColor,
|
||||
Color? background,
|
||||
double radius = 10,
|
||||
double size = 38,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onPressed,
|
||||
child: Container(
|
||||
width: size,
|
||||
height: size,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: background ?? Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
border: bordered
|
||||
? Border.all(color: borderColor ?? colorBorder, width: 1)
|
||||
: null,
|
||||
),
|
||||
child: icon,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The destructive action — abandoning, which costs the most debt of all and
|
||||
/// so is always visually distinct from completing.
|
||||
Widget destructiveButton(
|
||||
String label,
|
||||
VoidCallback onPressed, {
|
||||
IconData? icon,
|
||||
bool enabled = true,
|
||||
}) {
|
||||
return roundedCornerButton(
|
||||
label,
|
||||
onPressed,
|
||||
background: colorDestructive,
|
||||
foreground: colorWhite,
|
||||
icon: icon,
|
||||
enabled: enabled,
|
||||
);
|
||||
}
|
||||
|
||||
/// A segmented selector, used for class, energy, proof type and tone.
|
||||
Widget segmentedSelector<T>({
|
||||
required List<T> options,
|
||||
required T selected,
|
||||
required String Function(T) label,
|
||||
required void Function(T) onSelected,
|
||||
Color? activeColor,
|
||||
}) {
|
||||
final Color active = activeColor ?? colorPrimaryDark;
|
||||
|
||||
return Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: options.map((option) {
|
||||
final bool isSelected = option == selected;
|
||||
return GestureDetector(
|
||||
onTap: () => onSelected(option),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? active : colorWhite,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: isSelected ? active : colorBorder,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: text(
|
||||
label(option),
|
||||
12,
|
||||
isSelected ? TextType.Bold : TextType.Regular,
|
||||
color: isSelected ? colorWhite : colorGrey2,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
206
frontend/lib/Grounded/designs/input/InputFields.dart
Normal file
206
frontend/lib/Grounded/designs/input/InputFields.dart
Normal file
@@ -0,0 +1,206 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../about/internal/application/TextType.dart';
|
||||
import '../../utils/Colors.dart';
|
||||
import '../Component.dart';
|
||||
import '../text/Text.dart';
|
||||
|
||||
/// The standard text field.
|
||||
Widget inputField(
|
||||
String label,
|
||||
TextEditingController controller, {
|
||||
String hint = "",
|
||||
String? Function(String?)? validator,
|
||||
TextInputType keyboard = TextInputType.text,
|
||||
bool obscure = false,
|
||||
int maxLines = 1,
|
||||
List<TextInputFormatter>? formatters,
|
||||
IconData? icon,
|
||||
ValueChanged<String>? onChanged,
|
||||
}) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
text(label.toUpperCase(), 10, TextType.Bold,
|
||||
color: colorGrey2, letterSpacing: 0.8),
|
||||
const SizedBox(height: 8),
|
||||
TextFormField(
|
||||
controller: controller,
|
||||
validator: validator,
|
||||
keyboardType: keyboard,
|
||||
obscureText: obscure,
|
||||
maxLines: obscure ? 1 : maxLines,
|
||||
inputFormatters: formatters,
|
||||
onChanged: onChanged,
|
||||
style: TextStyle(
|
||||
fontFamily: getTextType(TextType.Regular),
|
||||
fontSize: 14,
|
||||
color: colorPrimaryDark,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: hint,
|
||||
hintStyle: TextStyle(
|
||||
fontFamily: getTextType(TextType.Regular),
|
||||
fontSize: 13,
|
||||
color: colorGrey,
|
||||
),
|
||||
prefixIcon: icon == null
|
||||
? null
|
||||
: Icon(icon, size: 18, color: colorGrey2),
|
||||
filled: true,
|
||||
fillColor: colorWhite,
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 14, vertical: 14),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: colorBorder, width: 1),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: colorPrimaryDark, width: 1.4),
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: colorNegative, width: 1),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: colorNegative, width: 1.4),
|
||||
),
|
||||
errorStyle: TextStyle(
|
||||
fontFamily: getTextType(TextType.Regular),
|
||||
fontSize: 11,
|
||||
color: colorNegative,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// The excuse field. Deliberately unadorned — no templates, no quick-picks, a
|
||||
/// live character count that shows the minimum, because the friction is the
|
||||
/// feature rather than an obstacle to route around.
|
||||
Widget excuseField(
|
||||
TextEditingController controller,
|
||||
int minimumLength, {
|
||||
String? Function(String?)? validator,
|
||||
ValueChanged<String>? onChanged,
|
||||
}) {
|
||||
final int length = controller.text.trim().length;
|
||||
final bool satisfied = length >= minimumLength;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
text("WHY", 10, TextType.Bold, color: colorGrey2, letterSpacing: 0.8),
|
||||
text(
|
||||
satisfied ? "$length characters" : "$length / $minimumLength",
|
||||
10,
|
||||
TextType.Bold,
|
||||
color: satisfied ? colorPositive : colorGrey,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextFormField(
|
||||
controller: controller,
|
||||
validator: validator,
|
||||
onChanged: onChanged,
|
||||
maxLines: 4,
|
||||
style: TextStyle(
|
||||
fontFamily: getTextType(TextType.Regular),
|
||||
fontSize: 14,
|
||||
color: colorPrimaryDark,
|
||||
height: 1.5,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: "In your own words. No shortcuts here.",
|
||||
hintStyle: TextStyle(
|
||||
fontFamily: getTextType(TextType.Regular),
|
||||
fontSize: 13,
|
||||
color: colorGrey,
|
||||
),
|
||||
filled: true,
|
||||
fillColor: colorWhite,
|
||||
contentPadding: const EdgeInsets.all(14),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: colorBorder, width: 1),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: colorPrimaryDark, width: 1.4),
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: colorNegative, width: 1),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: colorNegative, width: 1.4),
|
||||
),
|
||||
errorStyle: TextStyle(
|
||||
fontFamily: getTextType(TextType.Regular),
|
||||
fontSize: 11,
|
||||
color: colorNegative,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// A read-only field that loads its options on tap rather than pre-loading
|
||||
/// them — the ViewModel fetches, then calls back to open the picker.
|
||||
Widget selectField(
|
||||
String label,
|
||||
String value,
|
||||
VoidCallback onTap, {
|
||||
String hint = "Select",
|
||||
IconData icon = Icons.expand_more_rounded,
|
||||
}) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
text(label.toUpperCase(), 10, TextType.Bold,
|
||||
color: colorGrey2, letterSpacing: 0.8),
|
||||
const SizedBox(height: 8),
|
||||
GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: colorWhite,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: colorBorder, width: 1),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: text(
|
||||
value.isEmpty ? hint : value,
|
||||
14,
|
||||
value.isEmpty ? TextType.Regular : TextType.Bold,
|
||||
color: value.isEmpty ? colorGrey : colorPrimaryDark,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Icon(icon, size: 20, color: colorGrey2),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
39
frontend/lib/Grounded/designs/text/Text.dart
Normal file
39
frontend/lib/Grounded/designs/text/Text.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../about/internal/application/TextType.dart';
|
||||
import '../../utils/Colors.dart';
|
||||
import '../Component.dart';
|
||||
|
||||
/// The only way display copy is rendered. Raw Text/TextStyle is never used for
|
||||
/// user-facing copy.
|
||||
Widget text(
|
||||
String text,
|
||||
double textSize,
|
||||
TextType type, {
|
||||
Color? color,
|
||||
TextAlign? align,
|
||||
int? maxLines,
|
||||
TextOverflow? overflow,
|
||||
double? letterSpacing,
|
||||
double? height,
|
||||
double? wordSpacing,
|
||||
TextDecoration? decoration,
|
||||
FontWeight? weight,
|
||||
}) {
|
||||
return Text(
|
||||
text,
|
||||
textAlign: align ?? TextAlign.left,
|
||||
maxLines: maxLines,
|
||||
overflow: overflow,
|
||||
style: TextStyle(
|
||||
decoration: decoration ?? TextDecoration.none,
|
||||
color: color ?? colorPrimaryDark,
|
||||
fontSize: textSize,
|
||||
fontFamily: getTextType(type),
|
||||
letterSpacing: letterSpacing,
|
||||
height: height,
|
||||
wordSpacing: wordSpacing,
|
||||
fontWeight: weight,
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user