Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: sky/framework/components/radio.dart

Issue 993033003: Move example fn widgets into sky/framework/components (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/framework/components/menu_item.dart ('k') | sky/framework/components/toolbar.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 part of widgets; 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 import '../fn.dart';
6 import 'button_base.dart';
7
8 typedef void ValueChanged(value);
2 9
3 class Radio extends ButtonBase { 10 class Radio extends ButtonBase {
4
5 Object value; 11 Object value;
6 Object groupValue; 12 Object groupValue;
7 ValueChanged onChanged; 13 ValueChanged onChanged;
8 14
9 static Style _style = new Style(''' 15 static final Style _style = new Style('''
10 transform: translateX(0); 16 transform: translateX(0);
11 display: inline-block; 17 display: inline-block;
12 -webkit-user-select: none; 18 -webkit-user-select: none;
13 width: 14px; 19 width: 14px;
14 height: 14px; 20 height: 14px;
15 border-radius: 7px; 21 border-radius: 7px;
16 border: 1px solid blue; 22 border: 1px solid blue;
17 margin: 0 5px;''' 23 margin: 0 5px;'''
18 ); 24 );
19 25
20 static Style _highlightStyle = new Style(''' 26 static final Style _highlightStyle = new Style('''
21 transform: translateX(0); 27 transform: translateX(0);
22 display: inline-block; 28 display: inline-block;
23 -webkit-user-select: none; 29 -webkit-user-select: none;
24 width: 14px; 30 width: 14px;
25 height: 14px; 31 height: 14px;
26 border-radius: 7px; 32 border-radius: 7px;
27 border: 1px solid blue; 33 border: 1px solid blue;
28 margin: 0 5px; 34 margin: 0 5px;
29 background-color: orange;''' 35 background-color: orange;'''
30 ); 36 );
31 37
32 static Style _dotStyle = new Style(''' 38 static final Style _dotStyle = new Style('''
33 -webkit-user-select: none; 39 -webkit-user-select: none;
34 width: 10px; 40 width: 10px;
35 height: 10px; 41 height: 10px;
36 border-radius: 5px; 42 border-radius: 5px;
37 background-color: black; 43 background-color: black;
38 margin: 2px;''' 44 margin: 2px;'''
39 ); 45 );
40 46
41 Radio({ 47 Radio({
42 Object key, 48 Object key,
43 this.onChanged, 49 this.onChanged,
44 this.value, 50 this.value,
45 this.groupValue 51 this.groupValue
46 }) : super(key: key); 52 }) : super(key: key) {
53 events.listen('click', _handleClick);
54 }
47 55
48 Node build() { 56 Node build() {
49 return new Container( 57 return new Container(
50 style: _highlight ? _highlightStyle : _style, 58 style: highlight ? _highlightStyle : _style,
51 children: value == groupValue ? 59 children: value == groupValue ?
52 [super.build(), new Container( style : _dotStyle )] : [super.build()] 60 [super.build(), new Container( style : _dotStyle )] : [super.build()]
53 )..events.listen('click', _handleClick); 61 )
54 } 62 }
55 63
56 void _handleClick(_) { 64 void _handleClick(_) {
57 onChanged(value); 65 onChanged(value);
58 } 66 }
59 } 67 }
OLDNEW
« no previous file with comments | « sky/framework/components/menu_item.dart ('k') | sky/framework/components/toolbar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698