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
d9d3114d
Commit
d9d3114d
authored
Jan 08, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Material baseline grid
See
https://www.google.com/design/spec/layout/metrics-keylines.html#
parent
99112425
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
29 deletions
+76
-29
flutter.yaml
examples/stocks/flutter.yaml
+1
-0
main.dart
examples/stocks/lib/main.dart
+6
-2
stock_settings.dart
examples/stocks/lib/stock_settings.dart
+51
-25
material_app.dart
packages/flutter/lib/src/material/material_app.dart
+18
-2
No files found.
examples/stocks/flutter.yaml
View file @
d9d3114d
...
...
@@ -12,6 +12,7 @@ material-design-icons:
-
name
:
action/thumb_up
-
name
:
content/add
-
name
:
device/dvr
-
name
:
editor/border_clear
-
name
:
navigation/arrow_back
-
name
:
navigation/menu
-
name
:
navigation/more_vert
examples/stocks/lib/main.dart
View file @
d9d3114d
...
...
@@ -48,17 +48,20 @@ class StocksAppState extends State<StocksApp> {
StockMode
_optimismSetting
=
StockMode
.
optimistic
;
BackupMode
_backupSetting
=
BackupMode
.
disabled
;
bool
_showGridSetting
=
false
;
void
modeUpdater
(
StockMode
optimism
)
{
setState
(()
{
_optimismSetting
=
optimism
;
});
}
void
settingsUpdater
({
StockMode
optimism
,
BackupMode
backup
})
{
void
settingsUpdater
({
StockMode
optimism
,
BackupMode
backup
,
bool
showGrid
})
{
setState
(()
{
if
(
optimism
!=
null
)
_optimismSetting
=
optimism
;
if
(
backup
!=
null
)
_backupSetting
=
backup
;
if
(
showGrid
!=
null
)
_showGridSetting
=
showGrid
;
});
}
...
...
@@ -105,9 +108,10 @@ class StocksAppState extends State<StocksApp> {
return
new
MaterialApp
(
title:
'Stocks'
,
theme:
theme
,
debugShowMaterialGrid:
_showGridSetting
,
routes:
<
String
,
RouteBuilder
>{
'/'
:
(
RouteArguments
args
)
=>
new
StockHome
(
_stocks
,
_symbols
,
_optimismSetting
,
modeUpdater
),
'/settings'
:
(
RouteArguments
args
)
=>
new
StockSettings
(
_optimismSetting
,
_backupSetting
,
settingsUpdater
)
'/settings'
:
(
RouteArguments
args
)
=>
new
StockSettings
(
_optimismSetting
,
_backupSetting
,
_showGridSetting
,
settingsUpdater
)
},
onGenerateRoute:
_getRoute
,
onLocaleChanged:
_onLocaleChanged
...
...
examples/stocks/lib/stock_settings.dart
View file @
d9d3114d
...
...
@@ -6,15 +6,17 @@ part of stocks;
typedef
void
SettingsUpdater
(
{
StockMode
optimism
,
BackupMode
backup
BackupMode
backup
,
bool
showGrid
});
class
StockSettings
extends
StatefulComponent
{
const
StockSettings
(
this
.
optimism
,
this
.
backup
,
this
.
updater
);
const
StockSettings
(
this
.
optimism
,
this
.
backup
,
this
.
showGrid
,
this
.
updater
);
final
StockMode
optimism
;
final
BackupMode
backup
;
final
SettingsUpdater
updater
;
final
bool
showGrid
;
StockSettingsState
createState
()
=>
new
StockSettingsState
();
}
...
...
@@ -22,11 +24,15 @@ class StockSettings extends StatefulComponent {
class
StockSettingsState
extends
State
<
StockSettings
>
{
void
_handleOptimismChanged
(
bool
value
)
{
value
??=
false
;
sendUpdates
(
value
?
StockMode
.
optimistic
:
StockMode
.
pessimistic
,
config
.
backup
);
sendUpdates
(
value
?
StockMode
.
optimistic
:
StockMode
.
pessimistic
,
config
.
backup
,
config
.
showGrid
);
}
void
_handleBackupChanged
(
bool
value
)
{
sendUpdates
(
config
.
optimism
,
value
?
BackupMode
.
enabled
:
BackupMode
.
disabled
);
sendUpdates
(
config
.
optimism
,
value
?
BackupMode
.
enabled
:
BackupMode
.
disabled
,
config
.
showGrid
);
}
void
_handleShowGridChanged
(
bool
value
)
{
sendUpdates
(
config
.
optimism
,
config
.
backup
,
value
);
}
void
_confirmOptimismChange
()
{
...
...
@@ -60,11 +66,12 @@ class StockSettingsState extends State<StockSettings> {
}
}
void
sendUpdates
(
StockMode
optimism
,
BackupMode
backup
)
{
void
sendUpdates
(
StockMode
optimism
,
BackupMode
backup
,
bool
showGrid
)
{
if
(
config
.
updater
!=
null
)
config
.
updater
(
optimism:
optimism
,
backup:
backup
backup:
backup
,
showGrid:
showGrid
);
}
...
...
@@ -77,30 +84,49 @@ class StockSettingsState extends State<StockSettings> {
Widget
buildSettingsPane
(
BuildContext
context
)
{
// TODO(ianh): Once we have the gesture API hooked up, fix https://github.com/domokit/mojo/issues/281
// (whereby tapping the widgets below causes both the widget and the menu item to fire their callbacks)
return
new
Block
(<
Widget
>[
List
<
Widget
>
rows
=
<
Widget
>[
new
DrawerItem
(
icon:
'action/thumb_up'
,
onPressed:
()
=>
_confirmOptimismChange
(),
child:
new
Row
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
'Everything is awesome'
)),
new
Checkbox
(
value:
config
.
optimism
==
StockMode
.
optimistic
,
onChanged:
(
bool
value
)
=>
_confirmOptimismChange
()
),
])
),
new
DrawerItem
(
icon:
'action/backup'
,
onPressed:
()
{
_handleBackupChanged
(!(
config
.
backup
==
BackupMode
.
enabled
));
},
child:
new
Row
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
'Back up stock list to the cloud'
)),
new
Switch
(
value:
config
.
backup
==
BackupMode
.
enabled
,
onChanged:
_handleBackupChanged
),
])
),
];
assert
(()
{
// material grid is only available in checked mode
rows
.
add
(
new
DrawerItem
(
icon:
'
action/thumb_up
'
,
onPressed:
()
=>
_confirmOptimismChange
()
,
icon:
'
editor/border_clear
'
,
onPressed:
()
{
_handleShowGridChanged
(!
config
.
showGrid
);
}
,
child:
new
Row
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
'Everything is awesome'
)),
new
Checkbox
(
value:
config
.
optimism
==
StockMode
.
optimistic
,
onChanged:
(
bool
value
)
=>
_confirmOptimismChange
()
),
])
),
new
DrawerItem
(
icon:
'action/backup'
,
onPressed:
()
{
_handleBackupChanged
(!(
config
.
backup
==
BackupMode
.
enabled
));
},
child:
new
Row
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
'Back up stock list to the cloud'
)),
new
Flexible
(
child:
new
Text
(
'Show material grid (for debugging)'
)),
new
Switch
(
value:
config
.
backup
==
BackupMode
.
enable
d
,
onChanged:
_handle
Backup
Changed
value:
config
.
showGri
d
,
onChanged:
_handle
ShowGrid
Changed
),
])
),
],
)
);
return
true
;
});
return
new
Block
(
rows
,
padding:
const
EdgeDims
.
symmetric
(
vertical:
20.0
)
);
}
...
...
packages/flutter/lib/src/material/material_app.dart
View file @
d9d3114d
...
...
@@ -47,10 +47,12 @@ class MaterialApp extends StatefulComponent {
this
.
theme
,
this
.
routes
:
const
<
String
,
RouteBuilder
>{},
this
.
onGenerateRoute
,
this
.
onLocaleChanged
this
.
onLocaleChanged
,
this
.
debugShowMaterialGrid
:
false
})
:
super
(
key:
key
)
{
assert
(
routes
!=
null
);
assert
(
routes
.
containsKey
(
Navigator
.
defaultRouteName
)
||
onGenerateRoute
!=
null
);
assert
(
debugShowMaterialGrid
!=
null
);
}
final
String
title
;
...
...
@@ -58,6 +60,7 @@ class MaterialApp extends StatefulComponent {
final
Map
<
String
,
RouteBuilder
>
routes
;
final
RouteFactory
onGenerateRoute
;
final
LocaleChangedCallback
onLocaleChanged
;
final
bool
debugShowMaterialGrid
;
_MaterialAppState
createState
()
=>
new
_MaterialAppState
();
}
...
...
@@ -131,7 +134,7 @@ class _MaterialAppState extends State<MaterialApp> implements BindingObserver {
}
ThemeData
theme
=
config
.
theme
??
new
ThemeData
.
fallback
();
return
new
MediaQuery
(
Widget
result
=
new
MediaQuery
(
data:
new
MediaQueryData
(
size:
_size
),
child:
new
LocaleQuery
(
data:
_localeData
,
...
...
@@ -156,6 +159,19 @@ class _MaterialAppState extends State<MaterialApp> implements BindingObserver {
)
)
);
assert
(()
{
if
(
config
.
debugShowMaterialGrid
)
{
result
=
new
GridPaper
(
color:
const
Color
(
0xE0F9BBE0
),
interval:
8.0
,
divisions:
2
,
subDivisions:
1
,
child:
result
);
}
return
true
;
});
return
result
;
}
}
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