Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Cupertino demo improvements #667

Merged
merged 6 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
536 changes: 128 additions & 408 deletions lib/codeviewer/code_segments.dart

Large diffs are not rendered by default.

20 changes: 0 additions & 20 deletions lib/data/demos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1110,26 +1110,6 @@ List<GalleryDemo> cupertinoDemos(GalleryLocalizations localizations) {
],
category: GalleryDemoCategory.cupertino,
),
GalleryDemo(
title: localizations.demoCupertinoPullToRefreshTitle,
icon: GalleryIcons.cupertinoPullToRefresh,
slug: 'cupertino-pull-to-refresh',
subtitle: localizations.demoCupertinoPullToRefreshSubtitle,
configurations: [
GalleryDemoConfiguration(
title: localizations.demoCupertinoPullToRefreshTitle,
description: localizations.demoCupertinoPullToRefreshDescription,
documentationUrl:
'$_docsBaseUrl/cupertino/CupertinoSliverRefreshControl-class.html',
buildRoute: (_) => DeferredWidget(
cupertinoLoader,
// ignore: prefer_const_constructors
() => cupertino_demos.CupertinoRefreshControlDemo()),
code: CodeSegments.cupertinoRefreshDemo,
),
],
category: GalleryDemoCategory.cupertino,
),
GalleryDemo(
title: localizations.demoCupertinoSegmentedControlTitle,
icon: GalleryIcons.tabs,
Expand Down
16 changes: 15 additions & 1 deletion lib/demos/cupertino/cupertino_button_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

import 'package:flutter/cupertino.dart';

import 'package:flutter_gen/gen_l10n/gallery_localizations.dart';

// BEGIN cupertinoButtonDemo
Expand Down Expand Up @@ -36,6 +35,21 @@ class CupertinoButtonDemo extends StatelessWidget {
localizations.cupertinoButtonWithBackground,
),
),
const SizedBox(height: 30),
// Disabled buttons
CupertinoButton(
onPressed: null,
child: Text(
localizations.cupertinoButton,
),
),
const SizedBox(height: 16),
CupertinoButton.filled(
onPressed: null,
child: Text(
localizations.cupertinoButtonWithBackground,
),
),
],
),
),
Expand Down
1 change: 0 additions & 1 deletion lib/demos/cupertino/cupertino_demos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export 'package:gallery/demos/cupertino/cupertino_button_demo.dart';
export 'package:gallery/demos/cupertino/cupertino_context_menu_demo.dart';
export 'package:gallery/demos/cupertino/cupertino_navigation_bar_demo.dart';
export 'package:gallery/demos/cupertino/cupertino_picker_demo.dart';
export 'package:gallery/demos/cupertino/cupertino_refresh_demo.dart';
export 'package:gallery/demos/cupertino/cupertino_segmented_control_demo.dart';
export 'package:gallery/demos/cupertino/cupertino_slider_demo.dart';
export 'package:gallery/demos/cupertino/cupertino_switch_demo.dart';
Expand Down
16 changes: 9 additions & 7 deletions lib/demos/cupertino/cupertino_picker_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
),
);
},
child: _Menu(children: [
Text(GalleryLocalizations.of(context)!.demoCupertinoPickerDate),
Text(
DateFormat.yMMMMd().format(date),
style: const TextStyle(color: CupertinoColors.inactiveGray),
),
]),
child: _Menu(
children: [
Text(GalleryLocalizations.of(context)!.demoCupertinoPickerDate),
Text(
DateFormat.yMMMMd().format(date),
style: const TextStyle(color: CupertinoColors.inactiveGray),
),
],
),
guidezpl marked this conversation as resolved.
Show resolved Hide resolved
),
);
}
Expand Down
76 changes: 0 additions & 76 deletions lib/demos/cupertino/cupertino_refresh_demo.dart

This file was deleted.

24 changes: 16 additions & 8 deletions lib/demos/cupertino/cupertino_switch_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

import 'package:flutter/cupertino.dart';

import 'package:flutter_gen/gen_l10n/gallery_localizations.dart';

// BEGIN cupertinoSwitchDemo
Expand Down Expand Up @@ -41,13 +40,22 @@ class _CupertinoSwitchDemoState extends State<CupertinoSwitchDemo>
child: Semantics(
container: true,
label: localizations.demoSelectionControlsSwitchTitle,
child: CupertinoSwitch(
value: _switchValue.value,
onChanged: (value) {
setState(() {
_switchValue.value = value;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CupertinoSwitch(
value: _switchValue.value,
onChanged: (value) {
setState(() {
_switchValue.value = value;
});
},
),
CupertinoSwitch(
value: _switchValue.value,
onChanged: null,
),
],
),
),
),
Expand Down
7 changes: 5 additions & 2 deletions test/code_segments_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import '../tool/codeviewer_cli/segment_generator.dart';
import 'utils.dart';

void main() {
bool _compareCodeSegments(String a, String b) {
return standardizeLineEndings(a) == standardizeLineEndings(b);
}

test('verify code segments are up to date', () async {
final currentCodeSegments = readCodeSegments();
var newCodeSegments = await getCodeSegments();

expect(standardizeLineEndings(newCodeSegments),
standardizeLineEndings(currentCodeSegments),
expect(_compareCodeSegments(currentCodeSegments, newCodeSegments), true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how this change simplifies the log!

reason: 'code_segments.dart is not up to date. '
'Did you forget to run `flutter pub run grinder update-code-segments`?');
});
Expand Down
Binary file modified test_goldens/goldens/demo_desktop_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_goldens/goldens/demo_desktop_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_goldens/goldens/home_page_desktop_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_goldens/goldens/home_page_desktop_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_goldens/goldens/home_page_mobile_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_goldens/goldens/home_page_mobile_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_goldens/goldens/shrine_desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_goldens/goldens/shrine_mobile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.