halkyon/packages/halkyon_app/lib/src/profile/widget/halkyon_profile.dart

144 lines
5.7 KiB
Dart
Raw Normal View History

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:halkyon_app/l10n/halkyon_app_localizations.dart';
feat(base,app,learn,todo,train,meditate): agent accounts with tokens ADR 0044's step 6a (D42, D43, D45): accounts for programs, such as AI assistants, that an identified person makes from the Profile. halkyon_base keeps them on the instance's register, which its members ask: an agent is an account (agent_account: its owner, its name, its public keys, set by itself once) with one token (agent_token: 32 random bytes, kept as their SHA-256 alone, shown once). agents.create, mine, newToken, revoke, delete and setKeys serve its owner; agentSignIn.signIn exchanges the token for an ordinary server-side session of a day, with the scopes identified and agent, at most 60 sign-ins an hour from a network. Revoking a token or making a new one ends the agent's sessions; a token unused for 90 days lapses in every service's pruning. Up to 5 agents a person, where the operator didn't switch them off (AGENTS=off; said on the privacy page and in instance.basics). An agent makes no agents, creates or owns no shared space, is invited and raised as a Viewer alone, is never handed a space on, is named no operator and granted no assistants; each refusal has its test. Deleting a person deletes their agents first; an agent's public profile names whose agent it is. In the apps, every Profile has an Agents card (halkyon_app's AgentsSection): made with a name and a handle, its token shown once to copy, a new token, the token taken back, deleted. Learn's Share sheet marks an agent among the members and offers it no role above Viewer. The migrations, the module's and each host's (Learn, Meditate, Todo, Train), are additive alone: CREATE TABLE "agent_account" with a unique index on "agentId" (one row an agent account) and one on "ownerId" (a person's agents, and deleting them with the person), and CREATE TABLE "agent_token" with unique indexes on "agentId" (one token an agent) and "tokenHash" (the sign-in finds the token by its hash). No existing table is touched, so the server before the deploy keeps working on the migrated database. Whats-New: Make agents in your Profile: accounts for programs such as AI assistants, which sign in with a token and see only what you share with them. Whats-New-De: Leg in deinem Profil Agenten an: Konten für Programme wie KI-Assistenten, die sich mit einem Token anmelden und nur sehen, was du mit ihnen teilst. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-11 19:55:27 +01:00
import 'package:halkyon_app/src/agent/widget/agents_section.dart';
import 'package:halkyon_app/src/app/app_scope.dart';
import 'package:halkyon_app/src/auth/bloc/sign_in_ways_cubit.dart';
import 'package:halkyon_app/src/password/widget/account_security_section.dart';
import 'package:halkyon_app/src/profile/widget/public_profile_section.dart';
import 'package:halkyon_app/src/simplelogin/widget/simplelogin_section.dart';
import 'package:halkyon_ui/halkyon_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:material_ui/material_ui.dart';
/// Every Halkyon app's Profile (decided 2026-11-02, the developer's wish
/// for one profile in function and look across the apps): the person's
/// own tab first, the same in every app (their account and the ways they
/// sign in, SimpleLogin and the password with its authenticators, then the
/// app's own [sections], then the public profile others see, one for all
/// apps), and after it the app's own [tabs] (Learn's statistics, Train's
/// progress). With several tabs, the tab row folds into the title as the
/// content scrolls ([FoldingTabs], as Strava's); with none of the app's,
/// the person's tab alone, under the title. The [actions] stand in the app
/// bar (the app's Settings); the app's colour washes down from the top
/// ([TopGradient], [color], into [background]).
class const HalkyonProfile({
final List<Widget> actions = const [],
final List<Widget> sections = const [],
final List<FoldingTab> tabs = const [],
final Color? color,
final Color? background,
super.key,
}) extends StatelessWidget {
@override
Widget build(BuildContext context) {
final l10n = HalkyonAppLocalizations.of(context);
final mine = _Mine(sections: sections);
return BlocProvider(
create: (context) => SignInWaysCubit(AppScope.of(context).auth)..load(),
child: TopGradient(
color: color,
background: background ?? Theme.of(context).colorScheme.surface,
child: tabs.isEmpty
? Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
backgroundColor: Colors.transparent,
systemOverlayStyle: TopGradient.overlayStyle(context),
title: Text(l10n.profileTitle),
actions: actions,
),
body: mine,
)
: FoldingTabs(
title: l10n.profileTitle,
actions: actions,
tabs: [
FoldingTab(label: l10n.profileTabProfile, body: mine),
...tabs,
],
),
),
);
}
}
/// The person's own tab: a card for each part, as Settings groups its own,
/// in the middle and as wide as readable text.
class const _Mine({required final List<Widget> sections})
extends StatelessWidget {
@override
Widget build(BuildContext context) {
final l10n = HalkyonAppLocalizations.of(context);
return Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: readableContentMaxWidth),
child: ListView(
feat(learn,todo,train,meditate,ui): the navigation bar flush with the foot, a fade above it Below medium windows the frame's bar is Material 3 Expressive's again, flush with the window's foot (decided 7 Nov 2026 by the developer): the theme's NavigationBar across the whole width, 64 dp in its own colour, running on beneath the system's bar as Material's does. Right above it a fade 32 dp high, from the background of the screen in view (the ScreenTint's, the theme's surface before a screen claims one) made see-through to that background, so what scrolls on beneath the bar fades out rather than being cut off; taps pass through it. The rail of wider windows stays as it was. halkyon_ui's FloatingNavigationBar becomes FlushNavigationBar, its side margin, lift and rounded card gone. Its coverOf is now the whole room content leaves at its end, the system's bar included (the body's bottom padding: bar, fade and system's bar inside the frame, the system's bar alone outside it), and floating buttons rise by buttonLiftOf, the same without the system's bar, which a Scaffold keeps them clear of itself. Lists, Todo's hour grid and the Plan's sheet keep using coverOf; the Profile's list no longer adds the system's bar a second time. Whats-New: The navigation bar sits at the bottom edge again, with a soft fade above it. Whats-New-De: Die Navigationsleiste sitzt wieder am unteren Rand, mit einem sanften Übergang darüber. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-08 00:04:18 +01:00
// Room at the end for the navigation bar and its fade at the foot.
padding: EdgeInsets.fromLTRB(
12,
12,
12,
feat(learn,todo,train,meditate,ui): the navigation bar flush with the foot, a fade above it Below medium windows the frame's bar is Material 3 Expressive's again, flush with the window's foot (decided 7 Nov 2026 by the developer): the theme's NavigationBar across the whole width, 64 dp in its own colour, running on beneath the system's bar as Material's does. Right above it a fade 32 dp high, from the background of the screen in view (the ScreenTint's, the theme's surface before a screen claims one) made see-through to that background, so what scrolls on beneath the bar fades out rather than being cut off; taps pass through it. The rail of wider windows stays as it was. halkyon_ui's FloatingNavigationBar becomes FlushNavigationBar, its side margin, lift and rounded card gone. Its coverOf is now the whole room content leaves at its end, the system's bar included (the body's bottom padding: bar, fade and system's bar inside the frame, the system's bar alone outside it), and floating buttons rise by buttonLiftOf, the same without the system's bar, which a Scaffold keeps them clear of itself. Lists, Todo's hour grid and the Plan's sheet keep using coverOf; the Profile's list no longer adds the system's bar a second time. Whats-New: The navigation bar sits at the bottom edge again, with a soft fade above it. Whats-New-De: Die Navigationsleiste sitzt wieder am unteren Rand, mit einem sanften Übergang darüber. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-08 00:04:18 +01:00
12 + FlushNavigationBar.coverOf(context),
),
children: [
SectionCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
l10n.profileAccount,
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 4),
Text(l10n.profileIdentified),
const _SignInWays(),
],
),
),
for (final section in sections) ...[
const SizedBox(height: 12),
SectionCard(child: section),
],
const SizedBox(height: 12),
const SectionCard(child: PublicProfileSection()),
feat(base,app,learn,todo,train,meditate): agent accounts with tokens ADR 0044's step 6a (D42, D43, D45): accounts for programs, such as AI assistants, that an identified person makes from the Profile. halkyon_base keeps them on the instance's register, which its members ask: an agent is an account (agent_account: its owner, its name, its public keys, set by itself once) with one token (agent_token: 32 random bytes, kept as their SHA-256 alone, shown once). agents.create, mine, newToken, revoke, delete and setKeys serve its owner; agentSignIn.signIn exchanges the token for an ordinary server-side session of a day, with the scopes identified and agent, at most 60 sign-ins an hour from a network. Revoking a token or making a new one ends the agent's sessions; a token unused for 90 days lapses in every service's pruning. Up to 5 agents a person, where the operator didn't switch them off (AGENTS=off; said on the privacy page and in instance.basics). An agent makes no agents, creates or owns no shared space, is invited and raised as a Viewer alone, is never handed a space on, is named no operator and granted no assistants; each refusal has its test. Deleting a person deletes their agents first; an agent's public profile names whose agent it is. In the apps, every Profile has an Agents card (halkyon_app's AgentsSection): made with a name and a handle, its token shown once to copy, a new token, the token taken back, deleted. Learn's Share sheet marks an agent among the members and offers it no role above Viewer. The migrations, the module's and each host's (Learn, Meditate, Todo, Train), are additive alone: CREATE TABLE "agent_account" with a unique index on "agentId" (one row an agent account) and one on "ownerId" (a person's agents, and deleting them with the person), and CREATE TABLE "agent_token" with unique indexes on "agentId" (one token an agent) and "tokenHash" (the sign-in finds the token by its hash). No existing table is touched, so the server before the deploy keeps working on the migrated database. Whats-New: Make agents in your Profile: accounts for programs such as AI assistants, which sign in with a token and see only what you share with them. Whats-New-De: Leg in deinem Profil Agenten an: Konten für Programme wie KI-Assistenten, die sich mit einem Token anmelden und nur sehen, was du mit ihnen teilst. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-11 19:55:27 +01:00
// The person's agents (Halkyon's ADR 0044, D45), where the
// instance offers them: a card of its own, or nothing.
const AgentsSection(),
],
),
),
);
}
}
/// How the person signs in: an email address, and SimpleLogin (Halkyon
/// Learn's ADR 0020, D21), with the password and authenticators beneath.
class const _SignInWays() extends StatelessWidget {
@override
Widget build(BuildContext context) {
final l10n = HalkyonAppLocalizations.of(context);
final theme = Theme.of(context);
final ways = context.watch<SignInWaysCubit>().state;
Widget way(String label, String linkedAs) => ListTile(
contentPadding: EdgeInsets.zero,
title: Text(label),
subtitle: Text(linkedAs, maxLines: 1, overflow: TextOverflow.ellipsis),
trailing: Icon(LucideIcons.circleCheck, color: theme.colorScheme.primary),
);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 16),
Text(l10n.profileSignInWays, style: theme.textTheme.titleSmall),
if (ways.ways.email)
way(l10n.profileWayEmail, ways.emailAddress ?? l10n.profileWayLinked),
// SimpleLogin (ADR 0020, D21): once added, one more way in here.
const SimpleLoginSection(gapAbove: 16),
const SizedBox(height: 16),
// The password and authenticators, and setting them up (ADR 0017),
// which brings the address.
const AccountSecuritySection(),
],
);
}
}