Files
openchamber-android-native/lib/main.dart
T
blumia da4bfb6826 feat: add scheduled tasks behind a 全部功能 button
- the sidebar footer gains 全部功能 left of 设置; its page lists the
  features the server offers, planned tasks for now
- 计划任务 follows the web client: a project (or the chats scope) picked
  at the top, then its tasks with schedule, last result, next run, model
  and error; the switch pauses, the menu runs now, edits or deletes
- the editor covers name, prompt, daily/weekly/once/cron schedules
  (Chinese date and time pickers), several times a day, weekdays, cron
  examples, enabled, and either the session defaults or a fixed model
  and agent
- the same /api/projects/:id/scheduled-tasks endpoints the web uses; a
  server without them says so instead of failing silently
- the app now pins zh_CN localizations, so the built-in pickers and
  menus are Chinese too
- bump to 0.5.1
2026-11-26 00:36:27 +08:00

92 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'appearance_prefs.dart';
import 'pets/pet_library.dart';
import 'screens/home_screen.dart';
import 'screens/servers_screen.dart';
import 'state.dart';
import 'version.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// The version goes into every connection's handshake; read it once here so
// nothing waits for it later.
await loadAppVersion();
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();
PetLibrary.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',
// The app speaks Chinese only; this also puts the built-in pieces
// (date and time pickers, text selection menu) in Chinese.
locale: const Locale('zh', 'CN'),
supportedLocales: const [Locale('zh', 'CN'), Locale('en')],
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
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,
);
},
);
}
}