feat: new ui (#1455)

This commit is contained in:
Levi authored and GitHub committed 2026-09-05 19:53:41 +08:00
1 parent 3be8db664c
commit 177c225f16
742 files changed
+59951 -5934

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -0,0 +1,152 @@
import 'package:flutter/material.dart' show Colors, Icons;
import 'package:flutter/widgets.dart';
import '../../../../core/window/app_window_chrome.dart';
import '../../../../shared/theme/app_design_tokens.dart';
import '../../../../shared/theme/app_palette.dart';
import '../../../../l10n/l10n.dart';
import '../../../tasks/domain/task_record.dart';
import '../../../tasks/presentation/widgets/speed_monitor_card.dart';
enum TaskFilter { all, downloading, completed, paused, failed }
class FilterSidebar extends StatelessWidget {
const FilterSidebar({super.key, required this.activeFilter, required this.onFilterSelected, required this.tasks});
final TaskFilter activeFilter;
final ValueChanged<TaskFilter> onFilterSelected;
final List<TaskRecord> tasks;
@override
Widget build(BuildContext context) {
final palette = AppPalette.of(context);
final titleStyle = TextStyle(
color: palette.textMuted,
fontSize: 12,
fontWeight: FontWeight.w700,
letterSpacing: 2.4,
);
return Container(
width: AppDesignTokens.filterSidebarWidth,
color: palette.sideBg,
padding: EdgeInsets.only(top: AppWindowChrome.reservesHeaderInset ? AppDesignTokens.windowHeaderHeight : 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: AppDesignTokens.contentHeaderHeight,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Align(
alignment: Alignment.centerLeft,
child: Text(context.l10n.filters.toUpperCase(), style: titleStyle),
),
),
),
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
children: [
_FilterItem(
label: context.l10n.allTasks,
icon: Icons.grid_view_rounded,
active: activeFilter == TaskFilter.all,
count: tasks.length.toString(),
onTap: () => onFilterSelected(TaskFilter.all),
),
_FilterItem(
label: context.l10n.downloading,
icon: Icons.south_rounded,
active: activeFilter == TaskFilter.downloading,
count: _count(TaskStatus.downloading).toString(),
onTap: () => onFilterSelected(TaskFilter.downloading),
),
_FilterItem(
label: context.l10n.completed,
icon: Icons.check_circle_outline,
active: activeFilter == TaskFilter.completed,
onTap: () => onFilterSelected(TaskFilter.completed),
),
_FilterItem(
label: context.l10n.pause,
icon: Icons.pause_circle_outline,
active: activeFilter == TaskFilter.paused,
onTap: () => onFilterSelected(TaskFilter.paused),
),
_FilterItem(
label: context.l10n.failed,
icon: Icons.error_outline,
active: activeFilter == TaskFilter.failed,
onTap: () => onFilterSelected(TaskFilter.failed),
),
],
),
),
const Spacer(),
const SpeedMonitorCard(),
],
),
);
}
int _count(TaskStatus status) {
return tasks.where((task) => task.status == status).length;
}
}
class _FilterItem extends StatelessWidget {
const _FilterItem({required this.label, required this.icon, required this.active, required this.onTap, this.count});
final String label;
final IconData icon;
final bool active;
final VoidCallback onTap;
final String? count;
@override
Widget build(BuildContext context) {
final palette = AppPalette.of(context);
return GestureDetector(
onTap: onTap,
child: Container(
margin: const EdgeInsets.only(bottom: 4),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
decoration: BoxDecoration(
color: active ? palette.itemActiveBg : Colors.transparent,
borderRadius: BorderRadius.circular(AppDesignTokens.controlRadius),
),
child: Row(
children: [
Icon(icon, size: 16, color: active ? palette.textPrimary : palette.textSecondary),
const SizedBox(width: 12),
Expanded(
child: Text(
label,
style: TextStyle(
color: active ? palette.textPrimary : palette.textSecondary,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
if (count != null)
Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(color: palette.cardHoverBg, borderRadius: BorderRadius.circular(4)),
child: Text(
count!,
style: TextStyle(
color: active ? palette.textPrimary : palette.textSecondary,
fontSize: 10,
fontWeight: FontWeight.w600,
),
),
),
],
),
),
);
}
}
@@ -0,0 +1,6 @@
const double kWindowTaskbarHeight = 30;
const double kColumnHeaderContentHeight = 30;
const double kColumnHeaderTotalHeight = kWindowTaskbarHeight + kColumnHeaderContentHeight;
const double kContentTopBarHeight = 40;
const double kSidebarItemHeight = 40;
const double kSidebarItemGap = 3;
@@ -0,0 +1,198 @@
import 'package:flutter/material.dart' show Icons;
import 'package:flutter/widgets.dart';
import 'package:go_router/go_router.dart';
import '../../../../core/window/app_window_chrome.dart';
import '../../../../shared/theme/app_design_tokens.dart';
import '../../../../shared/theme/app_palette.dart';
import '../../../../shared/widgets/app_tooltip.dart';
import '../../../../shared/widgets/gopeed_app_mark.dart';
import '../../../../l10n/l10n.dart';
enum RailSection { tasks, extensions, settings }
class PrimaryRail extends StatelessWidget {
const PrimaryRail({super.key, this.activeSection = RailSection.tasks});
final RailSection activeSection;
@override
Widget build(BuildContext context) {
final palette = AppPalette.of(context);
return Container(
width: AppDesignTokens.railWidth,
color: palette.railBg,
padding: EdgeInsets.only(top: AppWindowChrome.reservesHeaderInset ? AppDesignTokens.windowHeaderHeight : 0),
child: Column(
children: [
SizedBox(
height: AppDesignTokens.contentHeaderHeight,
child: const Center(child: GopeedAppMark(key: ValueKey('primary-rail-app-mark'))),
),
const SizedBox(height: AppDesignTokens.space8),
_RailItem(
key: const ValueKey('primary-rail-tasks-item'),
icon: Icons.download_rounded,
label: context.l10n.task,
active: activeSection == RailSection.tasks,
onTap: () => context.go('/'),
),
const SizedBox(height: 28),
_RailItem(
icon: Icons.extension_outlined,
label: context.l10n.extensions,
active: activeSection == RailSection.extensions,
onTap: () => context.go('/extensions'),
),
const SizedBox(height: 28),
_RailItem(
icon: Icons.settings_outlined,
label: context.l10n.setting,
active: activeSection == RailSection.settings,
onTap: () => context.go('/settings'),
),
const Spacer(),
],
),
);
}
}
class PrimaryBottomNavigation extends StatelessWidget {
const PrimaryBottomNavigation({super.key, this.activeSection = RailSection.tasks});
final RailSection activeSection;
@override
Widget build(BuildContext context) {
final palette = AppPalette.of(context);
return Container(
decoration: BoxDecoration(
color: palette.railBg,
border: Border(top: BorderSide(color: palette.border)),
),
child: SafeArea(
top: false,
child: SizedBox(
height: 64,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Row(
children: [
Expanded(
child: _BottomNavItem(
icon: Icons.download_rounded,
label: context.l10n.task,
active: activeSection == RailSection.tasks,
onTap: () => context.go('/'),
),
),
Expanded(
child: _BottomNavItem(
icon: Icons.extension_outlined,
label: context.l10n.extensions,
active: activeSection == RailSection.extensions,
onTap: () => context.go('/extensions'),
),
),
Expanded(
child: _BottomNavItem(
icon: Icons.settings_outlined,
label: context.l10n.setting,
active: activeSection == RailSection.settings,
onTap: () => context.go('/settings'),
),
),
],
),
),
),
),
);
}
}
class _RailItem extends StatelessWidget {
const _RailItem({super.key, required this.icon, required this.label, required this.onTap, this.active = false});
final IconData icon;
final String label;
final VoidCallback onTap;
final bool active;
@override
Widget build(BuildContext context) {
final palette = AppPalette.of(context);
return AppTooltip(
message: label,
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
child: SizedBox(
width: AppDesignTokens.railWidth,
height: 24,
child: Stack(
children: [
if (active)
Align(
alignment: Alignment.centerLeft,
child: Container(
key: const ValueKey('primary-rail-active-indicator'),
width: 2,
height: 24,
color: palette.textPrimary,
),
),
Center(child: Icon(icon, size: 18, color: active ? palette.textPrimary : palette.textMuted)),
],
),
),
),
),
);
}
}
class _BottomNavItem extends StatelessWidget {
const _BottomNavItem({required this.icon, required this.label, required this.onTap, this.active = false});
final IconData icon;
final String label;
final VoidCallback onTap;
final bool active;
@override
Widget build(BuildContext context) {
final palette = AppPalette.of(context);
return MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
child: SizedBox(
height: 54,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(icon, size: 19, color: active ? palette.textPrimary : palette.textMuted),
const SizedBox(height: 4),
Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: active ? palette.textPrimary : palette.textMuted,
fontSize: 10,
fontWeight: active ? FontWeight.w700 : FontWeight.w600,
),
),
],
),
),
),
);
}
}
@@ -0,0 +1,161 @@
import 'package:flutter/material.dart' show Colors, Icons;
import 'package:flutter/widgets.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart' as shad;
import '../../../../shared/theme/app_design_tokens.dart';
import '../../../../shared/theme/app_palette.dart';
import '../../../../shared/widgets/app_primary_button.dart';
import '../../../../l10n/l10n.dart';
class TasksTopBar extends StatelessWidget {
const TasksTopBar({
super.key,
required this.searchController,
required this.onAddTask,
required this.batchMode,
required this.selectedBatchCount,
required this.canPauseSelected,
required this.canResumeSelected,
required this.onToggleBatchMode,
required this.onPauseSelected,
required this.onResumeSelected,
required this.onDeleteSelected,
});
final TextEditingController searchController;
final VoidCallback onAddTask;
final bool batchMode;
final int selectedBatchCount;
final bool canPauseSelected;
final bool canResumeSelected;
final VoidCallback onToggleBatchMode;
final VoidCallback onPauseSelected;
final VoidCallback onResumeSelected;
final VoidCallback onDeleteSelected;
@override
Widget build(BuildContext context) {
final palette = AppPalette.of(context);
final headerBorder = palette.border;
return SizedBox(
height: AppDesignTokens.contentHeaderHeight,
child: Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.only(left: 32, right: 32),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Align(
alignment: Alignment.centerLeft,
child: ConstrainedBox(
key: const ValueKey('tasks-search-field-container'),
constraints: const BoxConstraints(maxWidth: 240),
child: _SearchField(controller: searchController, palette: palette, borderColor: headerBorder),
),
),
),
const SizedBox(width: 16),
ConstrainedBox(
key: const ValueKey('tasks-create-button-container'),
constraints: const BoxConstraints(maxWidth: 190),
child: _AddTaskButton(onPressed: onAddTask),
),
const SizedBox(width: 16),
Row(
key: const ValueKey('tasks-top-action-buttons'),
crossAxisAlignment: CrossAxisAlignment.center,
children: [
_ActionIconButton(
icon: Icons.pause_outlined,
onPressed: !batchMode || canPauseSelected ? onPauseSelected : null,
),
const SizedBox(width: 4),
_ActionIconButton(
icon: Icons.play_arrow_outlined,
onPressed: !batchMode || canResumeSelected ? onResumeSelected : null,
),
const SizedBox(width: 4),
_ActionIconButton(
icon: Icons.delete_outline,
onPressed: selectedBatchCount > 0 ? onDeleteSelected : null,
),
const SizedBox(width: 4),
_ActionIconButton(icon: Icons.checklist_rtl_outlined, onPressed: onToggleBatchMode),
],
),
],
),
),
),
);
}
}
class _SearchField extends StatelessWidget {
const _SearchField({required this.controller, required this.palette, required this.borderColor});
final TextEditingController controller;
final AppPalette palette;
final Color borderColor;
@override
Widget build(BuildContext context) {
return shad.ComponentTheme<shad.FocusOutlineTheme>(
data: const shad.FocusOutlineTheme(
align: 0,
border: Border.fromBorderSide(BorderSide(color: Colors.transparent, width: 0)),
),
child: SizedBox(
height: 40,
child: shad.TextField(
controller: controller,
style: TextStyle(color: palette.textPrimary, fontSize: 14, height: 1),
placeholder: Text(
context.l10n.searchDownloads,
style: TextStyle(color: palette.searchHint, fontSize: 14, height: 1),
),
features: [shad.InputFeature.leading(Icon(Icons.search_rounded, size: 14, color: palette.textMuted))],
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 0),
decoration: BoxDecoration(
color: palette.inputBg,
borderRadius: BorderRadius.circular(4),
border: Border.all(color: borderColor),
),
),
),
);
}
}
class _AddTaskButton extends StatelessWidget {
const _AddTaskButton({required this.onPressed});
final VoidCallback onPressed;
@override
Widget build(BuildContext context) {
return AppPrimaryButton(
onPressed: onPressed,
leading: const Icon(Icons.add),
child: Text(context.l10n.create, maxLines: 1, overflow: TextOverflow.ellipsis),
);
}
}
class _ActionIconButton extends StatelessWidget {
const _ActionIconButton({required this.icon, required this.onPressed});
final IconData icon;
final VoidCallback? onPressed;
@override
Widget build(BuildContext context) {
return SizedBox.square(
dimension: 30,
child: shad.IconButton.outline(size: shad.ButtonSize.xSmall, onPressed: onPressed, icon: Icon(icon, size: 18)),
);
}
}
@@ -0,0 +1,49 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:window_manager/window_manager.dart';
import '../../../../shared/theme/app_palette.dart';
import '../../../../shared/widgets/window/desktop_window_header.dart';
import 'layout_constants.dart';
class WindowChromeOverlay extends StatelessWidget {
const WindowChromeOverlay({super.key});
@override
Widget build(BuildContext context) {
final isWindowsDesktop = !kIsWeb && defaultTargetPlatform == TargetPlatform.windows;
return SizedBox(
height: kWindowTaskbarHeight,
child: Row(
children: [
SizedBox(
width: 64 + 264,
child: isWindowsDesktop ? const DragToMoveArea(child: SizedBox.expand()) : const SizedBox.shrink(),
),
const Expanded(child: _WindowTaskbar()),
],
),
);
}
}
class _WindowTaskbar extends StatelessWidget {
const _WindowTaskbar();
@override
Widget build(BuildContext context) {
final isWindowsDesktop = !kIsWeb && defaultTargetPlatform == TargetPlatform.windows;
final palette = AppPalette.of(context);
return Container(
color: palette.bg,
child: Row(
children: [
Expanded(child: isWindowsDesktop ? const DragToMoveArea(child: SizedBox.expand()) : const SizedBox.shrink()),
if (isWindowsDesktop) const WindowCaptionControls(),
],
),
);
}
}