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
481b764f
Commit
481b764f
authored
Sep 25, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port Input and EditableText to fn3
parent
fe77808d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
64 deletions
+62
-64
fn3.dart
packages/flutter/lib/src/fn3.dart
+2
-0
editable_text.dart
packages/flutter/lib/src/fn3/editable_text.dart
+22
-23
input.dart
packages/flutter/lib/src/fn3/input.dart
+38
-41
No files found.
packages/flutter/lib/src/fn3.dart
View file @
481b764f
...
...
@@ -18,6 +18,7 @@ export 'fn3/drawer.dart';
export
'fn3/drawer_divider.dart'
;
export
'fn3/drawer_header.dart'
;
export
'fn3/drawer_item.dart'
;
export
'fn3/editable_text.dart'
;
export
'fn3/flat_button.dart'
;
export
'fn3/floating_action_button.dart'
;
export
'fn3/focus.dart'
;
...
...
@@ -27,6 +28,7 @@ export 'fn3/homogeneous_viewport.dart';
export
'fn3/icon.dart'
;
export
'fn3/icon_button.dart'
;
export
'fn3/ink_well.dart'
;
export
'fn3/input.dart'
;
export
'fn3/material.dart'
;
export
'fn3/material_button.dart'
;
export
'fn3/mixed_viewport.dart'
;
...
...
packages/flutter/lib/src/fn3/editable_text.dart
View file @
481b764f
...
...
@@ -7,8 +7,8 @@ import 'dart:sky' as sky;
import
'package:mojo_services/keyboard/keyboard.mojom.dart'
;
import
'package:sky/painting.dart'
;
import
'package:sky/src/
widgets
/basic.dart'
;
import
'package:sky/src/
widgets
/framework.dart'
;
import
'package:sky/src/
fn3
/basic.dart'
;
import
'package:sky/src/
fn3
/framework.dart'
;
const
_kCursorBlinkPeriod
=
500
;
// milliseconds
const
_kCursorGap
=
1.0
;
...
...
@@ -133,7 +133,6 @@ class EditableString implements KeyboardClient {
}
class
EditableText
extends
StatefulComponent
{
EditableText
({
Key
key
,
this
.
value
,
...
...
@@ -141,18 +140,15 @@ class EditableText extends StatefulComponent {
this
.
style
,
this
.
cursorColor
})
:
super
(
key:
key
);
EditableString
value
;
bool
focused
;
TextStyle
style
;
Color
cursorColor
;
final
EditableString
value
;
final
bool
focused
;
final
TextStyle
style
;
final
Color
cursorColor
;
void
syncConstructorArguments
(
EditableText
source
)
{
value
=
source
.
value
;
focused
=
source
.
focused
;
style
=
source
.
style
;
cursorColor
=
source
.
cursorColor
;
}
EditableTextState
createState
()
=>
new
EditableTextState
();
}
class
EditableTextState
extends
State
<
EditableText
>
{
Timer
_cursorTimer
;
bool
_showCursor
=
false
;
...
...
@@ -175,10 +171,10 @@ class EditableText extends StatefulComponent {
new
Duration
(
milliseconds:
_kCursorBlinkPeriod
),
_cursorTick
);
}
void
di
dUnmount
()
{
void
di
spose
()
{
if
(
_cursorTimer
!=
null
)
_stopCursorTimer
();
super
.
di
dUnmount
();
super
.
di
spose
();
}
void
_stopCursorTimer
()
{
...
...
@@ -191,26 +187,29 @@ class EditableText extends StatefulComponent {
if
(!
_showCursor
)
return
;
double
cursorHeight
=
style
.
fontSize
+
2.0
*
_kCursorHeightOffset
;
double
cursorHeight
=
config
.
style
.
fontSize
+
2.0
*
_kCursorHeightOffset
;
Rect
cursorRect
=
new
Rect
.
fromLTWH
(
_kCursorGap
,
(
size
.
height
-
cursorHeight
)
/
2.0
,
_kCursorWidth
,
cursorHeight
);
canvas
.
drawRect
(
cursorRect
,
new
Paint
()..
color
=
cursorColor
);
canvas
.
drawRect
(
cursorRect
,
new
Paint
()..
color
=
c
onfig
.
c
ursorColor
);
}
Widget
build
()
{
assert
(
style
!=
null
);
assert
(
focused
!=
null
);
assert
(
cursorColor
!=
null
);
Widget
build
(
BuildContext
context
)
{
assert
(
config
.
style
!=
null
);
assert
(
config
.
focused
!=
null
);
assert
(
c
onfig
.
c
ursorColor
!=
null
);
if
(
focused
&&
_cursorTimer
==
null
)
if
(
config
.
focused
&&
_cursorTimer
==
null
)
_startCursorTimer
();
else
if
(!
focused
&&
_cursorTimer
!=
null
)
else
if
(!
config
.
focused
&&
_cursorTimer
!=
null
)
_stopCursorTimer
();
final
EditableString
value
=
config
.
value
;
final
TextStyle
style
=
config
.
style
;
Widget
text
;
if
(
value
.
composing
.
isValid
)
{
TextStyle
composingStyle
=
style
.
merge
(
const
TextStyle
(
decoration:
underline
));
...
...
packages/flutter/lib/src/fn3/input.dart
View file @
481b764f
...
...
@@ -4,11 +4,11 @@
import
'package:sky/services.dart'
;
import
'package:sky/painting.dart'
;
import
'package:sky/src/
widgets
/basic.dart'
;
import
'package:sky/src/
widgets
/editable_text.dart'
;
import
'package:sky/src/
widgets
/focus.dart'
;
import
'package:sky/src/
widgets
/framework.dart'
;
import
'package:sky/src/
widgets
/theme.dart'
;
import
'package:sky/src/
fn3
/basic.dart'
;
import
'package:sky/src/
fn3
/editable_text.dart'
;
import
'package:sky/src/
fn3
/focus.dart'
;
import
'package:sky/src/
fn3
/framework.dart'
;
import
'package:sky/src/
fn3
/theme.dart'
;
export
'package:sky/services.dart'
show
KeyboardType
;
...
...
@@ -19,35 +19,34 @@ typedef void StringValueChanged(String value);
const
EdgeDims
_kTextfieldPadding
=
const
EdgeDims
.
symmetric
(
vertical:
8.0
);
class
Input
extends
StatefulComponent
{
Input
({
GlobalKey
key
,
String
initialValue:
''
,
this
.
initialValue
:
''
,
this
.
placeholder
,
this
.
onChanged
,
this
.
keyboardType
:
KeyboardType
.
TEXT
}):
_value
=
initialValue
,
super
(
key:
key
);
this
.
keyboardType
:
KeyboardType
.
TEXT
}):
super
(
key:
key
);
final
String
initialValue
;
final
KeyboardType
keyboardType
;
final
String
placeholder
;
final
StringValueChanged
onChanged
;
KeyboardType
keyboardType
;
String
placeholder
;
StringValueChanged
onChanged
;
InputState
createState
()
=>
new
InputState
();
}
class
InputState
extends
State
<
Input
>
{
String
_value
;
EditableString
_editableValue
;
KeyboardHandle
_keyboardHandle
=
KeyboardHandle
.
unattached
;
void
initState
()
{
void
initState
(
BuildContext
context
)
{
super
.
initState
(
context
);
_value
=
config
.
initialValue
;
_editableValue
=
new
EditableString
(
text:
_value
,
onUpdated:
_handleTextUpdated
);
super
.
initState
();
}
void
syncConstructorArguments
(
Input
source
)
{
placeholder
=
source
.
placeholder
;
onChanged
=
source
.
onChanged
;
keyboardType
=
source
.
keyboardType
;
}
void
_handleTextUpdated
()
{
...
...
@@ -55,17 +54,17 @@ class Input extends StatefulComponent {
setState
(()
{
_value
=
_editableValue
.
text
;
});
if
(
onChanged
!=
null
)
onChanged
(
_value
);
if
(
config
.
onChanged
!=
null
)
config
.
onChanged
(
_value
);
}
}
Widget
build
()
{
ThemeData
themeData
=
Theme
.
of
(
this
);
bool
focused
=
Focus
.
at
(
this
);
Widget
build
(
BuildContext
context
)
{
ThemeData
themeData
=
Theme
.
of
(
context
);
bool
focused
=
Focus
State
.
at
(
context
,
config
);
if
(
focused
&&
!
_keyboardHandle
.
attached
)
{
_keyboardHandle
=
keyboard
.
show
(
_editableValue
.
stub
,
keyboardType
);
_keyboardHandle
=
keyboard
.
show
(
_editableValue
.
stub
,
config
.
keyboardType
);
}
else
if
(!
focused
&&
_keyboardHandle
.
attached
)
{
_keyboardHandle
.
release
();
}
...
...
@@ -73,10 +72,10 @@ class Input extends StatefulComponent {
TextStyle
textStyle
=
themeData
.
text
.
subhead
;
List
<
Widget
>
textChildren
=
<
Widget
>[];
if
(
placeholder
!=
null
&&
_value
.
isEmpty
)
{
if
(
config
.
placeholder
!=
null
&&
_value
.
isEmpty
)
{
Widget
child
=
new
Opacity
(
key:
const
ValueKey
<
String
>(
'placeholder'
),
child:
new
Text
(
placeholder
,
style:
textStyle
),
child:
new
Text
(
config
.
placeholder
,
style:
textStyle
),
opacity:
themeData
.
hintOpacity
);
textChildren
.
add
(
child
);
...
...
@@ -109,23 +108,21 @@ class Input extends StatefulComponent {
return
new
Listener
(
child:
input
,
onPointerDown:
focus
);
}
void
focus
(
_
)
{
if
(
Focus
.
at
(
this
))
{
onPointerDown:
(
_
)
{
if
(
FocusState
.
at
(
context
,
config
))
{
assert
(
_keyboardHandle
.
attached
);
_keyboardHandle
.
showByRequest
();
}
else
{
Focus
.
moveTo
(
this
);
FocusState
.
moveTo
(
context
,
config
);
// we'll get told to rebuild and we'll take care of the keyboard then
}
}
);
}
void
di
dUnmount
()
{
void
di
spose
()
{
if
(
_keyboardHandle
.
attached
)
_keyboardHandle
.
release
();
super
.
di
dUnmount
();
super
.
di
spose
();
}
}
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