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
10a4753f
Commit
10a4753f
authored
Nov 06, 2015
by
Hans Muller
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1990 from HansMuller/bottom_sheet_placeholder
Adds showBottomSheet(), AlignTransition
parents
fa50aaec
b39c1f89
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
8 deletions
+90
-8
bottom_sheet.dart
packages/flutter/lib/src/material/bottom_sheet.dart
+41
-7
box.dart
packages/flutter/lib/src/rendering/box.dart
+17
-0
shifted_box.dart
packages/flutter/lib/src/rendering/shifted_box.dart
+1
-1
transitions.dart
packages/flutter/lib/src/widgets/transitions.dart
+31
-0
No files found.
packages/flutter/lib/src/material/bottom_sheet.dart
View file @
10a4753f
...
@@ -16,15 +16,15 @@ const Duration _kBottomSheetDuration = const Duration(milliseconds: 200);
...
@@ -16,15 +16,15 @@ const Duration _kBottomSheetDuration = const Duration(milliseconds: 200);
const
double
_kMinFlingVelocity
=
700.0
;
const
double
_kMinFlingVelocity
=
700.0
;
const
double
_kFlingVelocityScale
=
1.0
/
300.0
;
const
double
_kFlingVelocityScale
=
1.0
/
300.0
;
class
_BottomSheet
extends
StatefulComponent
{
class
_
Modal
BottomSheet
extends
StatefulComponent
{
_BottomSheet
({
Key
key
,
this
.
route
})
:
super
(
key:
key
);
_
Modal
BottomSheet
({
Key
key
,
this
.
route
})
:
super
(
key:
key
);
final
_ModalBottomSheetRoute
route
;
final
_ModalBottomSheetRoute
route
;
_
BottomSheetState
createState
()
=>
new
_
BottomSheetState
();
_
ModalBottomSheetState
createState
()
=>
new
_Modal
BottomSheetState
();
}
}
class
_BottomSheetLayout
extends
OneChildLayoutDelegate
{
class
_
Modal
BottomSheetLayout
extends
OneChildLayoutDelegate
{
// The distance from the bottom of the parent to the top of the BottomSheet child.
// The distance from the bottom of the parent to the top of the BottomSheet child.
AnimatedValue
<
double
>
childTop
=
new
AnimatedValue
<
double
>(
0.0
);
AnimatedValue
<
double
>
childTop
=
new
AnimatedValue
<
double
>(
0.0
);
...
@@ -43,9 +43,9 @@ class _BottomSheetLayout extends OneChildLayoutDelegate {
...
@@ -43,9 +43,9 @@ class _BottomSheetLayout extends OneChildLayoutDelegate {
}
}
}
}
class
_
BottomSheetState
extends
State
<
_
BottomSheet
>
{
class
_
ModalBottomSheetState
extends
State
<
_Modal
BottomSheet
>
{
final
_
BottomSheetLayout
_layout
=
new
_
BottomSheetLayout
();
final
_
ModalBottomSheetLayout
_layout
=
new
_Modal
BottomSheetLayout
();
bool
_dragEnabled
=
false
;
bool
_dragEnabled
=
false
;
void
_handleDragStart
(
Point
position
)
{
void
_handleDragStart
(
Point
position
)
{
...
@@ -111,7 +111,7 @@ class _ModalBottomSheetRoute extends ModalRoute {
...
@@ -111,7 +111,7 @@ class _ModalBottomSheetRoute extends ModalRoute {
}
}
Color
get
barrierColor
=>
Colors
.
black54
;
Color
get
barrierColor
=>
Colors
.
black54
;
Widget
buildModalWidget
(
BuildContext
context
)
=>
new
_BottomSheet
(
route:
this
);
Widget
buildModalWidget
(
BuildContext
context
)
=>
new
_
Modal
BottomSheet
(
route:
this
);
void
didPop
([
dynamic
result
])
{
void
didPop
([
dynamic
result
])
{
completer
.
complete
(
result
);
completer
.
complete
(
result
);
...
@@ -120,6 +120,7 @@ class _ModalBottomSheetRoute extends ModalRoute {
...
@@ -120,6 +120,7 @@ class _ModalBottomSheetRoute extends ModalRoute {
}
}
Future
showModalBottomSheet
(
{
BuildContext
context
,
Widget
child
})
{
Future
showModalBottomSheet
(
{
BuildContext
context
,
Widget
child
})
{
assert
(
child
!=
null
);
final
Completer
completer
=
new
Completer
();
final
Completer
completer
=
new
Completer
();
Navigator
.
of
(
context
).
pushEphemeral
(
new
_ModalBottomSheetRoute
(
Navigator
.
of
(
context
).
pushEphemeral
(
new
_ModalBottomSheetRoute
(
completer:
completer
,
completer:
completer
,
...
@@ -127,3 +128,36 @@ Future showModalBottomSheet({ BuildContext context, Widget child }) {
...
@@ -127,3 +128,36 @@ Future showModalBottomSheet({ BuildContext context, Widget child }) {
));
));
return
completer
.
future
;
return
completer
.
future
;
}
}
class
_PersistentBottomSheet
extends
StatelessComponent
{
_PersistentBottomSheet
({
Key
key
,
this
.
child
,
this
.
route
})
:
super
(
key:
key
);
final
TransitionRoute
route
;
final
Widget
child
;
Widget
build
(
BuildContext
context
)
{
return
new
AlignTransition
(
performance:
route
.
performance
,
alignment:
new
AnimatedValue
<
FractionalOffset
>(
const
FractionalOffset
(
0.0
,
0.0
)),
heightFactor:
new
AnimatedValue
<
double
>(
0.0
,
end:
1.0
),
child:
child
);
}
}
class
_PersistentBottomSheetRoute
extends
TransitionRoute
{
bool
get
opaque
=>
false
;
Duration
get
transitionDuration
=>
_kBottomSheetDuration
;
}
void
showBottomSheet
(
{
BuildContext
context
,
GlobalKey
<
PlaceholderState
>
placeholderKey
,
Widget
child
})
{
assert
(
child
!=
null
);
assert
(
placeholderKey
!=
null
);
_PersistentBottomSheetRoute
route
=
new
_PersistentBottomSheetRoute
();
placeholderKey
.
currentState
.
child
=
new
_PersistentBottomSheet
(
route:
route
,
child:
child
);
Navigator
.
of
(
context
).
pushEphemeral
(
route
);
}
packages/flutter/lib/src/rendering/box.dart
View file @
10a4753f
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
import
'dart:math'
as
math
;
import
'dart:math'
as
math
;
import
'dart:ui'
as
ui
;
import
'dart:ui'
as
ui
;
import
'package:flutter/animation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/painting.dart'
;
import
'package:flutter/painting.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
...
@@ -792,5 +793,21 @@ class FractionalOffset {
...
@@ -792,5 +793,21 @@ class FractionalOffset {
value
=
37
*
value
+
y
.
hashCode
;
value
=
37
*
value
+
y
.
hashCode
;
return
value
;
return
value
;
}
}
static
FractionalOffset
lerp
(
FractionalOffset
a
,
FractionalOffset
b
,
double
t
)
{
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
new
FractionalOffset
(
b
.
x
*
t
,
b
.
y
*
t
);
if
(
b
==
null
)
return
new
FractionalOffset
(
b
.
x
*
(
1.0
-
t
),
b
.
y
*
(
1.0
-
t
));
return
new
FractionalOffset
(
ui
.
lerpDouble
(
a
.
x
,
b
.
x
,
t
),
ui
.
lerpDouble
(
a
.
y
,
b
.
y
,
t
));
}
String
toString
()
=>
'
$runtimeType
(
$x
,
$y
)'
;
String
toString
()
=>
'
$runtimeType
(
$x
,
$y
)'
;
}
}
class
AnimatedFractionalOffsetValue
extends
AnimatedValue
<
FractionalOffset
>
{
AnimatedFractionalOffsetValue
(
FractionalOffset
begin
,
{
FractionalOffset
end
,
Curve
curve
,
Curve
reverseCurve
})
:
super
(
begin
,
end:
end
,
curve:
curve
,
reverseCurve:
reverseCurve
);
FractionalOffset
lerp
(
double
t
)
=>
FractionalOffset
.
lerp
(
begin
,
end
,
t
);
}
packages/flutter/lib/src/rendering/shifted_box.dart
View file @
10a4753f
...
@@ -166,7 +166,7 @@ class RenderPositionedBox extends RenderShiftedBox {
...
@@ -166,7 +166,7 @@ class RenderPositionedBox extends RenderShiftedBox {
FractionalOffset
get
alignment
=>
_alignment
;
FractionalOffset
get
alignment
=>
_alignment
;
FractionalOffset
_alignment
;
FractionalOffset
_alignment
;
void
set
alignment
(
FractionalOffset
newAlignment
)
{
void
set
alignment
(
FractionalOffset
newAlignment
)
{
assert
(
newAlignment
==
null
||
(
newAlignment
.
x
!=
null
&&
newAlignment
.
y
!=
null
)
);
assert
(
newAlignment
!=
null
&&
newAlignment
.
x
!=
null
&&
newAlignment
.
y
!=
null
);
if
(
_alignment
==
newAlignment
)
if
(
_alignment
==
newAlignment
)
return
;
return
;
_alignment
=
newAlignment
;
_alignment
=
newAlignment
;
...
...
packages/flutter/lib/src/widgets/transitions.dart
View file @
10a4753f
...
@@ -177,6 +177,37 @@ class SquashTransition extends TransitionWithChild {
...
@@ -177,6 +177,37 @@ class SquashTransition extends TransitionWithChild {
}
}
}
}
class
AlignTransition
extends
TransitionWithChild
{
AlignTransition
({
Key
key
,
this
.
alignment
,
this
.
widthFactor
,
this
.
heightFactor
,
PerformanceView
performance
,
Widget
child
})
:
super
(
key:
key
,
performance:
performance
,
child:
child
);
final
AnimatedValue
<
FractionalOffset
>
alignment
;
final
AnimatedValue
<
double
>
widthFactor
;
final
AnimatedValue
<
double
>
heightFactor
;
Widget
buildWithChild
(
BuildContext
context
,
Widget
child
)
{
if
(
alignment
!=
null
)
performance
.
updateVariable
(
alignment
);
if
(
widthFactor
!=
null
)
performance
.
updateVariable
(
widthFactor
);
if
(
heightFactor
!=
null
)
performance
.
updateVariable
(
heightFactor
);
return
new
Align
(
alignment:
alignment
?.
value
,
widthFactor:
widthFactor
?.
value
,
heightFactor:
heightFactor
?.
value
,
child:
child
);
}
}
/// An animated variable containing a RelativeRectangle
/// An animated variable containing a RelativeRectangle
///
///
/// This class specializes the interpolation of AnimatedValue<RelativeRect> to
/// This class specializes the interpolation of AnimatedValue<RelativeRect> to
...
...
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