Files
openchamber-android-native/lib/main.dart
T
blumia e646130d1f feat: a settings page, a server footer in the sidebar, and follow-up behaviour
- The sidebar's server switch moves to a footer bar: the connected server's
  name on the left (tap for the server sheet) and a settings key on the
  right, matching the first-party phone layout.
- Settings has three groups: 外观 (theme mode and seed colour, stored on the
  device only in shared_preferences), 聊天 (the server's followUpBehavior:
  steer or queue) and a 宠物 placeholder. The app theme now reads the seed
  and mode.
- The chat's short send while a turn runs uses the configured follow-up
  behaviour; the long-press sheet offers both and marks the default. The
  value is read from GET /api/config/settings?surface=mobile on connect, on
  resume and when the page opens, and written back with PUT.
- Tests: settings page groups and choice, sidebar footer naming the server
  and opening settings, follow-up normalization.
- 0.3.17 (317).
2026-11-21 19:17:22 +08:00

75 lines
1.9 KiB
Dart

import 'package:flutter/material.dart';
import 'appearance_prefs.dart';
import 'screens/home_screen.dart';
import 'screens/servers_screen.dart';
import 'state.dart';
void main() {
runApp(const OpenChamberApp());
}
class OpenChamberApp extends StatefulWidget {
const OpenChamberApp({super.key});
@override
State<OpenChamberApp> createState() => _OpenChamberAppState();
}
class _OpenChamberAppState extends State<OpenChamberApp>
with WidgetsBindingObserver {
final AppState app = AppState();
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
app.init();
AppearancePrefs.instance.ensureLoaded();
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
// The socket often dies while the app sits in the background; nothing
// reports it, so reopen the stream and refresh the open chat on return.
if (state == AppLifecycleState.resumed) app.onResumed();
}
@override
Widget build(BuildContext context) {
final look = AppearancePrefs.instance;
return ListenableBuilder(
listenable: Listenable.merge([app, look]),
builder: (context, _) {
final home = app.client == null
? ServersScreen(app: app)
: HomeScreen(app: app);
return MaterialApp(
title: 'OpenChamber',
themeMode: look.themeMode,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: look.seedColor,
brightness: Brightness.light,
),
useMaterial3: true,
),
darkTheme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: look.seedColor,
brightness: Brightness.dark,
),
useMaterial3: true,
),
home: home,
);
},
);
}
}