Skip to content

Commit d80f3e3

Browse files
authored
Cupertino examples improvements and clean up (#103044)
1 parent 27fee48 commit d80f3e3

27 files changed

+219
-202
lines changed

examples/api/lib/cupertino/bottom_tab_bar/bottom_tab_bar.0.dart renamed to examples/api/lib/cupertino/bottom_tab_bar/cupertino_tab_bar.0.dart

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,43 @@
66

77
import 'package:flutter/cupertino.dart';
88

9-
void main() => runApp(const MyApp());
9+
void main() => runApp(const CupertinoTabBarApp());
1010

11-
class MyApp extends StatelessWidget {
12-
const MyApp({Key? key}) : super(key: key);
13-
14-
static const String _title = 'Flutter Code Sample';
11+
class CupertinoTabBarApp extends StatelessWidget {
12+
const CupertinoTabBarApp({Key? key}) : super(key: key);
1513

1614
@override
1715
Widget build(BuildContext context) {
1816
return const CupertinoApp(
19-
title: _title,
20-
home: MyStatefulWidget(),
17+
theme: CupertinoThemeData(brightness: Brightness.light),
18+
home: CupertinoTabBarExample(),
2119
);
2220
}
2321
}
2422

25-
class MyStatefulWidget extends StatefulWidget {
26-
const MyStatefulWidget({Key? key}) : super(key: key);
27-
28-
@override
29-
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
30-
}
23+
class CupertinoTabBarExample extends StatelessWidget {
24+
const CupertinoTabBarExample({Key? key}) : super(key: key);
3125

32-
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
3326
@override
3427
Widget build(BuildContext context) {
3528
return CupertinoTabScaffold(
3629
tabBar: CupertinoTabBar(
3730
items: const <BottomNavigationBarItem>[
3831
BottomNavigationBarItem(
39-
icon: Icon(CupertinoIcons.circle),
40-
label: 'Tab 1',
32+
icon: Icon(CupertinoIcons.star_fill),
33+
label: 'Favourites',
34+
),
35+
BottomNavigationBarItem(
36+
icon: Icon(CupertinoIcons.clock_solid),
37+
label: 'Recents',
38+
),
39+
BottomNavigationBarItem(
40+
icon: Icon(CupertinoIcons.person_alt_circle_fill),
41+
label: 'Contacts',
4142
),
4243
BottomNavigationBarItem(
43-
icon: Icon(CupertinoIcons.add),
44-
label: 'Tab 2',
44+
icon: Icon(CupertinoIcons.circle_grid_3x3_fill),
45+
label: 'Keypad',
4546
),
4647
],
4748
),

examples/api/lib/cupertino/button/cupertino_button.0.dart

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,51 @@
66

77
import 'package:flutter/cupertino.dart';
88

9-
void main() => runApp(const MyApp());
9+
void main() => runApp(const CupertinoButtonApp());
1010

11-
class MyApp extends StatelessWidget {
12-
const MyApp({Key? key}) : super(key: key);
13-
14-
static const String _title = 'Flutter Code Sample';
11+
class CupertinoButtonApp extends StatelessWidget {
12+
const CupertinoButtonApp({Key? key}) : super(key: key);
1513

1614
@override
1715
Widget build(BuildContext context) {
1816
return const CupertinoApp(
19-
title: _title,
20-
home: MyStatelessWidget(),
17+
theme: CupertinoThemeData(brightness: Brightness.light),
18+
home: CupertinoButtonExample(),
2119
);
2220
}
2321
}
2422

25-
class MyStatelessWidget extends StatelessWidget {
26-
const MyStatelessWidget({Key? key}) : super(key: key);
23+
class CupertinoButtonExample extends StatelessWidget {
24+
const CupertinoButtonExample({Key? key}) : super(key: key);
2725

2826
@override
2927
Widget build(BuildContext context) {
30-
return Center(
31-
child: Column(
32-
mainAxisSize: MainAxisSize.min,
33-
children: <Widget>[
34-
const CupertinoButton(
35-
onPressed: null,
36-
child: Text('Disabled'),
37-
),
38-
const SizedBox(height: 30),
39-
const CupertinoButton.filled(
40-
onPressed: null,
41-
child: Text('Disabled'),
42-
),
43-
const SizedBox(height: 30),
44-
CupertinoButton(
45-
onPressed: () {},
46-
child: const Text('Enabled'),
47-
),
48-
const SizedBox(height: 30),
49-
CupertinoButton.filled(
50-
onPressed: () {},
51-
child: const Text('Enabled'),
52-
),
53-
],
28+
return CupertinoPageScaffold(
29+
child: Center(
30+
child: Column(
31+
mainAxisSize: MainAxisSize.min,
32+
children: <Widget>[
33+
const CupertinoButton(
34+
onPressed: null,
35+
child: Text('Disabled'),
36+
),
37+
const SizedBox(height: 30),
38+
const CupertinoButton.filled(
39+
onPressed: null,
40+
child: Text('Disabled'),
41+
),
42+
const SizedBox(height: 30),
43+
CupertinoButton(
44+
onPressed: () {},
45+
child: const Text('Enabled'),
46+
),
47+
const SizedBox(height: 30),
48+
CupertinoButton.filled(
49+
onPressed: () {},
50+
child: const Text('Enabled'),
51+
),
52+
],
53+
),
5454
),
5555
);
5656
}

examples/api/lib/cupertino/date_picker/cupertino_date_picker.0.dart

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,28 @@
66

77
import 'package:flutter/cupertino.dart';
88

9-
void main() => runApp(const MyApp());
9+
void main() => runApp(const DatePickerApp());
1010

11-
class MyApp extends StatelessWidget {
12-
const MyApp({Key? key}) : super(key: key);
13-
14-
static const String _title = 'Flutter Code Sample';
11+
class DatePickerApp extends StatelessWidget {
12+
const DatePickerApp({Key? key}) : super(key: key);
1513

1614
@override
1715
Widget build(BuildContext context) {
1816
return const CupertinoApp(
19-
title: _title,
20-
home: MyStatelessWidget(),
17+
theme: CupertinoThemeData(brightness: Brightness.light),
18+
home: DatePickerExample(),
2119
);
2220
}
2321
}
2422

25-
class MyStatelessWidget extends StatefulWidget {
26-
const MyStatelessWidget({Key? key}) : super(key: key);
23+
class DatePickerExample extends StatefulWidget {
24+
const DatePickerExample({Key? key}) : super(key: key);
2725

2826
@override
29-
State<MyStatelessWidget> createState() => _MyStatelessWidgetState();
27+
State<DatePickerExample> createState() => _DatePickerExampleState();
3028
}
3129

32-
class _MyStatelessWidgetState extends State<MyStatelessWidget> {
30+
class _DatePickerExampleState extends State<DatePickerExample> {
3331
DateTime date = DateTime(2016, 10, 26);
3432
DateTime time = DateTime(2016, 5, 10, 22, 35);
3533
DateTime dateTime = DateTime(2016, 8, 3, 17, 45);

examples/api/lib/cupertino/date_picker/cupertino_timer_picker.0.dart

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,28 @@
66

77
import 'package:flutter/cupertino.dart';
88

9-
void main() => runApp(const MyApp());
9+
void main() => runApp(const TimerPickerApp());
1010

11-
class MyApp extends StatelessWidget {
12-
const MyApp({Key? key}) : super(key: key);
13-
14-
static const String _title = 'CupertinoTimerPicker Sample';
11+
class TimerPickerApp extends StatelessWidget {
12+
const TimerPickerApp({Key? key}) : super(key: key);
1513

1614
@override
1715
Widget build(BuildContext context) {
1816
return const CupertinoApp(
19-
title: _title,
20-
home: CupertinoTimerPickerSample(),
17+
theme: CupertinoThemeData(brightness: Brightness.light),
18+
home: TimerPickerExample(),
2119
);
2220
}
2321
}
2422

25-
class CupertinoTimerPickerSample extends StatefulWidget {
26-
const CupertinoTimerPickerSample({Key? key}) : super(key: key);
23+
class TimerPickerExample extends StatefulWidget {
24+
const TimerPickerExample({Key? key}) : super(key: key);
2725

2826
@override
29-
State<CupertinoTimerPickerSample> createState() => _CupertinoTimerPickerSampleState();
27+
State<TimerPickerExample> createState() => _TimerPickerExampleState();
3028
}
3129

32-
class _CupertinoTimerPickerSampleState extends State<CupertinoTimerPickerSample> {
30+
class _TimerPickerExampleState extends State<TimerPickerExample> {
3331
Duration duration = const Duration(hours: 1, minutes: 23);
3432

3533
// This shows a CupertinoModalPopup with a reasonable fixed height which hosts CupertinoTimerPicker.

examples/api/lib/cupertino/dialog/cupertino_action_sheet.0.dart

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,22 @@
66

77
import 'package:flutter/cupertino.dart';
88

9-
void main() => runApp(const MyApp());
9+
void main() => runApp(const ActionSheetApp());
1010

11-
class MyApp extends StatelessWidget {
12-
const MyApp({Key? key}) : super(key: key);
13-
14-
static const String _title = 'CupertinoActionSheet Sample';
11+
class ActionSheetApp extends StatelessWidget {
12+
const ActionSheetApp({Key? key}) : super(key: key);
1513

1614
@override
1715
Widget build(BuildContext context) {
1816
return const CupertinoApp(
19-
title: _title,
20-
home: ActionSheetSample(title: _title),
17+
theme: CupertinoThemeData(brightness: Brightness.light),
18+
home: ActionSheetExample(),
2119
);
2220
}
2321
}
2422

25-
class ActionSheetSample extends StatelessWidget {
26-
const ActionSheetSample({Key? key, required this.title}) : super(key: key);
27-
28-
final String title;
23+
class ActionSheetExample extends StatelessWidget {
24+
const ActionSheetExample({Key? key}) : super(key: key);
2925

3026
// This shows a CupertinoModalPopup which hosts a CupertinoActionSheet.
3127
void _showActionSheet(BuildContext context) {
@@ -68,8 +64,8 @@ class ActionSheetSample extends StatelessWidget {
6864
@override
6965
Widget build(BuildContext context) {
7066
return CupertinoPageScaffold(
71-
navigationBar: CupertinoNavigationBar(
72-
middle: Text(title),
67+
navigationBar: const CupertinoNavigationBar(
68+
middle: Text('CupertinoActionSheet Sample'),
7369
),
7470
child: Center(
7571
child: CupertinoButton(

examples/api/lib/cupertino/dialog/cupertino_alert_dialog.0.dart

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,22 @@
66

77
import 'package:flutter/cupertino.dart';
88

9-
void main() => runApp(const MyApp());
9+
void main() => runApp(const AlertDialogApp());
1010

11-
class MyApp extends StatelessWidget {
12-
const MyApp({Key? key}) : super(key: key);
13-
14-
static const String _title = 'CupertinoAlertDialog Sample';
11+
class AlertDialogApp extends StatelessWidget {
12+
const AlertDialogApp({Key? key}) : super(key: key);
1513

1614
@override
1715
Widget build(BuildContext context) {
1816
return const CupertinoApp(
19-
title: _title,
20-
home: ActionSheetSample(title: _title),
17+
theme: CupertinoThemeData(brightness: Brightness.light),
18+
home: AlertDialogExample(),
2119
);
2220
}
2321
}
2422

25-
class ActionSheetSample extends StatelessWidget {
26-
const ActionSheetSample({Key? key, required this.title}) : super(key: key);
27-
28-
final String title;
23+
class AlertDialogExample extends StatelessWidget {
24+
const AlertDialogExample({Key? key}) : super(key: key);
2925

3026
// This shows a CupertinoModalPopup which hosts a CupertinoAlertDialog.
3127
void _showAlertDialog(BuildContext context) {
@@ -62,8 +58,8 @@ class ActionSheetSample extends StatelessWidget {
6258
@override
6359
Widget build(BuildContext context) {
6460
return CupertinoPageScaffold(
65-
navigationBar: CupertinoNavigationBar(
66-
middle: Text(title),
61+
navigationBar: const CupertinoNavigationBar(
62+
middle: Text('CupertinoAlertDialog Sample'),
6763
),
6864
child: Center(
6965
child: CupertinoButton(

examples/api/lib/cupertino/nav_bar/cupertino_navigation_bar.0.dart

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,35 @@
66

77
import 'package:flutter/cupertino.dart';
88

9-
void main() => runApp(const MyApp());
9+
void main() => runApp(const NavBarApp());
1010

11-
class MyApp extends StatelessWidget {
12-
const MyApp({Key? key}) : super(key: key);
13-
14-
static const String _title = 'Flutter Code Sample';
11+
class NavBarApp extends StatelessWidget {
12+
const NavBarApp({Key? key}) : super(key: key);
1513

1614
@override
1715
Widget build(BuildContext context) {
1816
return const CupertinoApp(
19-
title: _title,
20-
home: MyStatefulWidget(),
17+
theme: CupertinoThemeData(brightness: Brightness.light),
18+
home: NavBarExample(),
2119
);
2220
}
2321
}
2422

25-
class MyStatefulWidget extends StatefulWidget {
26-
const MyStatefulWidget({Key? key}) : super(key: key);
23+
class NavBarExample extends StatefulWidget {
24+
const NavBarExample({Key? key}) : super(key: key);
2725

2826
@override
29-
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
27+
State<NavBarExample> createState() => _NavBarExampleState();
3028
}
3129

32-
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
30+
class _NavBarExampleState extends State<NavBarExample> {
3331
@override
3432
Widget build(BuildContext context) {
3533
return CupertinoPageScaffold(
3634
navigationBar: CupertinoNavigationBar(
3735
// Try removing opacity to observe the lack of a blur effect and of sliding content.
3836
backgroundColor: CupertinoColors.systemGrey.withOpacity(0.5),
39-
middle: const Text('Sample Code'),
37+
middle: const Text('CupertinoNavigationBar Sample'),
4038
),
4139
child: Column(
4240
children: <Widget>[

examples/api/lib/cupertino/nav_bar/cupertino_sliver_nav_bar.0.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,22 @@
66

77
import 'package:flutter/cupertino.dart';
88

9-
void main() => runApp(const MyApp());
9+
void main() => runApp(const SliverNavBarApp());
1010

11-
class MyApp extends StatelessWidget {
12-
const MyApp({Key? key}) : super(key: key);
13-
14-
static const String _title = 'CupertinoSliverNavigationBar Sample';
11+
class SliverNavBarApp extends StatelessWidget {
12+
const SliverNavBarApp({Key? key}) : super(key: key);
1513

1614
@override
1715
Widget build(BuildContext context) {
1816
return const CupertinoApp(
19-
title: _title,
20-
home: CupertinoNavBarSample(),
17+
theme: CupertinoThemeData(brightness: Brightness.light),
18+
home: SliverNavBarExample(),
2119
);
2220
}
2321
}
2422

25-
class CupertinoNavBarSample extends StatelessWidget {
26-
const CupertinoNavBarSample({Key? key}) : super(key: key);
23+
class SliverNavBarExample extends StatelessWidget {
24+
const SliverNavBarExample({Key? key}) : super(key: key);
2725

2826
@override
2927
Widget build(BuildContext context) {

0 commit comments

Comments
 (0)