import 'dart:async'; import 'package:flutter/material.dart'; import 'package:pipelines_app/core/transport/pipelines_client.dart'; import 'package:pipelines_app/features/settings/settings.dart'; /// A fixture entry point for browser captures of the Settings screen. It does /// not change `main.dart` or the shell, and it never uses the production /// preferences store: all persisted values live in a [MemorySettingsStore]. /// /// Query parameters: /// endpoint=ws://127.0.0.1:PORT/connect seed the URL field / connect target /// workspace=/srv/pipelines seed the saved workspace /// connect=1 explicitly connect after first frame /// platform=ios render the Cupertino controls /// theme=dark dark Material theme /// scale=1.5 large-text check void main() { final params = Uri.base.queryParameters; final endpoint = params['endpoint']?.trim(); final client = PipelinesClient(); final store = MemorySettingsStore( workspace: params['workspace']?.trim() ?? '', ); final isIOS = params['platform'] == 'ios'; final isDark = params['theme'] == 'dark'; final scale = double.tryParse(params['scale'] ?? '') ?? 1; runApp( MaterialApp( title: 'Pipelines Settings probe', theme: ThemeData( platform: isIOS ? TargetPlatform.iOS : TargetPlatform.android, brightness: isDark ? Brightness.dark : Brightness.light, colorScheme: ColorScheme.fromSeed( seedColor: Colors.blue, brightness: isDark ? Brightness.dark : Brightness.light, ), ), builder: (context, child) => MediaQuery( data: MediaQuery.of( context, ).copyWith(textScaler: TextScaler.linear(scale)), child: child ?? const SizedBox.shrink(), ), home: SettingsScreen( client: client, initialEndpoint: (endpoint == null || endpoint.isEmpty) ? null : Uri.tryParse(endpoint), store: store, ), ), ); if (params['connect'] == '1') { final target = (endpoint == null || endpoint.isEmpty) ? defaultServerUrl() : endpoint; if (target.isNotEmpty) { WidgetsBinding.instance.addPostFrameCallback((_) { unawaited( client.connect(Uri.parse(target)).catchError((Object _) { // The screen renders the client's truthful state; an invalid // fixture endpoint must not take the probe down. }), ); }); } } }