Skip to content
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

Fix formatting of code snippets on iOS dev pages #11021

Merged
merged 45 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7246dfc
Update swiftui-devs.md
piedcipher Aug 7, 2024
328af76
Update canvas.dart
piedcipher Aug 7, 2024
3a825e9
Update text_button.dart
piedcipher Aug 7, 2024
f97e036
Update swiftui-devs.md
piedcipher Aug 7, 2024
66372be
Update row.dart
piedcipher Aug 7, 2024
79ac9ea
Update column.dart
piedcipher Aug 7, 2024
82838b6
Update scroll.dart
piedcipher Aug 7, 2024
f672eb1
Update simple_animation.dart
piedcipher Aug 7, 2024
33c6c47
Update navigation.dart
piedcipher Aug 7, 2024
cf96e31
Update openapp.dart
piedcipher Aug 7, 2024
641b0a8
Update cupertino_themes.dart
piedcipher Aug 7, 2024
e81a5f8
Update cupertino_themes.dart
piedcipher Aug 7, 2024
67ea781
Update stylingbutton.dart
piedcipher Aug 7, 2024
8ec0396
Update cupertino_themes.dart
piedcipher Aug 7, 2024
b398b28
Update navigation.dart
piedcipher Aug 7, 2024
fc7f847
Update canvas.dart
piedcipher Aug 7, 2024
6ae42fd
Update simple_animation.dart
piedcipher Aug 7, 2024
ea49ea6
Update scroll.dart
piedcipher Aug 7, 2024
ffb52ee
Update column.dart
piedcipher Aug 7, 2024
9199a59
Update row.dart
piedcipher Aug 7, 2024
7a73319
Update text_button.dart
piedcipher Aug 7, 2024
15ee3a9
Update canvas.dart
piedcipher Aug 7, 2024
a07f898
Update column.dart
piedcipher Aug 7, 2024
dd4e6cb
Update cupertino_themes.dart
piedcipher Aug 7, 2024
9af3597
Update cupertino_themes.dart
piedcipher Aug 7, 2024
3e6e1e9
Update row.dart
piedcipher Aug 7, 2024
90d7b9d
Update scroll.dart
piedcipher Aug 7, 2024
89a1e57
Update scroll.dart
piedcipher Aug 7, 2024
aba9cd6
Update simple_animation.dart
piedcipher Aug 7, 2024
e5c3ff9
Update simple_animation.dart
piedcipher Aug 7, 2024
c5dd349
Update openapp.dart
piedcipher Aug 7, 2024
d0d96b1
Update text_button.dart
piedcipher Aug 7, 2024
f4a3f86
Update text_button.dart
piedcipher Aug 7, 2024
15dfaef
Update navigation.dart
piedcipher Aug 7, 2024
e18e8e9
Update text_button.dart
piedcipher Aug 7, 2024
aa9878e
Update text_button.dart
piedcipher Aug 7, 2024
8c4f301
Update stylingbutton.dart
piedcipher Aug 7, 2024
97c0b8f
Update stylingbutton.dart
piedcipher Aug 7, 2024
d6c902e
Update stylingbutton.dart
piedcipher Aug 7, 2024
a33f8a9
Update stylingbutton.dart
piedcipher Aug 7, 2024
a3e15cd
Update stylingbutton.dart
piedcipher Aug 7, 2024
9b6d687
Merge branch 'main' into fix/10725
domesticmouse Aug 9, 2024
a4d3222
Merge branch 'main' into fix/10725
parlough Sep 9, 2024
9346457
Move region comments up and add replacement instructions
parlough Sep 9, 2024
8572493
Merge branch 'main' into fix/10725
parlough Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions examples/get-started/flutter-for/ios_devs/lib/canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ class SignatureState extends State<Signature> {
});
},
onPanEnd: (details) => _points.add(null),
child:
// #docregion custom-paint
CustomPaint(
// #docregion custom-paint
child: CustomPaint(
painter: SignaturePainter(_points),
size: Size.infinite,
),
Expand Down
5 changes: 2 additions & 3 deletions examples/get-started/flutter-for/ios_devs/lib/column.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ class HomePage extends StatelessWidget {
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child:
// #docregion column
Column(
// #docregion column
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(CupertinoIcons.globe),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ class App extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const
// #docregion theme
CupertinoApp(
// #docregion theme
return const CupertinoApp(
theme: CupertinoThemeData(
brightness: Brightness.dark,
),
Expand All @@ -37,9 +36,8 @@ class HomePage extends StatelessWidget {
),
),
child: Center(
child:
// #docregion styling-text
Text(
// #docregion styling-text
child: Text(
'Hello, world!',
style: TextStyle(
fontSize: 30,
Expand Down
9 changes: 4 additions & 5 deletions examples/get-started/flutter-for/ios_devs/lib/images.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const Image(
image:
// #docregion asset-image
AssetImage('images/a_dot_burr.jpeg')
// #enddocregion asset-image
);
// #docregion asset-image
image: AssetImage('images/a_dot_burr.jpeg'),
// #enddocregion asset-image
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ class HomePage extends StatelessWidget {
),
),
child: Material(
child:
// #docregion list-view
ListView.builder(
// #docregion list-view
child: ListView.builder(
itemCount: mockPersons.length,
itemBuilder: (context, index) {
final person = mockPersons.elementAt(index);
Expand Down
5 changes: 2 additions & 3 deletions examples/get-started/flutter-for/ios_devs/lib/openapp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ class HomePage extends StatelessWidget {
return CupertinoPageScaffold(
child: SafeArea(
child: Center(
child:
// #docregion open-app-example
CupertinoButton(
// #docregion open-app-example
child: CupertinoButton(
onPressed: () async {
await launchUrl(
Uri.parse('https://google.com'),
Expand Down
5 changes: 2 additions & 3 deletions examples/get-started/flutter-for/ios_devs/lib/row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ class HomePage extends StatelessWidget {
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child:
// #docregion row
Row(
// #docregion row
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(CupertinoIcons.globe),
Expand Down
5 changes: 2 additions & 3 deletions examples/get-started/flutter-for/ios_devs/lib/scroll.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ class HomePage extends StatelessWidget {
// Finally, display the list of people on the screen,
// inside a scroll view of type
// SingleChildScrollView (equivalent of a ScrollView in SwiftUI).
body:
// #docregion scroll-example
SingleChildScrollView(
// #docregion scroll-example
body: SingleChildScrollView(
child: Column(
children: mockPersons
.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child:
// #docregion animated-button
AnimatedRotation(
// #docregion animated-button
child: AnimatedRotation(
duration: const Duration(seconds: 1),
turns: turns,
curve: Curves.easeIn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ class MyWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return
// #docregion access-string
const Text(Strings.welcomeMessage);
// #docregion access-string
return const Text(Strings.welcomeMessage);
// #enddocregion access-string
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@ class HomePage extends StatelessWidget {
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle:
// #docregion custom-font
Text(
'Cupertino',
style: TextStyle(
fontSize: 40,
fontFamily: 'BungeeSpice',
),
)
// #enddocregion custom-font
// #docregion custom-font
middle: Text(
'Cupertino',
style: TextStyle(
fontSize: 40,
fontFamily: 'BungeeSpice',
),
),
// #enddocregion custom-font
),
child: Center(
// #docregion styling-button
child: CupertinoButton(
Expand Down
19 changes: 9 additions & 10 deletions examples/get-started/flutter-for/ios_devs/lib/text_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ class HomePage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child:
// #docregion text-button
CupertinoButton(
onPressed: () {
// This closure is called when your button is tapped.
},
child: const Text('Do something'),
)
// #enddocregion text-button
),
// #docregion text-button
child: CupertinoButton(
onPressed: () {
// This closure is called when your button is tapped.
},
child: const Text('Do something'),
),
// #enddocregion text-button
),
);
}
}
56 changes: 28 additions & 28 deletions src/content/get-started/flutter-for/swiftui-devs.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,14 @@ Button("Do something") {
To achieve the same result in **Flutter**,
use the `CupertinoButton` class:

<?code-excerpt "lib/text_button.dart (text-button)"?>
<?code-excerpt "lib/text_button.dart (text-button)" replace="/child: //g;"?>
```dart dartpad="3c9b9a4de431b86725197a7fc2c84158"
CupertinoButton(
CupertinoButton(
onPressed: () {
// This closure is called when your button is tapped.
},
child: const Text('Do something'),
)
const Text('Do something'),
),
```

**Flutter** gives you access to a variety of buttons with predefined styles.
Expand Down Expand Up @@ -306,9 +306,9 @@ HStack {

**Flutter** uses [`Row`][] rather than `HStack`:

<?code-excerpt "lib/row.dart (row)"?>
<?code-excerpt "lib/row.dart (row)" replace="/child: //g;"?>
```dart dartpad="0365338f938427b01d72e37cea554f75"
Row(
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(CupertinoIcons.globe),
Expand Down Expand Up @@ -340,9 +340,9 @@ VStack {
**Flutter** uses the same Dart code from the previous example,
except it swaps [`Column`][] for `Row`:

<?code-excerpt "lib/column.dart (column)"?>
<?code-excerpt "lib/column.dart (column)" replace="/child: //g;"?>
```dart dartpad="d9a288be0c2a353296fc8825680b84b8"
Column(
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(CupertinoIcons.globe),
Expand Down Expand Up @@ -519,9 +519,9 @@ To create a scrolling view, **Flutter** uses [`SingleChildScrollView`][].
In the following example, the function `mockPerson` mocks instances
of the `Person` class to create the custom `PersonView` widget.

<?code-excerpt "lib/scroll.dart (scroll-example)"?>
<?code-excerpt "lib/scroll.dart (scroll-example)" replace="/body: //g;"?>
```dart dartpad="a75740320989ed04020d95502a0de34e"
SingleChildScrollView(
SingleChildScrollView(
child: Column(
children: mockPersons
.map(
Expand Down Expand Up @@ -650,19 +650,19 @@ Flutter names these widgets with the following format: `AnimatedFoo`.
For example: To rotate a button, use the [`AnimatedRotation`][] class.
This animates the `Transform.rotate` widget.

<?code-excerpt "lib/simple_animation.dart (animated-button)"?>
<?code-excerpt "lib/simple_animation.dart (animated-button)" replace="/child: //g;"?>
```dart dartpad="0ad0572cbf98ead2e5d31a2a94430f19"
AnimatedRotation(
AnimatedRotation(
duration: const Duration(seconds: 1),
turns: turns,
curve: Curves.easeIn,
child: TextButton(
TextButton(
onPressed: () {
setState(() {
turns += .125;
});
},
child: const Text('Tap me!')),
const Text('Tap me!')),
),
```

Expand Down Expand Up @@ -692,9 +692,9 @@ with two classes that help you draw:

1. [`CustomPaint`][] that requires a painter:

<?code-excerpt "lib/canvas.dart (custom-paint)"?>
<?code-excerpt "lib/canvas.dart (custom-paint)" replace="/child: //g;"?>
```dart dartpad="978d64ee66d54177fb639f8a9f801039"
CustomPaint(
CustomPaint(
painter: SignaturePainter(_points),
size: Size.infinite,
),
Expand Down Expand Up @@ -797,9 +797,9 @@ call your navigation routes using their names.
`mockPersons()`. Tapping a person pushes the person's detail page
to the `Navigator` using `pushNamed()`.

<?code-excerpt "lib/navigation.dart (list-view)"?>
<?code-excerpt "lib/navigation.dart (list-view)" replace="/child: //g;"?>
```dart dartpad="d8b22d4dcbefdc8a2e21f1382cf7dc2a"
ListView.builder(
ListView.builder(
itemCount: mockPersons.length,
itemBuilder: (context, index) {
final person = mockPersons.elementAt(index);
Expand Down Expand Up @@ -902,15 +902,15 @@ URL to another application.

In **Flutter**, use the [`url_launcher`][] plugin.

<?code-excerpt "lib/openapp.dart (open-app-example)"?>
<?code-excerpt "lib/openapp.dart (open-app-example)" replace="/child: //g;"?>
```dart dartpad="695beba25fa8120d89c9960cb222e276"
CupertinoButton(
CupertinoButton(
onPressed: () async {
await launchUrl(
Uri.parse('https://google.com'),
);
},
child: const Text(
const Text(
'Open website',
),
),
Expand All @@ -932,9 +932,9 @@ In **Flutter**, you can control light and dark mode at the app-level.
To control the brightness mode, use the `theme` property
of the `App` class:

<?code-excerpt "lib/cupertino_themes.dart (theme)"?>
<?code-excerpt "lib/cupertino_themes.dart (theme)" replace="/return //g;"?>
```dart dartpad="18790cfaa8441085994373a4bc4f46b0"
CupertinoApp(
const CupertinoApp(
theme: CupertinoThemeData(
brightness: Brightness.dark,
),
Expand All @@ -957,9 +957,9 @@ Text("Hello, world!")
To style text in **Flutter**, add a `TextStyle` widget as the value
of the `style` parameter of the `Text` widget.

<?code-excerpt "lib/cupertino_themes.dart (styling-text)"?>
<?code-excerpt "lib/cupertino_themes.dart (styling-text)" replace="/child: //g;"?>
```dart dartpad="18790cfaa8441085994373a4bc4f46b0"
Text(
Text(
'Hello, world!',
style: TextStyle(
fontSize: 30,
Expand Down Expand Up @@ -1047,15 +1047,15 @@ To add a custom font to your project, follow these steps:
After you add the font to your project, you can use it as in the
following example:

<?code-excerpt "lib/stylingbutton.dart (custom-font)"?>
<?code-excerpt "lib/stylingbutton.dart (custom-font)" replace="/middle: //g;"?>
```dart
Text(
Text(
'Cupertino',
style: TextStyle(
fontSize: 40,
fontFamily: 'BungeeSpice',
),
)
),
```

:::note
Expand Down
7 changes: 3 additions & 4 deletions src/content/get-started/flutter-for/uikit-devs.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,7 @@ class SignatureState extends State<Signature> {
});
},
onPanEnd: (details) => _points.add(null),
child:
CustomPaint(
child: CustomPaint(
painter: SignaturePainter(_points),
size: Size.infinite,
),
Expand Down Expand Up @@ -670,7 +669,7 @@ class Strings {

You can access your strings as such:

<?code-excerpt "lib/string_examples.dart (access-string)" replace="/const //g"?>
<?code-excerpt "lib/string_examples.dart (access-string)" replace="/const //g; /return //g;"?>
```dart
Text(Strings.welcomeMessage);
```
Expand Down Expand Up @@ -1498,7 +1497,7 @@ You can now access your images using `AssetImage`:

<?code-excerpt "lib/images.dart (asset-image)"?>
```dart
AssetImage('images/a_dot_burr.jpeg')
image: AssetImage('images/a_dot_burr.jpeg'),
```

or directly in an `Image` widget:
Expand Down