118 lines
2.9 KiB
Dart
118 lines
2.9 KiB
Dart
import "dart:io";
|
|
|
|
import "package:flutter/foundation.dart";
|
|
import "package:google_fonts/google_fonts.dart";
|
|
import "package:provider/provider.dart";
|
|
import "package:shadcn_flutter/shadcn_flutter.dart";
|
|
|
|
import "ana_text.dart";
|
|
|
|
import "../../../src/project_store.dart";
|
|
import "../../providers/home_coordinator.dart";
|
|
import "../../providers/projects_provider.dart";
|
|
|
|
|
|
class AppHeader extends StatelessWidget {
|
|
const AppHeader({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final coordinator = context.read<HomeCoordinator>();
|
|
final selectedProject = context.watch<ProjectsProvider>().selectedProject;
|
|
|
|
final isWindows = !kIsWeb && defaultTargetPlatform == TargetPlatform.windows;
|
|
|
|
return Container(
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: theme.colorScheme.background,
|
|
border: Border(
|
|
bottom: BorderSide(color: theme.colorScheme.border, width: 1),
|
|
),
|
|
),
|
|
child: IntrinsicHeight(
|
|
child: Row(
|
|
children: [
|
|
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 12, top: 4, bottom: 4),
|
|
child: _AgencyMenuBar(coordinator: coordinator),
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
_ProjectNameBox(project: selectedProject),
|
|
|
|
if (isWindows)
|
|
const Gap(6)
|
|
else
|
|
const Gap(64),
|
|
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
class _AgencyMenuBar extends StatelessWidget {
|
|
final HomeCoordinator coordinator;
|
|
|
|
const _AgencyMenuBar({required this.coordinator});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Menubar(
|
|
border: false,
|
|
children: [
|
|
|
|
MenuButton(
|
|
subMenu: [
|
|
MenuButton(
|
|
leading: const Icon(LucideIcons.squarePen).iconSmall,
|
|
onPressed: (_) => coordinator.createNewChat(),
|
|
child: const Text("New Chat"),
|
|
),
|
|
MenuButton(
|
|
leading: const Icon(LucideIcons.folderPlus).iconSmall,
|
|
onPressed: (_) => coordinator.pickProjectDirectory(),
|
|
child: const Text("New Project"),
|
|
),
|
|
],
|
|
child: const Text("File"),
|
|
),
|
|
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
class _ProjectNameBox extends StatelessWidget {
|
|
final ProjectRecord? project;
|
|
|
|
const _ProjectNameBox({required this.project});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final label = project?.name ?? "No project";
|
|
|
|
final textStyle = GoogleFonts.ibmPlexMono(
|
|
fontSize: 11,
|
|
height: 1,
|
|
fontWeight: FontWeight.w600,
|
|
color: theme.colorScheme.mutedForeground,
|
|
);
|
|
|
|
return Container(
|
|
color: theme.colorScheme.border,
|
|
constraints: const BoxConstraints(minWidth: 100),
|
|
alignment: Alignment.center,
|
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
|
child: AnaText(label, style: textStyle),
|
|
);
|
|
}
|
|
}
|