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
6f107d0a
Commit
6f107d0a
authored
Feb 09, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1702 from Hixie/checked-mode
Add a "SLOW MODE" banner in checked mode
parents
3de7121b
bf30c1ab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
127 additions
and
1 deletion
+127
-1
material_app.dart
packages/flutter/lib/src/material/material_app.dart
+50
-1
checked_mode_banner.dart
packages/flutter/lib/src/widgets/checked_mode_banner.dart
+76
-0
widgets.dart
packages/flutter/lib/widgets.dart
+1
-0
No files found.
packages/flutter/lib/src/material/material_app.dart
View file @
6f107d0a
...
...
@@ -50,7 +50,8 @@ class MaterialApp extends StatefulComponent {
this
.
onLocaleChanged
,
this
.
debugShowMaterialGrid
:
false
,
this
.
showPerformanceOverlay
:
false
,
this
.
showSemanticsDebugger
:
false
this
.
showSemanticsDebugger
:
false
,
this
.
debugShowCheckedModeBanner
:
true
})
:
super
(
key:
key
)
{
assert
(
routes
!=
null
);
assert
(
routes
.
containsKey
(
Navigator
.
defaultRouteName
)
||
onGenerateRoute
!=
null
);
...
...
@@ -59,15 +60,55 @@ class MaterialApp extends StatefulComponent {
assert
(
showSemanticsDebugger
!=
null
);
}
/// A one-line description of this app for use in the window manager.
final
String
title
;
/// The colors to use for the application's widgets.
final
ThemeData
theme
;
/// The default table of routes for the application. When the
/// [Navigator] is given a named route, the name will be looked up
/// in this table first. If the name is not available, then
/// [onGenerateRoute] will be called instead.
final
Map
<
String
,
RouteBuilder
>
routes
;
/// The route generator callback used when the app is navigated to a
/// named route but the name is not in the [routes] table.
final
RouteFactory
onGenerateRoute
;
/// Callback that is invoked when the operating system changes the
/// current locale.
final
LocaleChangedCallback
onLocaleChanged
;
/// Turns on a [GridPaper] overlay that paints a baseline grid
/// Material apps:
/// https://www.google.com/design/spec/layout/metrics-keylines.html
/// Only available in checked mode.
final
bool
debugShowMaterialGrid
;
/// Turns on a performance overlay.
/// https://flutter.io/debugging/#performanceoverlay
final
bool
showPerformanceOverlay
;
/// Turns on an overlay that shows the accessibility information
/// reported by the framework.
final
bool
showSemanticsDebugger
;
/// Turns on a "SLOW MODE" little banner in checked mode to indicate
/// that the app is in checked mode. This is on by default (in
/// checked mode), to turn it off, set the constructor argument to
/// false. In release mode this has no effect.
///
/// To get this banner in your application if you're not using
/// MaterialApp, include a [CheckedModeBanner] widget in your app.
///
/// This banner is intended to avoid people complaining that your
/// app is slow when it's in checked mode. In checked mode, Flutter
/// enables a large number of expensive diagnostics to aid in
/// development, and so performance in checked mode is not
/// representative of what will happen in release mode.
final
bool
debugShowCheckedModeBanner
;
_MaterialAppState
createState
()
=>
new
_MaterialAppState
();
}
...
...
@@ -203,6 +244,14 @@ class _MaterialAppState extends State<MaterialApp> implements BindingObserver {
child:
result
);
}
assert
(()
{
if
(
config
.
debugShowCheckedModeBanner
)
{
result
=
new
CheckedModeBanner
(
child:
result
);
}
return
true
;
});
return
result
;
}
...
...
packages/flutter/lib/src/widgets/checked_mode_banner.dart
0 → 100644
View file @
6f107d0a
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:math'
as
math
;
import
'dart:ui'
as
ui
;
import
'package:flutter/painting.dart'
;
import
'package:flutter/rendering.dart'
;
import
'basic.dart'
;
import
'framework.dart'
;
class
_CheckedModeBannerPainter
extends
CustomPainter
{
const
_CheckedModeBannerPainter
();
static
const
kColor
=
const
Color
(
0xA0B71C1C
);
static
const
kOffset
=
40.0
;
// distance to bottom of banner, at a 45 degree angle inwards from the top right corner
static
const
kHeight
=
12.0
;
// height of banner
static
const
kTextAlign
=
const
Offset
(
0.0
,
-
3.0
);
// offset to move text up
static
const
kFontSize
=
kHeight
*
0.85
;
static
const
kShadowBlur
=
8.0
;
// shadow blur sigma
static
final
Rect
kRect
=
new
Rect
.
fromLTWH
(-
kOffset
,
kOffset
-
kHeight
,
kOffset
*
2.0
,
kHeight
);
static
const
TextStyle
kTextStyles
=
const
TextStyle
(
color:
const
Color
(
0xFFFFFFFF
),
fontSize:
kFontSize
,
fontWeight:
FontWeight
.
w900
,
textAlign:
TextAlign
.
center
);
static
final
TextPainter
textPainter
=
new
TextPainter
()
..
text
=
new
StyledTextSpan
(
kTextStyles
,
<
TextSpan
>[
new
PlainTextSpan
(
'SLOW MODE'
)])
..
maxWidth
=
kOffset
*
2.0
..
maxHeight
=
kHeight
..
layout
();
void
paint
(
Canvas
canvas
,
Size
size
)
{
final
Paint
paintShadow
=
new
Paint
()
..
color
=
const
Color
(
0x7F000000
)
..
maskFilter
=
new
ui
.
MaskFilter
.
blur
(
ui
.
BlurStyle
.
normal
,
kShadowBlur
);
final
Paint
paintBanner
=
new
Paint
()
..
color
=
kColor
;
canvas
..
translate
(
size
.
width
,
0.0
)
..
rotate
(
math
.
PI
/
4
)
..
drawRect
(
kRect
,
paintShadow
)
..
drawRect
(
kRect
,
paintBanner
);
textPainter
.
paint
(
canvas
,
kRect
.
topLeft
.
toOffset
()
+
kTextAlign
);
}
bool
shouldRepaint
(
_CheckedModeBannerPainter
oldPainter
)
=>
false
;
bool
hitTest
(
Point
position
)
=>
false
;
}
/// Displays a banner saying "CHECKED" when running in checked mode.
/// Does nothing in release mode.
class
CheckedModeBanner
extends
StatelessComponent
{
CheckedModeBanner
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
final
Widget
child
;
Widget
build
(
BuildContext
context
)
{
Widget
result
=
child
;
assert
(()
{
result
=
new
CustomPaint
(
foregroundPainter:
const
_CheckedModeBannerPainter
(),
child:
result
);
return
true
;
});
return
result
;
}
}
packages/flutter/lib/widgets.dart
View file @
6f107d0a
...
...
@@ -8,6 +8,7 @@ library widgets;
export
'src/widgets/asset_vendor.dart'
;
export
'src/widgets/basic.dart'
;
export
'src/widgets/binding.dart'
;
export
'src/widgets/checked_mode_banner.dart'
;
export
'src/widgets/child_view.dart'
;
export
'src/widgets/dismissable.dart'
;
export
'src/widgets/drag_target.dart'
;
...
...
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