From 9f147ce54010c17c80132836ad8c53938f6e83c4 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 29 Sep 2021 17:29:24 -0400 Subject: [PATCH] Initial layout and theme (#90887) * Initial layout and theme * fixed tests * made page scrollable * fixes based on Chris on Casey's comments * removed desktop_window, add errorWidget * 2nd round of fixes * fixed linux analyze * changes based on Casey's comments: * remove trailing space * removed obselete macos build code * add discrepency in project.pbxproj * addressed Casey's comment --- dev/conductor/ui/lib/main.dart | 39 ++++++++++------ dev/conductor/ui/lib/widgets/progression.dart | 45 +++++++++++++++++++ .../test/{widget_test.dart => main_test.dart} | 11 +++-- 3 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 dev/conductor/ui/lib/widgets/progression.dart rename dev/conductor/ui/test/{widget_test.dart => main_test.dart} (77%) diff --git a/dev/conductor/ui/lib/main.dart b/dev/conductor/ui/lib/main.dart index 92128cb9bd..bc7ac695bd 100644 --- a/dev/conductor/ui/lib/main.dart +++ b/dev/conductor/ui/lib/main.dart @@ -2,23 +2,33 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:io' as io; import 'package:conductor_core/conductor_core.dart'; import 'package:conductor_core/proto.dart' as pb; - import 'package:file/file.dart'; import 'package:file/local.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:platform/platform.dart'; -const String _title = 'Flutter Conductor'; +import 'widgets/progression.dart'; + +const String _title = 'Flutter Desktop Conductor (Not ready, do not use)'; const LocalFileSystem _fs = LocalFileSystem(); const LocalPlatform _platform = LocalPlatform(); final String _stateFilePath = defaultStateFilePath(_platform); -void main() { +Future main() async { + // The app currently only supports macOS and Linux. + if (kIsWeb || io.Platform.isWindows) { + throw Exception('The conductor only supports MacOS and Linux desktop'); + } final File _stateFile = _fs.file(_stateFilePath); - final pb.ConductorState? state = _stateFile.existsSync() ? readStateFromFile(_stateFile) : null; + final pb.ConductorState? state = + _stateFile.existsSync() ? readStateFromFile(_stateFile) : null; + + WidgetsFlutterBinding.ensureInitialized(); runApp(MyApp(state)); } @@ -34,21 +44,24 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( title: _title, - theme: ThemeData( - primarySwatch: Colors.blue, - ), +// TODO(Yugue): Add theming, https://github.com/flutter/flutter/issues/90982. home: Scaffold( appBar: AppBar( title: const Text(_title), ), - body: Center( + body: Padding( + padding: const EdgeInsets.all(20.0), child: Column( - mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Expanded( - child: SelectableText( - state != null ? presentState(state!) : 'No persistent state file found at $_stateFilePath', - ), + const SelectableText( + 'Desktop app for managing a release of the Flutter SDK, currently in development', + ), + const SizedBox(height: 20.0), + MainProgression( + releaseState: state, + stateFilePath: _stateFilePath, ), ], ), diff --git a/dev/conductor/ui/lib/widgets/progression.dart b/dev/conductor/ui/lib/widgets/progression.dart new file mode 100644 index 0000000000..4020f4124c --- /dev/null +++ b/dev/conductor/ui/lib/widgets/progression.dart @@ -0,0 +1,45 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:conductor_core/conductor_core.dart'; +import 'package:conductor_core/proto.dart' as pb; +import 'package:flutter/material.dart'; + +/// Displays the progression and each step of the release from the conductor. +/// +// TODO(Yugue): Add documentation to explain +// each step of the release, https://github.com/flutter/flutter/issues/90981. +class MainProgression extends StatefulWidget { + const MainProgression({ + Key? key, + this.releaseState, + required this.stateFilePath, + }) : super(key: key); + + final pb.ConductorState? releaseState; + final String stateFilePath; + + @override + MainProgressionState createState() => MainProgressionState(); +} + +class MainProgressionState extends State { + @override + Widget build(BuildContext context) { + return Expanded( + child: Scrollbar( + isAlwaysShown: true, + child: ListView( + children: [ + SelectableText( + widget.releaseState != null + ? presentState(widget.releaseState!) + : 'No persistent state file found at ${widget.stateFilePath}', + ), + ], + ), + ), + ); + } +} diff --git a/dev/conductor/ui/test/widget_test.dart b/dev/conductor/ui/test/main_test.dart similarity index 77% rename from dev/conductor/ui/test/widget_test.dart rename to dev/conductor/ui/test/main_test.dart index ddfcd6dd1e..8a245931a4 100644 --- a/dev/conductor/ui/test/widget_test.dart +++ b/dev/conductor/ui/test/main_test.dart @@ -10,13 +10,12 @@ import 'package:conductor_ui/main.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - group('group', () { + group('Main app', () { testWidgets('Handles null state', (WidgetTester tester) async { await tester.pumpWidget(const MyApp(null)); - expect(find.text('Flutter Conductor'), findsOneWidget); - expect(find.textContaining('No persistent state file found at'), - findsOneWidget); + expect(find.textContaining('Flutter Desktop Conductor'), findsOneWidget); + expect(find.textContaining('No persistent state file found at'), findsOneWidget); }); testWidgets('App prints release channel from state file', @@ -27,8 +26,8 @@ void main() { ); await tester.pumpWidget(MyApp(state)); - expect(find.text('Flutter Conductor'), findsOneWidget); - expect(find.textContaining(channelName), findsOneWidget); + expect(find.textContaining('Flutter Desktop Conductor'), findsOneWidget); + expect(find.textContaining('Conductor version'), findsOneWidget); expect(find.text('1'), findsNothing); }); }, skip: Platform.isWindows); // This app does not support Windows [intended]