Implement Cupertino switch and slider demos (#196)

pull/201/head
rami-a 5 years ago committed by GitHub
parent b7b3c2c6c5
commit f72ed43ac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

File diff suppressed because it is too large Load Diff

@ -10,8 +10,10 @@ import 'package:gallery/data/gallery_options.dart';
import 'package:gallery/data/icons.dart'; import 'package:gallery/data/icons.dart';
import 'package:gallery/demos/cupertino/cupertino_alert_demo.dart'; import 'package:gallery/demos/cupertino/cupertino_alert_demo.dart';
import 'package:gallery/demos/cupertino/cupertino_button_demo.dart'; import 'package:gallery/demos/cupertino/cupertino_button_demo.dart';
import 'package:gallery/demos/cupertino/cupertino_tab_bar_demo.dart';
import 'package:gallery/demos/cupertino/cupertino_segmented_control_demo.dart'; import 'package:gallery/demos/cupertino/cupertino_segmented_control_demo.dart';
import 'package:gallery/demos/cupertino/cupertino_slider_demo.dart';
import 'package:gallery/demos/cupertino/cupertino_switch_demo.dart';
import 'package:gallery/demos/cupertino/cupertino_tab_bar_demo.dart';
import 'package:gallery/demos/material/bottom_navigation_demo.dart'; import 'package:gallery/demos/material/bottom_navigation_demo.dart';
import 'package:gallery/demos/material/bottom_sheet_demo.dart'; import 'package:gallery/demos/material/bottom_sheet_demo.dart';
import 'package:gallery/demos/material/button_demo.dart'; import 'package:gallery/demos/material/button_demo.dart';
@ -467,6 +469,39 @@ List<GalleryDemo> cupertinoDemos(BuildContext context) {
), ),
], ],
), ),
GalleryDemo(
title: GalleryLocalizations.of(context).demoCupertinoSliderTitle,
icon: GalleryIcons.sliders,
subtitle: GalleryLocalizations.of(context).demoCupertinoSliderSubtitle,
configurations: [
GalleryDemoConfiguration(
title: GalleryLocalizations.of(context).demoCupertinoSliderTitle,
description:
GalleryLocalizations.of(context).demoCupertinoSliderDescription,
documentationUrl:
'https://api.flutter.dev/flutter/cupertino/CupertinoSlider-class.html',
buildRoute: (_) => CupertinoSliderDemo(),
code: CodeSegments.cupertinoSliderDemo,
),
],
),
GalleryDemo(
title: GalleryLocalizations.of(context).demoSelectionControlsSwitchTitle,
icon: GalleryIcons.switches,
subtitle: GalleryLocalizations.of(context).demoCupertinoSwitchSubtitle,
configurations: [
GalleryDemoConfiguration(
title:
GalleryLocalizations.of(context).demoSelectionControlsSwitchTitle,
description:
GalleryLocalizations.of(context).demoCupertinoSwitchDescription,
documentationUrl:
'https://api.flutter.dev/flutter/cupertino/CupertinoSwitch-class.html',
buildRoute: (_) => CupertinoSwitchDemo(),
code: CodeSegments.cupertinoSwitchDemo,
),
],
),
GalleryDemo( GalleryDemo(
title: GalleryLocalizations.of(context).demoCupertinoTabBarTitle, title: GalleryLocalizations.of(context).demoCupertinoTabBarTitle,
icon: GalleryIcons.bottomNavigation, icon: GalleryIcons.bottomNavigation,

@ -0,0 +1,93 @@
// Copyright 2019 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/cupertino.dart';
import 'package:gallery/l10n/gallery_localizations.dart';
// BEGIN cupertinoSliderDemo
class CupertinoSliderDemo extends StatefulWidget {
@override
_CupertinoSliderDemoState createState() => _CupertinoSliderDemoState();
}
class _CupertinoSliderDemoState extends State<CupertinoSliderDemo> {
double _value = 25.0;
double _discreteValue = 20.0;
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text(GalleryLocalizations.of(context).demoCupertinoSliderTitle),
),
child: DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: double.infinity,
child: CupertinoSlider(
value: _value,
min: 0.0,
max: 100.0,
onChanged: (value) {
setState(() {
_value = value;
});
},
),
),
MergeSemantics(
child: Text(
GalleryLocalizations.of(context)
.demoCupertinoSliderContinuous(
_value.toStringAsFixed(1),
),
),
),
],
),
Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: double.infinity,
child: CupertinoSlider(
value: _discreteValue,
min: 0.0,
max: 100.0,
divisions: 5,
onChanged: (value) {
setState(() {
_discreteValue = value;
});
},
),
),
MergeSemantics(
child: Text(
GalleryLocalizations.of(context)
.demoCupertinoSliderDiscrete(
_discreteValue.toStringAsFixed(1),
),
),
),
],
),
],
),
),
),
);
}
}
// END

@ -0,0 +1,46 @@
// Copyright 2019 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/cupertino.dart';
import 'package:gallery/l10n/gallery_localizations.dart';
// BEGIN cupertinoSwitchDemo
class CupertinoSwitchDemo extends StatefulWidget {
@override
_CupertinoSwitchDemoState createState() => _CupertinoSwitchDemoState();
}
class _CupertinoSwitchDemoState extends State<CupertinoSwitchDemo> {
bool _switchValue = false;
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text(
GalleryLocalizations.of(context).demoSelectionControlsSwitchTitle,
),
),
child: Center(
child: Semantics(
container: true,
label:
GalleryLocalizations.of(context).demoSelectionControlsSwitchTitle,
child: CupertinoSwitch(
value: _switchValue,
onChanged: (value) {
setState(() {
_switchValue = value;
});
},
),
),
),
);
}
}
// END

@ -155,13 +155,18 @@ class _SwitchDemoState extends State<_SwitchDemo> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Center( return Center(
child: Switch( child: Semantics(
value: switchValue, container: true,
onChanged: (value) { label:
setState(() { GalleryLocalizations.of(context).demoSelectionControlsSwitchTitle,
switchValue = value; child: Switch(
}); value: switchValue,
}, onChanged: (value) {
setState(() {
switchValue = value;
});
},
),
), ),
); );
} }

