Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
194255e5
Commit
194255e5
authored
Oct 26, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1789 from Hixie/ValueChange
Radio<T> and ValueChanged<T>
parents
cdcd3de9
b1dbf452
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
36 deletions
+43
-36
feed.dart
examples/fitness/lib/feed.dart
+1
-1
stock_home.dart
examples/stocks/lib/stock_home.dart
+2
-2
card_collection.dart
examples/widgets/card_collection.dart
+25
-10
checkbox.dart
packages/flutter/lib/src/material/checkbox.dart
+0
-2
date_picker.dart
packages/flutter/lib/src/material/date_picker.dart
+6
-8
input.dart
packages/flutter/lib/src/material/input.dart
+4
-5
radio.dart
packages/flutter/lib/src/material/radio.dart
+5
-6
switch.dart
packages/flutter/lib/src/material/switch.dart
+0
-2
No files found.
examples/fitness/lib/feed.dart
View file @
194255e5
...
...
@@ -243,7 +243,7 @@ class AddItemDialogState extends State<AddItemDialog> {
for
(
String
routeName
in
_labels
.
keys
)
{
menuItems
.
add
(
new
DialogMenuItem
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
_labels
[
routeName
])),
new
Radio
(
value:
routeName
,
groupValue:
_addItemRoute
,
onChanged:
_handleAddItemRouteChanged
),
new
Radio
<
String
>
(
value:
routeName
,
groupValue:
_addItemRoute
,
onChanged:
_handleAddItemRouteChanged
),
],
onPressed:
()
=>
_handleAddItemRouteChanged
(
routeName
)));
}
return
new
Dialog
(
...
...
examples/stocks/lib/stock_home.dart
View file @
194255e5
...
...
@@ -123,7 +123,7 @@ class StockHomeState extends State<StockHome> {
onPressed:
()
=>
_handleStockModeChange
(
StockMode
.
optimistic
),
child:
new
Row
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
'Optimistic'
)),
new
Radio
(
value:
StockMode
.
optimistic
,
groupValue:
config
.
stockMode
,
onChanged:
_handleStockModeChange
)
new
Radio
<
StockMode
>
(
value:
StockMode
.
optimistic
,
groupValue:
config
.
stockMode
,
onChanged:
_handleStockModeChange
)
])
),
new
DrawerItem
(
...
...
@@ -131,7 +131,7 @@ class StockHomeState extends State<StockHome> {
onPressed:
()
=>
_handleStockModeChange
(
StockMode
.
pessimistic
),
child:
new
Row
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
'Pessimistic'
)),
new
Radio
(
value:
StockMode
.
pessimistic
,
groupValue:
config
.
stockMode
,
onChanged:
_handleStockModeChange
)
new
Radio
<
StockMode
>
(
value:
StockMode
.
pessimistic
,
groupValue:
config
.
stockMode
,
onChanged:
_handleStockModeChange
)
])
),
new
DrawerDivider
(),
...
...
examples/widgets/card_collection.dart
View file @
194255e5
...
...
@@ -124,14 +124,14 @@ class CardCollectionState extends State<CardCollection> {
buildDrawerCheckbox
(
"Fixed size cards"
,
_fixedSizeCards
,
_toggleFixedSizeCards
),
buildDrawerCheckbox
(
"Let the sun shine"
,
_sunshine
,
_toggleSunshine
),
new
DrawerDivider
(),
buildDrawerRadioItem
(
"Deep Purple"
,
Colors
.
deepPurple
,
_primaryColor
,
_selectColor
),
buildDrawerRadioItem
(
"Green"
,
Colors
.
green
,
_primaryColor
,
_selectColor
),
buildDrawerRadioItem
(
"Amber"
,
Colors
.
amber
,
_primaryColor
,
_selectColor
),
buildDrawerRadioItem
(
"Teal"
,
Colors
.
teal
,
_primaryColor
,
_selectColor
),
buildDrawer
Color
RadioItem
(
"Deep Purple"
,
Colors
.
deepPurple
,
_primaryColor
,
_selectColor
),
buildDrawer
Color
RadioItem
(
"Green"
,
Colors
.
green
,
_primaryColor
,
_selectColor
),
buildDrawer
Color
RadioItem
(
"Amber"
,
Colors
.
amber
,
_primaryColor
,
_selectColor
),
buildDrawer
Color
RadioItem
(
"Teal"
,
Colors
.
teal
,
_primaryColor
,
_selectColor
),
new
DrawerDivider
(),
buildDrawerRadioItem
(
"Dismiss horizontally"
,
DismissDirection
.
horizontal
,
_dismissDirection
,
_changeDismissDirection
,
icon:
'action/code'
),
buildDrawerRadioItem
(
"Dismiss left"
,
DismissDirection
.
left
,
_dismissDirection
,
_changeDismissDirection
,
icon:
'navigation/arrow_back'
),
buildDrawerRadioItem
(
"Dismiss right"
,
DismissDirection
.
right
,
_dismissDirection
,
_changeDismissDirection
,
icon:
'navigation/arrow_forward'
),
buildDrawer
Direction
RadioItem
(
"Dismiss horizontally"
,
DismissDirection
.
horizontal
,
_dismissDirection
,
_changeDismissDirection
,
icon:
'action/code'
),
buildDrawer
Direction
RadioItem
(
"Dismiss left"
,
DismissDirection
.
left
,
_dismissDirection
,
_changeDismissDirection
,
icon:
'navigation/arrow_back'
),
buildDrawer
Direction
RadioItem
(
"Dismiss right"
,
DismissDirection
.
right
,
_dismissDirection
,
_changeDismissDirection
,
icon:
'navigation/arrow_forward'
),
])
)
);
...
...
@@ -161,7 +161,7 @@ class CardCollectionState extends State<CardCollection> {
});
}
void
_selectColor
(
selection
)
{
void
_selectColor
(
Map
<
int
,
Color
>
selection
)
{
setState
(()
{
_primaryColor
=
selection
;
});
...
...
@@ -184,13 +184,28 @@ class CardCollectionState extends State<CardCollection> {
);
}
Widget
buildDrawer
RadioItem
(
String
label
,
itemValue
,
currentValue
,
RadioValueChanged
onChanged
,
{
String
icon
})
{
Widget
buildDrawer
ColorRadioItem
(
String
label
,
Map
<
int
,
Color
>
itemValue
,
Map
<
int
,
Color
>
currentValue
,
ValueChanged
<
Map
<
int
,
Color
>>
onChanged
,
{
String
icon
})
{
return
new
DrawerItem
(
icon:
icon
,
onPressed:
()
{
onChanged
(
itemValue
);
},
child:
new
Row
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
label
)),
new
Radio
(
new
Radio
<
Map
<
int
,
Color
>>(
value:
itemValue
,
groupValue:
currentValue
,
onChanged:
onChanged
)
])
);
}
Widget
buildDrawerDirectionRadioItem
(
String
label
,
DismissDirection
itemValue
,
DismissDirection
currentValue
,
ValueChanged
<
DismissDirection
>
onChanged
,
{
String
icon
})
{
return
new
DrawerItem
(
icon:
icon
,
onPressed:
()
{
onChanged
(
itemValue
);
},
child:
new
Row
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
label
)),
new
Radio
<
DismissDirection
>(
value:
itemValue
,
groupValue:
currentValue
,
onChanged:
onChanged
...
...
packages/flutter/lib/src/material/checkbox.dart
View file @
194255e5
...
...
@@ -9,8 +9,6 @@ import 'package:flutter/widgets.dart';
import
'theme.dart'
;
export
'package:flutter/rendering.dart'
show
ValueChanged
;
const
double
_kMidpoint
=
0.5
;
const
Color
_kLightUncheckedColor
=
const
Color
(
0x8A000000
);
const
Color
_kDarkUncheckedColor
=
const
Color
(
0xB2FFFFFF
);
...
...
packages/flutter/lib/src/material/date_picker.dart
View file @
194255e5
...
...
@@ -4,18 +4,16 @@
import
'dart:async'
;
import
'package:intl/date_symbols.dart'
;
import
'package:intl/intl.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:intl/date_symbols.dart'
;
import
'package:intl/intl.dart'
;
import
'colors.dart'
;
import
'ink_well.dart'
;
import
'theme.dart'
;
import
'typography.dart'
;
typedef
void
DatePickerValueChanged
(
DateTime
dateTime
);
enum
DatePickerMode
{
day
,
year
}
typedef
void
DatePickerModeChanged
(
DatePickerMode
value
);
...
...
@@ -33,7 +31,7 @@ class DatePicker extends StatefulComponent {
}
final
DateTime
selectedDate
;
final
DatePickerValueChanged
onChanged
;
final
ValueChanged
<
DateTime
>
onChanged
;
final
DateTime
firstDate
;
final
DateTime
lastDate
;
...
...
@@ -176,7 +174,7 @@ class DayPicker extends StatelessComponent {
final
DateTime
selectedDate
;
final
DateTime
currentDate
;
final
DatePickerValueChanged
onChanged
;
final
ValueChanged
<
DateTime
>
onChanged
;
final
DateTime
displayedMonth
;
Widget
build
(
BuildContext
context
)
{
...
...
@@ -282,7 +280,7 @@ class MonthPicker extends ScrollableWidgetList {
}
final
DateTime
selectedDate
;
final
DatePickerValueChanged
onChanged
;
final
ValueChanged
<
DateTime
>
onChanged
;
final
DateTime
firstDate
;
final
DateTime
lastDate
;
...
...
@@ -355,7 +353,7 @@ class YearPicker extends ScrollableWidgetList {
}
final
DateTime
selectedDate
;
final
DatePickerValueChanged
onChanged
;
final
ValueChanged
<
DateTime
>
onChanged
;
final
DateTime
firstDate
;
final
DateTime
lastDate
;
...
...
packages/flutter/lib/src/material/input.dart
View file @
194255e5
...
...
@@ -3,16 +3,15 @@
// found in the LICENSE file.
import
'package:flutter/animation.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'theme.dart'
;
export
'package:flutter/rendering.dart'
show
ValueChanged
;
export
'package:flutter/services.dart'
show
KeyboardType
;
typedef
void
StringValueChanged
(
String
value
);
typedef
void
StringValueSubmitted
(
String
value
);
// TODO(eseidel): This isn't right, it's 16px on the bottom:
// http://www.google.com/design/spec/components/text-fields.html#text-fields-single-line-text-field
const
EdgeDims
_kTextfieldPadding
=
const
EdgeDims
.
symmetric
(
vertical:
8.0
);
...
...
@@ -34,8 +33,8 @@ class Input extends Scrollable {
final
String
initialValue
;
final
KeyboardType
keyboardType
;
final
String
placeholder
;
final
StringValueChanged
onChanged
;
final
StringValueSubmitted
onSubmitted
;
final
ValueChanged
<
String
>
onChanged
;
final
ValueChanged
<
String
>
onSubmitted
;
InputState
createState
()
=>
new
InputState
();
}
...
...
packages/flutter/lib/src/material/radio.dart
View file @
194255e5
...
...
@@ -11,9 +11,7 @@ import 'theme.dart';
const
Color
_kLightOffColor
=
const
Color
(
0x8A000000
);
const
Color
_kDarkOffColor
=
const
Color
(
0xB2FFFFFF
);
typedef
void
RadioValueChanged
(
Object
value
);
class
Radio
extends
StatelessComponent
{
class
Radio
<
T
>
extends
StatelessComponent
{
Radio
({
Key
key
,
this
.
value
,
...
...
@@ -23,9 +21,9 @@ class Radio extends StatelessComponent {
assert
(
onChanged
!=
null
);
}
final
Object
value
;
final
Object
groupValue
;
final
RadioValueChanged
onChanged
;
final
T
value
;
final
T
groupValue
;
final
ValueChanged
<
T
>
onChanged
;
Color
_getColor
(
BuildContext
context
)
{
ThemeData
themeData
=
Theme
.
of
(
context
);
...
...
@@ -59,6 +57,7 @@ class Radio extends StatelessComponent {
paint
.
style
=
ui
.
PaintingStyle
.
fill
;
canvas
.
drawCircle
(
const
Point
(
kOuterRadius
,
kOuterRadius
),
kInnerRadius
,
paint
);
}
}
)
)
...
...
packages/flutter/lib/src/material/switch.dart
View file @
194255e5
...
...
@@ -13,8 +13,6 @@ import 'radial_reaction.dart';
import
'shadows.dart'
;
import
'theme.dart'
;
export
'package:flutter/rendering.dart'
show
ValueChanged
;
const
Color
_kThumbOffColor
=
const
Color
(
0xFFFAFAFA
);
const
Color
_kTrackOffColor
=
const
Color
(
0x42000000
);
const
double
_kSwitchWidth
=
35.0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment