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
188 lines
5.8 KiB
Dart
188 lines
5.8 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:stacked/stacked.dart';
|
|
|
|
import '../../about/external/initial/LoginData.dart';
|
|
import '../../about/internal/application/NavigatorType.dart';
|
|
import '../../about/internal/application/TextType.dart';
|
|
import '../../about/internal/application/UserDetails.dart';
|
|
import '../../configs/Navigator.dart';
|
|
import '../../designs/Responsive.dart';
|
|
import '../../designs/buttons/Buttons.dart';
|
|
import '../../designs/input/InputFields.dart';
|
|
import '../../designs/text/Text.dart';
|
|
import '../../utils/Colors.dart';
|
|
import '../../utils/Validators.dart';
|
|
import '../home/Home.dart';
|
|
import 'ConnectLogin.dart';
|
|
import 'Login.dart';
|
|
import 'ViewLogin.dart';
|
|
|
|
class LoginState extends State<Login> implements ConnectLogin {
|
|
ViewLogin? _model;
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
final TextEditingController _username = TextEditingController();
|
|
|
|
final TextEditingController _password = TextEditingController();
|
|
|
|
bool _obscured = true;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ViewModelBuilder<ViewLogin>.reactive(
|
|
viewModelBuilder: () => ViewLogin(context, this),
|
|
onViewModelReady: (viewModel) {
|
|
_model = viewModel;
|
|
_initiate();
|
|
},
|
|
builder: (context, viewModel, child) => Scaffold(
|
|
backgroundColor: colorPrimaryDark,
|
|
body: LayoutBuilder(
|
|
builder: (BuildContext context, BoxConstraints constraints) {
|
|
return Responsive(
|
|
mobile: _mobileView(constraints),
|
|
tablet: _mobileView(constraints),
|
|
desktop: _mobileView(constraints),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void _initiate() {}
|
|
|
|
void _onToggleObscured() {
|
|
setState(() {
|
|
_obscured = !_obscured;
|
|
});
|
|
}
|
|
|
|
void _onSignIn() {
|
|
if (_formKey.currentState?.validate() != true) {
|
|
return;
|
|
}
|
|
|
|
_model?.login(LoginData(
|
|
username: _username.text.trim(),
|
|
password: _password.text,
|
|
));
|
|
}
|
|
|
|
Widget _mobileView(BoxConstraints constraints) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
SafeArea(
|
|
bottom: false,
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(28, 24, 28, 32),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
text("GROUNDED", 10, TextType.Bold,
|
|
color: colorWhite.withValues(alpha: 0.45),
|
|
letterSpacing: 2.0),
|
|
const SizedBox(height: 22),
|
|
text("Welcome back.", 36, TextType.Light,
|
|
color: colorWhite, height: 1.1),
|
|
const SizedBox(height: 10),
|
|
text(
|
|
"Your record has been waiting exactly where you left it.",
|
|
14,
|
|
TextType.Regular,
|
|
color: colorWhite.withValues(alpha: 0.55),
|
|
height: 1.5,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: colorPrimaryLight,
|
|
borderRadius: const BorderRadius.only(
|
|
topLeft: Radius.circular(28),
|
|
topRight: Radius.circular(28),
|
|
),
|
|
),
|
|
clipBehavior: Clip.antiAlias,
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.fromLTRB(24, 32, 24, 32),
|
|
child: Form(
|
|
key: _formKey,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
inputField(
|
|
"Username",
|
|
_username,
|
|
hint: "The one you signed up with",
|
|
validator: Validators.username,
|
|
keyboard: TextInputType.emailAddress,
|
|
icon: CupertinoIcons.person,
|
|
),
|
|
const SizedBox(height: 20),
|
|
inputField(
|
|
"Password",
|
|
_password,
|
|
hint: "Your password",
|
|
validator: Validators.password,
|
|
obscure: _obscured,
|
|
icon: CupertinoIcons.lock,
|
|
),
|
|
const SizedBox(height: 8),
|
|
Align(
|
|
alignment: Alignment.centerRight,
|
|
child: textButton(
|
|
_obscured ? "Show password" : "Hide password",
|
|
_onToggleObscured,
|
|
textSize: 12,
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
roundedCornerButton(
|
|
"Sign in",
|
|
_onSignIn,
|
|
icon: CupertinoIcons.arrow_right,
|
|
),
|
|
const SizedBox(height: 24),
|
|
Center(
|
|
child: text(
|
|
"Nothing here judges you for being away.",
|
|
12,
|
|
TextType.Regular,
|
|
color: colorGrey2,
|
|
align: TextAlign.center,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
@override
|
|
void onLoggedIn(UserDetails details) {
|
|
GroundedNavigation()
|
|
.navigateToPage(NavigatorType.makeNewMain, const Home(), context);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_username.dispose();
|
|
_password.dispose();
|
|
super.dispose();
|
|
}
|
|
}
|