-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a simulated DevTools environment for developing extensions #6251
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
712bca0
Add a simulated DevTools environment for developing extensions
kenzieschmoll e7cbff1
use an environment variable instead
kenzieschmoll caaad8a
formatting
kenzieschmoll 706834a
Merge branch 'master' of github.com:flutter/devtools into ext-sim
kenzieschmoll e27eee8
fixes
kenzieschmoll f0c2fe5
Fix state management bug
kenzieschmoll 4636bd4
formatting
kenzieschmoll a9db1f8
add note about memory leak
kenzieschmoll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
...ges/devtools_extensions/lib/src/template/_simulated_devtools_environment/_connect_ui.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
// Copyright 2023 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
part of '_simulated_devtools_environment.dart'; | ||
|
||
class _VmServiceConnection extends StatelessWidget { | ||
const _VmServiceConnection({ | ||
required this.simController, | ||
required this.connected, | ||
}); | ||
|
||
static const _totalControlsHeight = 45.0; | ||
static const _totalControlsWidth = 415.0; | ||
|
||
final _SimulatedDevToolsController simController; | ||
final bool connected; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SizedBox( | ||
height: _totalControlsHeight, | ||
child: connected | ||
? const _ConnectedVmServiceDisplay() | ||
: _DisconnectedVmServiceDisplay( | ||
simController: simController, | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _ConnectedVmServiceDisplay extends StatelessWidget { | ||
const _ConnectedVmServiceDisplay(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
return Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
'Debugging:', | ||
style: theme.regularTextStyle, | ||
), | ||
const Text('<connected uri>'), | ||
// TODO(kenz): uncomment once we can bump to vm_service ^11.10.0 | ||
// Text( | ||
// serviceManager.service!.wsUri ?? '--', | ||
// style: theme.boldTextStyle, | ||
// ), | ||
], | ||
), | ||
const Expanded( | ||
child: SizedBox(width: denseSpacing), | ||
), | ||
DevToolsButton( | ||
elevated: true, | ||
label: 'Disconnect', | ||
onPressed: serviceManager.manuallyDisconnect, | ||
), | ||
], | ||
); | ||
} | ||
} | ||
|
||
class _DisconnectedVmServiceDisplay extends StatefulWidget { | ||
const _DisconnectedVmServiceDisplay({required this.simController}); | ||
|
||
final _SimulatedDevToolsController simController; | ||
|
||
@override | ||
State<_DisconnectedVmServiceDisplay> createState() => | ||
_DisconnectedVmServiceDisplayState(); | ||
} | ||
|
||
class _DisconnectedVmServiceDisplayState | ||
extends State<_DisconnectedVmServiceDisplay> { | ||
static const _connectFieldWidth = 300.0; | ||
|
||
late final TextEditingController _connectTextFieldController; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
_connectTextFieldController = TextEditingController(); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_connectTextFieldController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
return Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
SizedBox( | ||
width: _connectFieldWidth, | ||
child: TextField( | ||
autofocus: true, | ||
style: theme.regularTextStyle, | ||
decoration: InputDecoration( | ||
// contentPadding: const EdgeInsets.all(denseSpacing), | ||
isDense: true, | ||
border: const OutlineInputBorder(), | ||
enabledBorder: OutlineInputBorder( | ||
borderSide: BorderSide(width: 0.5, color: theme.focusColor), | ||
), | ||
labelText: 'Dart VM Service URL', | ||
labelStyle: theme.regularTextStyle, | ||
hintText: '(e.g., http://127.0.0.1:60851/fH-kAEXc7MQ=/)', | ||
hintStyle: theme.regularTextStyle, | ||
), | ||
onSubmitted: (value) => | ||
widget.simController.vmServiceConnectionChanged(uri: value), | ||
controller: _connectTextFieldController, | ||
), | ||
), | ||
const SizedBox(width: denseSpacing), | ||
DevToolsButton( | ||
elevated: true, | ||
label: 'Connect', | ||
onPressed: () => widget.simController.vmServiceConnectionChanged( | ||
uri: _connectTextFieldController.text, | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool!