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
This commit is contained in:
parent
01fc74e4d0
commit
9f147ce540
@ -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<void> 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: <Widget>[
|
||||
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,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
45
dev/conductor/ui/lib/widgets/progression.dart
Normal file
45
dev/conductor/ui/lib/widgets/progression.dart
Normal file
@ -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<MainProgression> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Scrollbar(
|
||||
isAlwaysShown: true,
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
SelectableText(
|
||||
widget.releaseState != null
|
||||
? presentState(widget.releaseState!)
|
||||
: 'No persistent state file found at ${widget.stateFilePath}',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -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]
|
Loading…
x
Reference in New Issue
Block a user