feat(app): dark mode uses a near-black gray with lighter layers instead of pure black
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import '../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -39,10 +40,15 @@ class MyApp extends StatelessWidget {
|
||||
final router = routerConfig;
|
||||
if (cupertino ?? _platformIsCupertino) {
|
||||
if (router != null) {
|
||||
return CupertinoApp.router(title: 'Pipelines', routerConfig: router);
|
||||
return CupertinoApp.router(
|
||||
title: 'Pipelines',
|
||||
theme: appCupertinoTheme,
|
||||
routerConfig: router,
|
||||
);
|
||||
}
|
||||
return CupertinoApp(
|
||||
title: 'Pipelines',
|
||||
theme: appCupertinoTheme,
|
||||
home: AdaptiveShell(
|
||||
destinationBodies: destinationBodies,
|
||||
cupertino: true,
|
||||
@@ -54,16 +60,16 @@ class MyApp extends StatelessWidget {
|
||||
if (router != null) {
|
||||
return MaterialApp.router(
|
||||
title: 'Pipelines',
|
||||
theme: ThemeData(),
|
||||
darkTheme: ThemeData(brightness: Brightness.dark),
|
||||
theme: appLightTheme(),
|
||||
darkTheme: appDarkTheme(),
|
||||
themeMode: ThemeMode.system,
|
||||
routerConfig: router,
|
||||
);
|
||||
}
|
||||
return MaterialApp(
|
||||
title: 'Pipelines',
|
||||
theme: ThemeData(),
|
||||
darkTheme: ThemeData(brightness: Brightness.dark),
|
||||
theme: appLightTheme(),
|
||||
darkTheme: appDarkTheme(),
|
||||
themeMode: ThemeMode.system,
|
||||
home: AdaptiveShell(
|
||||
destinationBodies: destinationBodies,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -42,6 +43,7 @@ class ArtifactDocumentSection extends StatelessWidget {
|
||||
}
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
header: Semantics(
|
||||
container: true,
|
||||
header: true,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -390,7 +391,7 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
return CupertinoPageScaffold(
|
||||
// Sections paint the grouped background; the page must match it or a
|
||||
// white seam shows below the last section in light mode.
|
||||
backgroundColor: CupertinoColors.systemGroupedBackground,
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
navigationBar: const CupertinoNavigationBar(
|
||||
middle: Text(artifactGalleryTitle),
|
||||
),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import '../../../ui/input/arrow_key_pager.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
@@ -248,7 +249,7 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
);
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: CupertinoColors.systemGroupedBackground,
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text(title, overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
@@ -105,6 +106,7 @@ class CupertinoNeedsYouSheet extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
for (final entry in rows)
|
||||
_AttentionRow(
|
||||
@@ -117,6 +119,7 @@ class CupertinoNeedsYouSheet extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
CupertinoListTile(
|
||||
key: attentionClearAllKey,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@@ -75,6 +76,7 @@ class ChatBackgroundTaskDetail extends StatelessWidget {
|
||||
);
|
||||
if (cupertino) {
|
||||
return CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [Padding(padding: const EdgeInsets.all(12), child: content)],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -223,6 +224,7 @@ class ChatPermissionCard extends StatelessWidget {
|
||||
);
|
||||
|
||||
Widget _cupertino(BuildContext context) => CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
// As the Material card: the transcript row owns the horizontal inset, so
|
||||
// the card lines up with the message bubbles.
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -136,6 +137,7 @@ class _ChatQuestionCardState extends State<ChatQuestionCard> {
|
||||
: body;
|
||||
if (cupertino) {
|
||||
return CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
// As the Material card: the transcript row owns the horizontal inset,
|
||||
// so the card lines up with the message bubbles.
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
@@ -165,10 +167,7 @@ class _ChatQuestionCardState extends State<ChatQuestionCard> {
|
||||
: '${widget.form['title']}'.trim(),
|
||||
style: chatCardTitleStyle(context, cupertino),
|
||||
),
|
||||
Text(
|
||||
_statusLine(),
|
||||
style: chatCardSecondaryStyle(context, cupertino),
|
||||
),
|
||||
Text(_statusLine(), style: chatCardSecondaryStyle(context, cupertino)),
|
||||
if (error.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
@@ -229,5 +228,4 @@ class _ChatQuestionCardState extends State<ChatQuestionCard> {
|
||||
_fields.every((field) => '${field['type'] ?? ''}' == 'external');
|
||||
return allExternal ? chatQuestionConfirm : chatQuestionSubmit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -156,6 +157,7 @@ class ChatCupertinoMessage extends StatelessWidget {
|
||||
container: true,
|
||||
explicitChildNodes: true,
|
||||
child: CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../../ui/theme/app_theme.dart';
|
||||
import '../../../../ui/layout/section_heading.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
@@ -62,6 +63,7 @@ class CupertinoSessionList extends StatelessWidget {
|
||||
return [
|
||||
for (final group in groups)
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
// Styled as a section divider, not as another chat row.
|
||||
header: Builder(
|
||||
builder: (context) => Text(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
import '../pipeline_filter.dart';
|
||||
@@ -31,6 +32,7 @@ class PipelineFilterCupertinoBody extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
header: const Text('RUNS'),
|
||||
children: [
|
||||
for (final presence in RunPresence.values)
|
||||
@@ -42,6 +44,7 @@ class PipelineFilterCupertinoBody extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
header: const Text('LAST RUN STATUS'),
|
||||
children: [
|
||||
for (final status in runStatusFilters)
|
||||
@@ -61,6 +64,7 @@ class PipelineFilterCupertinoBody extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
header: const Text('SCHEDULING'),
|
||||
footer: const Text('Configured schedules, including paused.'),
|
||||
children: [
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@@ -215,6 +216,7 @@ class PipelineListPanel extends StatelessWidget {
|
||||
key: const Key('pipeline-list'),
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
for (final pipeline in items)
|
||||
CupertinoListTile(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -124,6 +125,7 @@ class PipelineSummaryView extends StatelessWidget {
|
||||
];
|
||||
if (useCupertinoControls(context)) {
|
||||
return CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
header: const Text('VERSIONS'),
|
||||
children: rows,
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -57,6 +58,7 @@ Widget runDetailSummaryTab({
|
||||
SliverToBoxAdapter(
|
||||
child: cupertino
|
||||
? CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [_summaryFacts(context, facts, cupertino: true)],
|
||||
)
|
||||
: _summaryFacts(context, facts, cupertino: false),
|
||||
@@ -198,6 +200,7 @@ Widget runDetailFieldTab({
|
||||
key: Key('run-detail-tab-body-$tabKey'),
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [Padding(padding: const EdgeInsets.all(16), child: body)],
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -53,6 +54,7 @@ class RunTimelineList extends StatelessWidget {
|
||||
key: const Key('run-detail-tab-body-timeline'),
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
header: const Text('Timeline'),
|
||||
children: rows,
|
||||
),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -110,6 +111,7 @@ class _RunVisitSessionState extends State<RunVisitSession> {
|
||||
key: const Key('run-visit-body-session'),
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 16),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
@@ -61,6 +62,7 @@ class CupertinoSearchBody extends StatelessWidget {
|
||||
return [
|
||||
SliverToBoxAdapter(
|
||||
child: CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
for (final hit in controller.shownResults)
|
||||
_CupertinoResult(hit: hit, query: query, onOpen: onOpen),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -200,6 +201,7 @@ class SettingsCard extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
if (usesCupertinoControls(context)) {
|
||||
return CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
margin: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -21,6 +22,7 @@ class SettingsSchedulesSection extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
if (usesCupertinoControls(context)) {
|
||||
return CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
margin: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
CupertinoListTile(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -22,6 +23,7 @@ class SettingsTemplatesSection extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
if (usesCupertinoControls(context)) {
|
||||
return CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
margin: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
CupertinoListTile(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -115,6 +116,7 @@ class TemplateGallery extends StatelessWidget {
|
||||
key: templatesGalleryKey,
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
for (final entry in templates)
|
||||
CupertinoListTile(
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../adaptive/host.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../motion/motion.dart';
|
||||
import 'section_heading.dart';
|
||||
|
||||
@@ -230,7 +231,7 @@ class StickyBar extends StatelessWidget {
|
||||
return PinnedHeaderSliver(
|
||||
child: ColoredBox(
|
||||
color: cupertino
|
||||
? CupertinoColors.systemGroupedBackground.resolveFrom(context)
|
||||
? AppColors.groupedBackground.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
child: child,
|
||||
),
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// The app's backgrounds. Dark mode uses a near-black gray rather than pure
|
||||
/// black, so cards, sections and bars read as layers above the page.
|
||||
abstract final class AppColors {
|
||||
/// A page.
|
||||
static const background = CupertinoDynamicColor.withBrightness(
|
||||
color: Color(0xFFFFFFFF),
|
||||
darkColor: Color(0xFF141416),
|
||||
);
|
||||
|
||||
/// Behind grouped sections (Settings-style lists).
|
||||
static const groupedBackground = CupertinoDynamicColor.withBrightness(
|
||||
color: Color(0xFFF2F2F7),
|
||||
darkColor: Color(0xFF141416),
|
||||
);
|
||||
|
||||
/// Bars over the page.
|
||||
static const bar = CupertinoDynamicColor.withBrightness(
|
||||
color: Color(0xF0F9F9F9),
|
||||
darkColor: Color(0xF01C1C1F),
|
||||
);
|
||||
}
|
||||
|
||||
const _seed = Color(0xFF6750A4);
|
||||
|
||||
ThemeData appLightTheme() =>
|
||||
ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: _seed));
|
||||
|
||||
/// Material's dark scheme with gray surfaces stepping up from the page.
|
||||
ThemeData appDarkTheme() {
|
||||
final scheme =
|
||||
ColorScheme.fromSeed(
|
||||
seedColor: _seed,
|
||||
brightness: Brightness.dark,
|
||||
).copyWith(
|
||||
surface: const Color(0xFF141416),
|
||||
surfaceDim: const Color(0xFF141416),
|
||||
surfaceBright: const Color(0xFF3A3B40),
|
||||
surfaceContainerLowest: const Color(0xFF0F0F11),
|
||||
surfaceContainerLow: const Color(0xFF1B1C1F),
|
||||
surfaceContainer: const Color(0xFF202125),
|
||||
surfaceContainerHigh: const Color(0xFF27282C),
|
||||
surfaceContainerHighest: const Color(0xFF303136),
|
||||
);
|
||||
return ThemeData(
|
||||
colorScheme: scheme,
|
||||
scaffoldBackgroundColor: scheme.surface,
|
||||
);
|
||||
}
|
||||
|
||||
const appCupertinoTheme = CupertinoThemeData(
|
||||
scaffoldBackgroundColor: AppColors.background,
|
||||
barBackgroundColor: AppColors.bar,
|
||||
);
|
||||
@@ -0,0 +1,28 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||
|
||||
void main() {
|
||||
test('dark mode is a near-black gray, with lighter layers above it', () {
|
||||
final scheme = appDarkTheme().colorScheme;
|
||||
expect(scheme.surface, const Color(0xFF141416));
|
||||
expect(appDarkTheme().scaffoldBackgroundColor, scheme.surface);
|
||||
final steps = [
|
||||
scheme.surface,
|
||||
scheme.surfaceContainerLow,
|
||||
scheme.surfaceContainer,
|
||||
scheme.surfaceContainerHigh,
|
||||
scheme.surfaceContainerHighest,
|
||||
].map((color) => color.computeLuminance()).toList();
|
||||
for (var i = 1; i < steps.length; i++) {
|
||||
expect(steps[i], greaterThan(steps[i - 1]));
|
||||
}
|
||||
});
|
||||
|
||||
test('the Cupertino page is gray in dark mode and unchanged in light', () {
|
||||
expect(AppColors.background.darkColor, const Color(0xFF141416));
|
||||
expect(AppColors.background.color, const Color(0xFFFFFFFF));
|
||||
expect(appCupertinoTheme.scaffoldBackgroundColor, AppColors.background);
|
||||
expect(AppColors.groupedBackground.darkColor, isNot(CupertinoColors.black));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user