@ -1560,6 +1560,61 @@ class GalleryLocalizations {
desc: r'Title for the cupertino segmented control component demo.'); desc: r'Title for the cupertino segmented control component demo.');
} }
String demoCupertinoSliderContinuous(Object value) {
return Intl.message(r'Continuous: $value',
locale: _localeName,
name: 'demoCupertinoSliderContinuous',
desc:
r'A label for a continuous slider that indicates what value it is set to.',
args: <Object>[value]);
}
String get demoCupertinoSliderDescription {
return Intl.message(
r'A slider can be used to select from either a continuous or a discrete set of values.',
locale: _localeName,
name: 'demoCupertinoSliderDescription',
desc: r'Description for the cupertino slider component demo.');
}
String demoCupertinoSliderDiscrete(Object value) {
return Intl.message(r'Discrete: $value',
locale: _localeName,
name: 'demoCupertinoSliderDiscrete',
desc:
r'A label for a discrete slider that indicates what value it is set to.',
args: <Object>[value]);
}
String get demoCupertinoSliderSubtitle {
return Intl.message(r'iOS-style slider',
locale: _localeName,
name: 'demoCupertinoSliderSubtitle',
desc: r'Subtitle for the cupertino slider component demo.');
}
String get demoCupertinoSliderTitle {
return Intl.message(r'Slider',
locale: _localeName,
name: 'demoCupertinoSliderTitle',
desc: r'Title for the cupertino slider component demo.');
}
String get demoCupertinoSwitchDescription {
return Intl.message(
r'A switch is used to toggle the on/off state of a single setting.',
locale: _localeName,
name: 'demoCupertinoSwitchDescription',
desc: r'Description for the cupertino switch component demo.');
}
String get demoCupertinoSwitchSubtitle {
return Intl.message(r'iOS-style switch',
locale: _localeName,
name: 'demoCupertinoSwitchSubtitle',
desc: r'Subtitle for the cupertino switch component demo.');
}
String get demoCupertinoTabBarDescription { String get demoCupertinoTabBarDescription {
return Intl.message( return Intl.message(
r'An iOS-style bottom navigation tab bar. Displays multiple tabs with one tab being active, the first tab by default.', r'An iOS-style bottom navigation tab bar. Displays multiple tabs with one tab being active, the first tab by default.',

@ -645,6 +645,44 @@
"@demoCupertinoSegmentedControlDescription": { "@demoCupertinoSegmentedControlDescription": {
"description": "Description for the cupertino segmented control component demo." "description": "Description for the cupertino segmented control component demo."
}, },
"demoCupertinoSliderTitle": "Slider",
"@demoCupertinoSliderTitle": {
"description": "Title for the cupertino slider component demo."
},
"demoCupertinoSliderSubtitle": "iOS-style slider",
"@demoCupertinoSliderSubtitle": {
"description": "Subtitle for the cupertino slider component demo."
},
"demoCupertinoSliderDescription": "A slider can be used to select from either a continuous or a discrete set of values.",
"@demoCupertinoSliderDescription": {
"description": "Description for the cupertino slider component demo."
},
"demoCupertinoSliderContinuous": "Continuous: {value}",
"@demoCupertinoSliderContinuous": {
"description": "A label for a continuous slider that indicates what value it is set to.",
"placeholders": {
"value": {
"example": "1"
}
}
},
"demoCupertinoSliderDiscrete": "Discrete: {value}",
"@demoCupertinoSliderDiscrete": {
"description": "A label for a discrete slider that indicates what value it is set to.",
"placeholders": {
"value": {
"example": "1"
}
}
},
"demoCupertinoSwitchSubtitle": "iOS-style switch",
"@demoCupertinoSwitchSubtitle": {
"description": "Subtitle for the cupertino switch component demo."
},
"demoCupertinoSwitchDescription": "A switch is used to toggle the on/off state of a single setting.",
"@demoCupertinoSwitchDescription": {
"description": "Description for the cupertino switch component demo."
},
"demoCupertinoTabBarTitle": "Tab Bar", "demoCupertinoTabBarTitle": "Tab Bar",
"@demoCupertinoTabBarTitle": { "@demoCupertinoTabBarTitle": {
"description": "Title for the cupertino bottom tab bar demo." "description": "Title for the cupertino bottom tab bar demo."

@ -609,6 +609,34 @@
name="demoCupertinoSegmentedControlDescription" name="demoCupertinoSegmentedControlDescription"
description="Description for the cupertino segmented control component demo." description="Description for the cupertino segmented control component demo."
>Used to select between a number of mutually exclusive options. When one option in the segmented control is selected, the other options in the segmented control cease to be selected.</string> >Used to select between a number of mutually exclusive options. When one option in the segmented control is selected, the other options in the segmented control cease to be selected.</string>
<string
name="demoCupertinoSliderTitle"
description="Title for the cupertino slider component demo."
>Slider</string>
<string
name="demoCupertinoSliderSubtitle"
description="Subtitle for the cupertino slider component demo."
>iOS-style slider</string>
<string
name="demoCupertinoSliderDescription"
description="Description for the cupertino slider component demo."
>A slider can be used to select from either a continuous or a discrete set of values.</string>
<string
name="demoCupertinoSliderContinuous"
description="A label for a continuous slider that indicates what value it is set to."
>Continuous: {value}</string>
<string
name="demoCupertinoSliderDiscrete"
description="A label for a discrete slider that indicates what value it is set to."
>Discrete: {value}</string>
<string
name="demoCupertinoSwitchSubtitle"
description="Subtitle for the cupertino switch component demo."
>iOS-style switch</string>
<string
name="demoCupertinoSwitchDescription"
description="Description for the cupertino switch component demo."
>A switch is used to toggle the on/off state of a single setting.</string>
<string <string
name="demoCupertinoTabBarTitle" name="demoCupertinoTabBarTitle"
description="Title for the cupertino bottom tab bar demo." description="Title for the cupertino bottom tab bar demo."

@ -37,6 +37,10 @@ class MessageLookup extends MessageLookupByLibrary {
static m6(error) => "Failed to copy to clipboard: ${error}"; static m6(error) => "Failed to copy to clipboard: ${error}";
static m23(value) => "Continuous: ${value}";
static m24(value) => "Discrete: ${value}";
static m7(name, phoneNumber) => "${name} phone number is ${phoneNumber}"; static m7(name, phoneNumber) => "${name} phone number is ${phoneNumber}";
static m8(value) => "You selected: \"${value}\""; static m8(value) => "You selected: \"${value}\"";
@ -400,6 +404,18 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("iOS-style segmented control"), MessageLookupByLibrary.simpleMessage("iOS-style segmented control"),
"demoCupertinoSegmentedControlTitle": "demoCupertinoSegmentedControlTitle":
MessageLookupByLibrary.simpleMessage("Segmented Control"), MessageLookupByLibrary.simpleMessage("Segmented Control"),
"demoCupertinoSliderContinuous": m23,
"demoCupertinoSliderDescription": MessageLookupByLibrary.simpleMessage(
"A slider can be used to select from either a continuous or a discrete set of values."),
"demoCupertinoSliderDiscrete": m24,
"demoCupertinoSliderSubtitle":
MessageLookupByLibrary.simpleMessage("iOS-style slider"),
"demoCupertinoSliderTitle":
MessageLookupByLibrary.simpleMessage("Slider"),
"demoCupertinoSwitchDescription": MessageLookupByLibrary.simpleMessage(
"A switch is used to toggle the on/off state of a single setting."),
"demoCupertinoSwitchSubtitle":
MessageLookupByLibrary.simpleMessage("iOS-style switch"),
"demoCupertinoTabBarDescription": MessageLookupByLibrary.simpleMessage( "demoCupertinoTabBarDescription": MessageLookupByLibrary.simpleMessage(
"An iOS-style bottom navigation tab bar. Displays multiple tabs with one tab being active, the first tab by default."), "An iOS-style bottom navigation tab bar. Displays multiple tabs with one tab being active, the first tab by default."),
"demoCupertinoTabBarSubtitle": "demoCupertinoTabBarSubtitle":

Loading…
Cancel
Save