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
9ac68307
Commit
9ac68307
authored
Jul 23, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #244 from Hixie/focus
Add a dialog to the address book app to test scoped focus.
parents
1570b172
2694d675
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
14 deletions
+69
-14
main.dart
packages/flutter/example/address_book/lib/main.dart
+69
-14
No files found.
packages/flutter/example/address_book/lib/main.dart
View file @
9ac68307
...
@@ -7,11 +7,14 @@ import 'package:sky/theme/colors.dart' as colors;
...
@@ -7,11 +7,14 @@ import 'package:sky/theme/colors.dart' as colors;
import
'package:sky/theme/typography.dart'
as
typography
;
import
'package:sky/theme/typography.dart'
as
typography
;
import
'package:sky/widgets/basic.dart'
;
import
'package:sky/widgets/basic.dart'
;
import
'package:sky/widgets/default_text_style.dart'
;
import
'package:sky/widgets/default_text_style.dart'
;
import
'package:sky/widgets/dialog.dart'
;
import
'package:sky/widgets/floating_action_button.dart'
;
import
'package:sky/widgets/floating_action_button.dart'
;
import
'package:sky/widgets/flat_button.dart'
;
import
'package:sky/widgets/focus.dart'
;
import
'package:sky/widgets/focus.dart'
;
import
'package:sky/widgets/icon.dart'
;
import
'package:sky/widgets/icon.dart'
;
import
'package:sky/widgets/icon_button.dart'
;
import
'package:sky/widgets/icon_button.dart'
;
import
'package:sky/widgets/material.dart'
;
import
'package:sky/widgets/material.dart'
;
import
'package:sky/widgets/navigator.dart'
;
import
'package:sky/widgets/scaffold.dart'
;
import
'package:sky/widgets/scaffold.dart'
;
import
'package:sky/widgets/scrollable_viewport.dart'
;
import
'package:sky/widgets/scrollable_viewport.dart'
;
import
'package:sky/widgets/task_description.dart'
;
import
'package:sky/widgets/task_description.dart'
;
...
@@ -51,17 +54,23 @@ class Field extends Component {
...
@@ -51,17 +54,23 @@ class Field extends Component {
class
AddressBookApp
extends
App
{
class
AddressBookApp
extends
App
{
Widget
buildToolBar
()
{
Widget
buildToolBar
(
Navigator
navigator
)
{
return
new
ToolBar
(
return
new
ToolBar
(
left:
new
IconButton
(
icon:
"navigation/arrow_back"
),
left:
new
IconButton
(
icon:
"navigation/arrow_back"
),
right:
[
new
IconButton
(
icon:
"navigation/check"
)]
right:
[
new
IconButton
(
icon:
"navigation/check"
)]
);
);
}
}
Widget
buildFloatingActionButton
()
{
Widget
buildFloatingActionButton
(
Navigator
navigator
)
{
return
new
FloatingActionButton
(
return
new
FloatingActionButton
(
child:
new
Icon
(
type:
'image/photo_camera'
,
size:
24
),
child:
new
Icon
(
type:
'image/photo_camera'
,
size:
24
),
backgroundColor:
Theme
.
of
(
this
).
accentColor
backgroundColor:
Theme
.
of
(
this
).
accentColor
,
onPressed:
()
{
showDialog
=
true
;
navigator
.
pushState
(
this
,
(
_
)
{
showDialog
=
false
;
});
}
);
);
}
}
...
@@ -71,8 +80,10 @@ class AddressBookApp extends App {
...
@@ -71,8 +80,10 @@ class AddressBookApp extends App {
static
final
GlobalKey
addressKey
=
new
GlobalKey
();
static
final
GlobalKey
addressKey
=
new
GlobalKey
();
static
final
GlobalKey
ringtoneKey
=
new
GlobalKey
();
static
final
GlobalKey
ringtoneKey
=
new
GlobalKey
();
static
final
GlobalKey
noteKey
=
new
GlobalKey
();
static
final
GlobalKey
noteKey
=
new
GlobalKey
();
static
final
GlobalKey
fillKey
=
new
GlobalKey
();
static
final
GlobalKey
emoticonKey
=
new
GlobalKey
();
Widget
buildBody
()
{
Widget
buildBody
(
Navigator
navigator
)
{
return
new
Material
(
return
new
Material
(
child:
new
ScrollableBlock
([
child:
new
ScrollableBlock
([
new
AspectRatio
(
new
AspectRatio
(
...
@@ -91,12 +102,59 @@ class AddressBookApp extends App {
...
@@ -91,12 +102,59 @@ class AddressBookApp extends App {
);
);
}
}
Widget
buildMain
()
{
bool
showDialog
=
false
;
return
new
Scaffold
(
toolbar:
buildToolBar
(),
Widget
buildMain
(
Navigator
navigator
)
{
body:
buildBody
(),
List
<
Widget
>
layers
=
[
floatingActionButton:
buildFloatingActionButton
()
new
Focus
(
);
initialFocus:
nameKey
,
child:
new
Scaffold
(
toolbar:
buildToolBar
(
navigator
),
body:
buildBody
(
navigator
),
floatingActionButton:
buildFloatingActionButton
(
navigator
)
)
)
];
if
(
showDialog
)
{
layers
.
add
(
new
Focus
(
initialFocus:
fillKey
,
child:
new
Dialog
(
title:
new
Text
(
"Describe your picture"
),
content:
new
ScrollableBlock
([
new
Field
(
inputKey:
fillKey
,
icon:
"editor/format_color_fill"
,
placeholder:
"Color"
),
new
Field
(
inputKey:
emoticonKey
,
icon:
"editor/insert_emoticon"
,
placeholder:
"Emotion"
),
]),
onDismiss:
navigator
.
pop
,
actions:
[
new
FlatButton
(
child:
new
Text
(
'DISCARD'
),
onPressed:
()
{
navigator
.
pop
();
}
),
new
FlatButton
(
child:
new
Text
(
'SAVE'
),
onPressed:
()
{
navigator
.
pop
();
}
),
]
)
));
}
return
new
Stack
(
layers
);
}
NavigationState
_navigationState
;
void
initState
()
{
_navigationState
=
new
NavigationState
([
new
Route
(
name:
'/'
,
builder:
(
navigator
,
route
)
=>
buildMain
(
navigator
)
),
]);
super
.
initState
();
}
}
Widget
build
()
{
Widget
build
()
{
...
@@ -111,10 +169,7 @@ class AddressBookApp extends App {
...
@@ -111,10 +169,7 @@ class AddressBookApp extends App {
style:
typography
.
error
,
// if you see this, you've forgotten to correctly configure the text style!
style:
typography
.
error
,
// if you see this, you've forgotten to correctly configure the text style!
child:
new
TaskDescription
(
child:
new
TaskDescription
(
label:
'Address Book'
,
label:
'Address Book'
,
child:
new
Focus
(
child:
new
Navigator
(
_navigationState
)
initialFocus:
nameKey
,
child:
buildMain
()
)
)
)
)
)
);
);
...
...
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