Skip to content

Commit

Permalink
Merge branch 'main' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
domesticmouse committed Jan 31, 2024
2 parents 3e27e14 + 176c565 commit 765c711
Show file tree
Hide file tree
Showing 37 changed files with 784 additions and 13,815 deletions.
21 changes: 20 additions & 1 deletion experimental/material_3_demo/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:web_startup_analyzer/web_startup_analyzer.dart';

import 'constants.dart';
import 'home.dart';

void main() {
void main() async {
var analyzer = WebStartupAnalyzer(additionalFrameCount: 10);
debugPrint(json.encode(analyzer.startupTiming));
analyzer.onFirstFrame.addListener(() {
debugPrint(json.encode({'firstFrame': analyzer.onFirstFrame.value}));
});
analyzer.onFirstPaint.addListener(() {
debugPrint(json.encode({
'firstPaint': analyzer.onFirstPaint.value?.$1,
'firstContentfulPaint': analyzer.onFirstPaint.value?.$2,
}));
});
analyzer.onAdditionalFrames.addListener(() {
debugPrint(json.encode({
'additionalFrames': analyzer.onAdditionalFrames.value,
}));
});
runApp(
const App(),
);
Expand Down
3 changes: 3 additions & 0 deletions experimental/material_3_demo/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ version: 1.0.0+1

environment:
sdk: ^3.2.0
flutter: ^3.16.0

dependencies:
flutter:
sdk: flutter

cupertino_icons: ^1.0.2
url_launcher: ^6.1.8
web_startup_analyzer:
path: ../../web/_packages/web_startup_analyzer

dev_dependencies:
analysis_defaults:
Expand Down
36 changes: 22 additions & 14 deletions experimental/material_3_demo/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,30 @@
</script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
<script type="text/javascript" src="assets/packages/web_startup_analyzer/lib/web_startup_analyzer.js"></script>
</head>
<body>
<script>
window.addEventListener('load', function(ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: function(engineInitializer) {
engineInitializer.initializeEngine().then(function(appRunner) {
appRunner.runApp();
});
}
});
<script>
var flutterWebStartupAnalyzer = new FlutterWebStartupAnalyzer();
var analyzer = flutterWebStartupAnalyzer;

window.addEventListener('load', function(ev) {
analyzer.markStart("loadEntrypoint");
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: function(engineInitializer) {
analyzer.markFinished("loadEntrypoint");
analyzer.markStart("initializeEngine");
engineInitializer.initializeEngine().then(function(appRunner) {
analyzer.markFinished("initializeEngine");
analyzer.markStart("appRunnerRunApp");
appRunner.runApp();
});
}
});
</script>
});
</script>
</body>
</html>
7 changes: 4 additions & 3 deletions simplistic_editor/lib/basic_text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class BasicTextField extends StatefulWidget {
VoidCallback? onSelectAll,
VoidCallback? onLookUp,
VoidCallback? onLiveTextInput,
VoidCallback? onSearchWeb,
VoidCallback? onShare,
TextSelectionToolbarAnchors anchors,
) {
return AdaptiveTextSelectionToolbar.editable(
Expand All @@ -38,10 +40,9 @@ class BasicTextField extends StatefulWidget {
onSelectAll: onSelectAll,
onLookUp: onLookUp,
onLiveTextInput: onLiveTextInput,
onSearchWeb: onSearchWeb,
onShare: onShare,
anchors: anchors,
// TODO(Renzo-Olivares): https://github.com/flutter/samples/issues/2088
onSearchWeb: null,
onShare: null,
);
}

Expand Down
68 changes: 68 additions & 0 deletions simplistic_editor/lib/basic_text_input_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ typedef BasicTextFieldContextMenuBuilder = Widget Function(
VoidCallback? onSelectAll,
VoidCallback? onLookUp,
VoidCallback? onLiveTextInput,
VoidCallback? onSearchWeb,
VoidCallback? onShare,
TextSelectionToolbarAnchors anchors,
);

Expand Down Expand Up @@ -867,6 +869,13 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
liveTextInputEnabled
? () => _startLiveTextInput(SelectionChangedCause.toolbar)
: null,
searchWebEnabled
? () =>
_searchWebForSelection(SelectionChangedCause.toolbar)
: null,
shareEnabled
? () => _shareSelection(SelectionChangedCause.toolbar)
: null,
_contextMenuAnchors,
);
},
Expand Down Expand Up @@ -1016,6 +1025,65 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
);
}

@override
bool get searchWebEnabled {
if (defaultTargetPlatform != TargetPlatform.iOS) {
return false;
}

return !textEditingValue.selection.isCollapsed &&
textEditingValue.selection.textInside(textEditingValue.text).trim() !=
'';
}

/// Launch a web search on the current selection,
/// as in the "Search Web" edit menu button on iOS.
///
/// Currently this is only implemented for iOS.
Future<void> _searchWebForSelection(SelectionChangedCause cause) async {
final String text =
textEditingValue.selection.textInside(textEditingValue.text);
if (text.isNotEmpty) {
await SystemChannels.platform.invokeMethod(
'SearchWeb.invoke',
text,
);
}
}

@override
bool get shareEnabled {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.iOS:
return !textEditingValue.selection.isCollapsed &&
textEditingValue.selection
.textInside(textEditingValue.text)
.trim() !=
'';
case TargetPlatform.macOS:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return false;
}
}

/// Launch the share interface for the current selection,
/// as in the "Share..." edit menu button on iOS.
///
/// Currently this is only implemented for iOS and Android.
Future<void> _shareSelection(SelectionChangedCause cause) async {
final String text =
textEditingValue.selection.textInside(textEditingValue.text);
if (text.isNotEmpty) {
await SystemChannels.platform.invokeMethod(
'Share.invoke',
text,
);
}
}

@override
Widget build(BuildContext context) {
return Actions(
Expand Down
3 changes: 2 additions & 1 deletion tool/flutter_ci_script_beta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ declare -ar PROJECT_NAMES=(
"experimental/federated_plugin/federated_plugin_web"
"experimental/federated_plugin/federated_plugin_windows"
"experimental/linting_tool"
"experimental/material_3_demo"
# TODO(DomesticMouse): re-enable once deps allow
# "experimental/material_3_demo"
"experimental/pedometer"
"experimental/pedometer/example"
"experimental/varfont_shader_puzzle"
Expand Down
2 changes: 1 addition & 1 deletion tool/flutter_ci_script_master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ declare -ar PROJECT_NAMES=(
"provider_shopper"
"simple_shader"
"simplistic_calculator"
# TODO(DomesticMouse): The method 'isSelectionWithinTextBounds' isn't defined for the type 'TextEditingController'.
# TODO(DomesticMouse): The method 'isSelectionWithinTextBounds' isn't defined for the type 'TextEditingController'
# "simplistic_editor"
"testing_app"
"veggieseasons"
Expand Down
3 changes: 2 additions & 1 deletion tool/flutter_ci_script_stable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ declare -ar PROJECT_NAMES=(
"experimental/federated_plugin/federated_plugin_web"
"experimental/federated_plugin/federated_plugin_windows"
"experimental/linting_tool"
"experimental/material_3_demo"
# TODO(DomesticMouse): re-enable once deps allow
# "experimental/material_3_demo"
"experimental/pedometer"
"experimental/pedometer/example"
"experimental/varfont_shader_puzzle"
Expand Down
29 changes: 29 additions & 0 deletions web/_packages/web_startup_analyzer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
build/
10 changes: 10 additions & 0 deletions web/_packages/web_startup_analyzer/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "f5fb61b953a631f47191124a31169701911ee1f4"
channel: "main"

project_type: package
4 changes: 4 additions & 0 deletions web/_packages/web_startup_analyzer/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
43 changes: 43 additions & 0 deletions web/_packages/web_startup_analyzer/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
45 changes: 45 additions & 0 deletions web/_packages/web_startup_analyzer/example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "f5fb61b953a631f47191124a31169701911ee1f4"
channel: "main"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f5fb61b953a631f47191124a31169701911ee1f4
base_revision: f5fb61b953a631f47191124a31169701911ee1f4
- platform: android
create_revision: f5fb61b953a631f47191124a31169701911ee1f4
base_revision: f5fb61b953a631f47191124a31169701911ee1f4
- platform: ios
create_revision: f5fb61b953a631f47191124a31169701911ee1f4
base_revision: f5fb61b953a631f47191124a31169701911ee1f4
- platform: linux
create_revision: f5fb61b953a631f47191124a31169701911ee1f4
base_revision: f5fb61b953a631f47191124a31169701911ee1f4
- platform: macos
create_revision: f5fb61b953a631f47191124a31169701911ee1f4
base_revision: f5fb61b953a631f47191124a31169701911ee1f4
- platform: web
create_revision: f5fb61b953a631f47191124a31169701911ee1f4
base_revision: f5fb61b953a631f47191124a31169701911ee1f4
- platform: windows
create_revision: f5fb61b953a631f47191124a31169701911ee1f4
base_revision: f5fb61b953a631f47191124a31169701911ee1f4

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include: package:flutter_lints/flutter.yaml
linter:
rules:
Loading

0 comments on commit 765c711

Please sign in to comment.