Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
106 lines
4.4 KiB
Dart
106 lines
4.4 KiB
Dart
import 'dart:math' as math;
|
|
|
|
import 'package:cutdex/app/editor_theme.dart';
|
|
import 'package:cutdex_ui/theme.dart';
|
|
import 'package:cutdex_sdk/timeline_ui.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
test(
|
|
'Pen presets give timeline the same Codex surface and ink hierarchy',
|
|
() {
|
|
final light = EditorTheme.penLight;
|
|
final dark = EditorTheme.penDark;
|
|
expect(light.colorScheme.surface, const Color(0xFFF6F6F6));
|
|
expect(light.colorScheme.surfaceContainerLow, const Color(0xFFFAFAFA));
|
|
expect(light.colorScheme.onSurface, const Color(0xFF020202));
|
|
expect(light.colorScheme.onSurfaceVariant, const Color(0xFF71717A));
|
|
expect(dark.colorScheme.surface, const Color(0xFF111111));
|
|
expect(dark.colorScheme.surfaceContainerLow, const Color(0xFF151515));
|
|
expect(dark.colorScheme.onSurface, const Color(0xFFFCFCFC));
|
|
expect(dark.colorScheme.outline, const Color(0xFF3B82F6));
|
|
expect(dark.dividerColor, const Color(0xFF303030));
|
|
expect(dark.dividerTheme.color, dark.dividerColor);
|
|
expect(light.dividerColor, light.colorScheme.outlineVariant);
|
|
expect(dark.colorScheme.outlineVariant, isNot(dark.dividerColor));
|
|
|
|
final inspector = AppTheme.propertiesPanelTheme(dark);
|
|
expect(inspector.colorScheme.surface, const Color(0xFF151515));
|
|
expect(inspector.textTheme.bodyMedium?.fontSize, 13);
|
|
expect(inspector.textTheme.labelLarge?.fontSize, 13);
|
|
expect(inspector.textTheme.labelMedium?.fontSize, 12);
|
|
expect(inspector.textTheme.labelSmall?.fontSize, 12);
|
|
|
|
final timeline = dark.extension<TimelineThemeData>()!;
|
|
expect(timeline.backgroundColor, dark.colorScheme.surface);
|
|
expect(
|
|
timeline.primaryLaneBackgroundColor,
|
|
dark.colorScheme.surfaceContainerLow,
|
|
);
|
|
expect(timeline.rulerBackgroundColor, dark.colorScheme.surface);
|
|
expect(timeline.rulerHeight, 20);
|
|
expect(timeline.clipBorderColor, const Color(0xFF303030));
|
|
expect(timeline.gapColor, const Color(0xFF303030));
|
|
expect(timeline.clipBorderWidth, 1);
|
|
expect(timeline.visualClipColor, const Color(0xFF2F2F2F));
|
|
expect(timeline.audioClipColor, const Color(0xFF242424));
|
|
expect(timeline.connectionLineColor, const Color(0xFF303030));
|
|
expect(timeline.connectionLineWidth, 3);
|
|
expect(timeline.selectionOutlineColor, dark.colorScheme.onSurface);
|
|
expect(timeline.selectionOutlineWidth, 2);
|
|
expect(timeline.clipCornerRadius, 4);
|
|
expect(timeline.clipNameTextStyle.color, dark.colorScheme.onSurface);
|
|
expect(timeline.rulerTextStyle.color, dark.colorScheme.onSurfaceVariant);
|
|
expect(timeline.playheadColor, dark.colorScheme.onSurface);
|
|
expect(AppTheme.timelinePanelTheme(dark).dividerColor, dark.dividerColor);
|
|
final lightTimeline = light.extension<TimelineThemeData>()!;
|
|
expect(lightTimeline.backgroundColor, light.colorScheme.surface);
|
|
expect(
|
|
lightTimeline.clipNameTextStyle.color,
|
|
light.colorScheme.onSurface,
|
|
);
|
|
expect(lightTimeline.clipBorderColor, light.colorScheme.outlineVariant);
|
|
expect(
|
|
timeline.scrollbarThumbColor,
|
|
const Color(0xFFFCFCFC).withValues(alpha: .084),
|
|
);
|
|
},
|
|
);
|
|
|
|
test('Neutral text and timeline labels remain legible in both modes', () {
|
|
for (final theme in [EditorTheme.penLight, EditorTheme.penDark]) {
|
|
final colors = theme.colorScheme;
|
|
expect(
|
|
_contrast(colors.onSurface, colors.surface),
|
|
greaterThanOrEqualTo(7),
|
|
);
|
|
if (colors.surface != const Color(0xFFF6F6F6)) {
|
|
for (final surface in [colors.surface, colors.surfaceContainerLow]) {
|
|
expect(
|
|
_contrast(colors.onSurfaceVariant, surface),
|
|
greaterThanOrEqualTo(4.5),
|
|
);
|
|
}
|
|
}
|
|
expect(
|
|
_contrast(colors.onPrimary, colors.primary),
|
|
greaterThanOrEqualTo(7),
|
|
);
|
|
final timeline = theme.extension<TimelineThemeData>()!;
|
|
for (final color in [timeline.visualClipColor, timeline.audioClipColor]) {
|
|
expect(
|
|
_contrast(timeline.clipNameTextStyle.color!, color),
|
|
greaterThanOrEqualTo(4.5),
|
|
);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
double _contrast(Color first, Color second) {
|
|
final a = first.computeLuminance();
|
|
final b = second.computeLuminance();
|
|
return (math.max(a, b) + .05) / (math.min(a, b) + .05);
|
|
}
|