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
6dcd1271
Commit
6dcd1271
authored
Feb 02, 2017
by
Ian Hickson
Committed by
GitHub
Feb 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delay time dilation so users see the checkbox (#7803)
Fixes
https://github.com/flutter/flutter/issues/5066
parent
5f38773e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
5 deletions
+34
-5
app.dart
examples/flutter_gallery/lib/gallery/app.dart
+34
-5
No files found.
examples/flutter_gallery/lib/gallery/app.dart
View file @
6dcd1271
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:flutter/foundation.dart'
show
defaultTargetPlatform
;
import
'package:flutter/material.dart'
;
import
'package:flutter/scheduler.dart'
show
timeDilation
;
...
...
@@ -51,8 +53,23 @@ class GalleryAppState extends State<GalleryApp> {
bool
_useLightTheme
=
true
;
bool
_showPerformanceOverlay
=
false
;
bool
_checkerboardRasterCacheImages
=
false
;
double
_timeDilation
=
1.0
;
TargetPlatform
_platform
=
defaultTargetPlatform
;
Timer
_timeDilationTimer
;
TargetPlatform
platform
=
defaultTargetPlatform
;
@override
void
initState
()
{
_timeDilation
=
timeDilation
;
super
.
initState
();
}
@override
void
dispose
()
{
_timeDilationTimer
?.
cancel
();
_timeDilationTimer
=
null
;
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -77,13 +94,25 @@ class GalleryAppState extends State<GalleryApp> {
}
:
null
,
onPlatformChanged:
(
TargetPlatform
value
)
{
setState
(()
{
platform
=
value
;
_
platform
=
value
;
});
},
timeDilation:
timeDilation
,
timeDilation:
_
timeDilation
,
onTimeDilationChanged:
(
double
value
)
{
setState
(()
{
timeDilation
=
value
;
_timeDilationTimer
?.
cancel
();
_timeDilationTimer
=
null
;
_timeDilation
=
value
;
if
(
_timeDilation
>
1.0
)
{
// We delay the time dilation change long enough that the user can see
// that the checkbox in the drawer has started reacting, then we slam
// on the brakes so that they see that the time is in fact now dilated.
_timeDilationTimer
=
new
Timer
(
const
Duration
(
milliseconds:
150
),
()
{
timeDilation
=
_timeDilation
;
});
}
else
{
timeDilation
=
_timeDilation
;
}
});
},
onSendFeedback:
config
.
onSendFeedback
,
...
...
@@ -99,7 +128,7 @@ class GalleryAppState extends State<GalleryApp> {
return
new
MaterialApp
(
title:
'Flutter Gallery'
,
color:
Colors
.
grey
[
500
],
theme:
(
_useLightTheme
?
_kGalleryLightTheme
:
_kGalleryDarkTheme
).
copyWith
(
platform:
platform
),
theme:
(
_useLightTheme
?
_kGalleryLightTheme
:
_kGalleryDarkTheme
).
copyWith
(
platform:
_
platform
),
showPerformanceOverlay:
_showPerformanceOverlay
,
checkerboardRasterCacheImages:
_checkerboardRasterCacheImages
,
routes:
_kRoutes
,
...
...
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