Keep web Material styling and preserve visible installer access URLs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import '../ui/adaptive/platform.dart';
|
||||
import '../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../shell/adaptive_shell.dart';
|
||||
@@ -79,7 +79,5 @@ class MyApp extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
bool get _platformIsCupertino =>
|
||||
defaultTargetPlatform == TargetPlatform.iOS ||
|
||||
defaultTargetPlatform == TargetPlatform.macOS;
|
||||
bool get _platformIsCupertino => prefersCupertino();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../ui/adaptive/platform.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -551,7 +552,5 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
AppDestination.settings => AppRoute.settings,
|
||||
};
|
||||
|
||||
bool get _platformIsCupertino =>
|
||||
defaultTargetPlatform == TargetPlatform.iOS ||
|
||||
defaultTargetPlatform == TargetPlatform.macOS;
|
||||
bool get _platformIsCupertino => prefersCupertino();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../ui/adaptive/platform.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -243,9 +244,7 @@ class _PipelinesRootState extends State<PipelinesRoot> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
bool get _cupertino =>
|
||||
defaultTargetPlatform == TargetPlatform.iOS ||
|
||||
defaultTargetPlatform == TargetPlatform.macOS;
|
||||
bool get _cupertino => prefersCupertino();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
@@ -9,7 +8,8 @@ import '../pipeline_query.dart';
|
||||
/// The one platform decision for this feature. The screen itself receives no
|
||||
/// platform flag, so tests and integration obey Flutter's target platform.
|
||||
bool useCupertinoControls(BuildContext context) =>
|
||||
usesCupertinoHost(context) || defaultTargetPlatform == TargetPlatform.iOS;
|
||||
usesCupertinoHost(context) ||
|
||||
Theme.of(context).platform == TargetPlatform.iOS;
|
||||
|
||||
/// Standard platform activity indicator with an accessible status label.
|
||||
class PipelineProgress extends StatelessWidget {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
/// Browsers use Material consistently, regardless of their host OS.
|
||||
bool prefersCupertino({bool web = kIsWeb, TargetPlatform? platform}) {
|
||||
final target = platform ?? defaultTargetPlatform;
|
||||
return !web &&
|
||||
(target == TargetPlatform.iOS || target == TargetPlatform.macOS);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -26,6 +27,7 @@ abstract final class AppColors {
|
||||
const _seed = Color(0xFF6750A4);
|
||||
|
||||
ThemeData appLightTheme() => ThemeData(
|
||||
platform: kIsWeb ? TargetPlatform.android : null,
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: _seed),
|
||||
pageTransitionsTheme: appPageTransitions,
|
||||
);
|
||||
@@ -94,6 +96,7 @@ ThemeData appDarkTheme() {
|
||||
surfaceContainerHighest: const Color(0xFF303136),
|
||||
);
|
||||
return ThemeData(
|
||||
platform: kIsWeb ? TargetPlatform.android : null,
|
||||
colorScheme: scheme,
|
||||
scaffoldBackgroundColor: scheme.surface,
|
||||
pageTransitionsTheme: appPageTransitions,
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Material styling in browsers
|
||||
|
||||
Web selects the Material app host on every OS. Native iOS/macOS retain
|
||||
Cupertino. Both Material themes set the web platform to Android so adaptive
|
||||
feature controls and route transitions cannot switch back to Apple styling
|
||||
based on the browser's host OS. Pipeline controls now follow the theme too.
|
||||
|
||||
Verification: 18 focused native widget tests and 3 Chrome platform tests passed;
|
||||
Flutter analysis passed; release web build passed. Desktop and phone captures
|
||||
of Pipelines and Settings were rendered against an isolated fixture under
|
||||
/tmp/pipelines-material-web. Existing operator data was not used for tests.
|
||||
|
||||
The Pipelines capture exercises its error state because the runs fixture does
|
||||
not implement list_pipelines; Settings renders the populated fixture data.
|
||||
|
||||
Published with ./install --web after verifying zero executing runs. Rollback:
|
||||
/tmp/pipelines-web-before-material.tar.gz. No shared service restart. Authenticated
|
||||
HTML and main.dart.js returned HTTP 200 on port 8083; served JS matches installed
|
||||
bundle by SHA-256. Native-device behavior was not tested on a device.
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/app.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/platform.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||
|
||||
void main() {
|
||||
test('web uses Material on every host; native Apple uses Cupertino', () {
|
||||
for (final platform in TargetPlatform.values) {
|
||||
expect(prefersCupertino(web: true, platform: platform), isFalse);
|
||||
expect(
|
||||
prefersCupertino(web: false, platform: platform),
|
||||
platform == TargetPlatform.iOS || platform == TargetPlatform.macOS,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
for (final platform in [TargetPlatform.macOS, TargetPlatform.iOS]) {
|
||||
testWidgets('app and themes select the right controls on $platform', (
|
||||
tester,
|
||||
) async {
|
||||
debugDefaultTargetPlatformOverride = platform;
|
||||
addTearDown(() => debugDefaultTargetPlatformOverride = null);
|
||||
await tester.pumpWidget(const MyApp());
|
||||
if (kIsWeb) {
|
||||
expect(find.byType(MaterialApp), findsOneWidget);
|
||||
expect(find.byType(CupertinoApp), findsNothing);
|
||||
expect(appLightTheme().platform, TargetPlatform.android);
|
||||
expect(appDarkTheme().platform, TargetPlatform.android);
|
||||
} else {
|
||||
expect(find.byType(CupertinoApp), findsOneWidget);
|
||||
expect(appLightTheme().platform, platform);
|
||||
expect(appDarkTheme().platform, platform);
|
||||
}
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user