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
7c3a9435
Commit
7c3a9435
authored
Jun 22, 2016
by
Hans Muller
Committed by
GitHub
Jun 22, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the gallery Live Demo buttons, etc (#4678)
parent
a8f6f44a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
172 deletions
+65
-172
grid_list_demo.dart
examples/flutter_gallery/lib/demo/grid_list_demo.dart
+0
-7
demo.dart
examples/flutter_gallery/lib/gallery/demo.dart
+48
-161
syntax_highlighter.dart
examples/flutter_gallery/lib/gallery/syntax_highlighter.dart
+17
-4
No files found.
examples/flutter_gallery/lib/demo/grid_list_demo.dart
View file @
7c3a9435
...
...
@@ -7,10 +7,6 @@ import 'dart:collection';
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'../gallery/demo.dart'
;
const
String
_kExampleCode
=
'gridlists'
;
enum
GridDemoTileStyle
{
imageOnly
,
oneLine
,
...
...
@@ -268,9 +264,6 @@ class GridListDemoState extends State<GridListDemo> {
);
})
)
),
new
DemoBottomBar
(
exampleCodeTag:
_kExampleCode
)
]
)
...
...
examples/flutter_gallery/lib/gallery/demo.dart
View file @
7c3a9435
...
...
@@ -8,34 +8,17 @@ import 'package:flutter_markdown/flutter_markdown.dart';
import
'example_code_parser.dart'
;
import
'syntax_highlighter.dart'
;
class
SingleComponentDemo
Data
{
SingleComponentDemo
Data
({
class
ComponentDemoTab
Data
{
ComponentDemoTab
Data
({
this
.
widget
,
this
.
exampleCodeTag
,
this
.
description
,
this
.
onPressedDemo
this
.
tabName
});
final
Widget
widget
;
final
String
exampleCodeTag
;
final
String
description
;
final
VoidCallback
onPressedDemo
;
}
class
ComponentDemoTabData
extends
SingleComponentDemoData
{
ComponentDemoTabData
({
Widget
widget
,
String
exampleCodeTag
,
String
description
,
VoidCallback
onPressedDemo
,
this
.
tabName
})
:
super
(
widget:
widget
,
exampleCodeTag:
exampleCodeTag
,
description:
description
,
onPressedDemo:
onPressedDemo
);
final
String
tabName
;
static
Map
<
ComponentDemoTabData
,
TabLabel
>
buildTabLabels
(
List
<
ComponentDemoTabData
>
demos
)
{
...
...
@@ -66,6 +49,16 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
final
List
<
ComponentDemoTabData
>
demos
;
final
String
title
;
void
_showExampleCode
(
BuildContext
context
)
{
TabBarSelectionState
<
ComponentDemoTabData
>
selection
=
TabBarSelection
.
of
(
context
);
String
tag
=
selection
.
value
?.
exampleCodeTag
;
if
(
tag
!=
null
)
{
Navigator
.
push
(
context
,
new
MaterialPageRoute
<
FullScreenCodeDialog
>(
builder:
(
BuildContext
context
)
=>
new
FullScreenCodeDialog
(
exampleCodeTag:
tag
)
));
}
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
TabBarSelection
<
ComponentDemoTabData
>(
...
...
@@ -73,153 +66,36 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
child:
new
Scaffold
(
appBar:
new
AppBar
(
title:
new
Text
(
title
),
actions:
<
Widget
>[
new
Builder
(
builder:
(
BuildContext
context
)
{
return
new
IconButton
(
icon:
new
Icon
(
Icons
.
description
),
tooltip:
'Show example code'
,
onPressed:
()
{
_showExampleCode
(
context
);
}
);
}
)
],
bottom:
new
TabBar
<
ComponentDemoTabData
>(
isScrollable:
true
,
labels:
ComponentDemoTabData
.
buildTabLabels
(
demos
)
)
),
body:
new
TabbedComponentDemo
(
demos
)
)
);
}
}
class
TabbedComponentDemo
extends
StatelessWidget
{
TabbedComponentDemo
(
this
.
demos
);
final
List
<
ComponentDemoTabData
>
demos
;
@override
Widget
build
(
BuildContext
context
)
{
return
new
TabBarView
<
ComponentDemoTabData
>(
children:
demos
.
map
(
buildTabView
).
toList
()
);
}
Widget
buildTabView
(
ComponentDemoTabData
demo
)
{
return
new
SingleComponentDemo
(
demo
);
}
}
class
SingleComponentDemo
extends
StatelessWidget
{
SingleComponentDemo
(
this
.
demo
);
final
SingleComponentDemoData
demo
;
@override
Widget
build
(
BuildContext
context
)
{
return
new
Column
(
children:
<
Widget
>[
new
Padding
(
padding:
new
EdgeInsets
.
all
(
16.0
),
child:
new
MarkdownBody
(
data:
demo
.
description
)
),
new
Flexible
(
child:
demo
.
widget
),
new
DemoBottomBar
(
exampleCodeTag:
demo
.
exampleCodeTag
,
onPressedDemo:
demo
.
onPressedDemo
)
]
);
}
}
class
DemoBottomBar
extends
StatelessWidget
{
DemoBottomBar
({
this
.
exampleCodeTag
,
this
.
onPressedDemo
});
final
String
exampleCodeTag
;
final
VoidCallback
onPressedDemo
;
@override
Widget
build
(
BuildContext
context
)
{
VoidCallback
onPressedCode
;
if
(
exampleCodeTag
!=
null
)
{
onPressedCode
=
()
{
Navigator
.
push
(
context
,
new
MaterialPageRoute
<
FullScreenCodeDialog
>(
builder:
(
BuildContext
context
)
=>
new
FullScreenCodeDialog
(
exampleCodeTag:
exampleCodeTag
)
));
};
}
return
new
Column
(
children:
<
Widget
>[
new
Divider
(
height:
1.0
),
new
Container
(
height:
48.0
,
child:
new
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
new
FlatButton
(
child:
new
Row
(
children:
<
Widget
>[
new
Padding
(
padding:
new
EdgeInsets
.
only
(
right:
8.0
),
child:
new
Icon
(
Icons
.
code
)
),
new
Text
(
'VIEW CODE'
)
]
),
onPressed:
onPressedCode
),
new
FlatButton
(
child:
new
Row
(
children:
<
Widget
>[
new
Padding
(
padding:
new
EdgeInsets
.
only
(
right:
8.0
),
child:
new
Icon
(
Icons
.
star
)
),
new
Text
(
'LIVE DEMO'
)
]
body:
new
TabBarView
<
ComponentDemoTabData
>(
children:
demos
.
map
((
ComponentDemoTabData
demo
)
{
return
new
Column
(
children:
<
Widget
>[
new
Padding
(
padding:
const
EdgeInsets
.
all
(
16.0
),
child:
new
MarkdownBody
(
data:
demo
.
description
)
),
onPressed:
onPressedDemo
)
]
)
new
Flexible
(
child:
demo
.
widget
)
]
);
}).
toList
(
)
)
]
);
}
}
class
FormattedCode
extends
StatefulWidget
{
FormattedCode
(
this
.
exampleCode
);
final
String
exampleCode
;
@override
_FormattedCodeState
createState
()
=>
new
_FormattedCodeState
();
}
class
_FormattedCodeState
extends
State
<
FormattedCode
>
{
@override
void
initState
()
{
super
.
initState
();
_formatText
();
}
TextSpan
_formattedText
;
@override
Widget
build
(
BuildContext
context
)
{
return
new
RichText
(
text:
_formattedText
);
}
@override
void
didUpdateConfig
(
FormattedCode
oldConfig
)
{
super
.
didUpdateConfig
(
oldConfig
);
if
(
oldConfig
.
exampleCode
!=
config
.
exampleCode
)
_formatText
();
}
void
_formatText
()
{
_formattedText
=
new
TextSpan
(
style:
new
TextStyle
(
fontFamily:
'monospace'
,
fontSize:
10.0
),
children:
<
TextSpan
>[
new
DartSyntaxHighlighter
().
format
(
config
.
exampleCode
)]
)
);
}
}
...
...
@@ -250,6 +126,10 @@ class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
@override
Widget
build
(
BuildContext
context
)
{
final
SyntaxHighlighterStyle
style
=
Theme
.
of
(
context
).
brightness
==
Brightness
.
dark
?
SyntaxHighlighterStyle
.
darkThemeStyle
()
:
SyntaxHighlighterStyle
.
lightThemeStyle
();
Widget
body
;
if
(
_exampleCode
==
null
)
{
body
=
new
Center
(
...
...
@@ -259,7 +139,14 @@ class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
body
=
new
ScrollableViewport
(
child:
new
Padding
(
padding:
new
EdgeInsets
.
all
(
16.0
),
child:
new
FormattedCode
(
_exampleCode
)
child:
new
RichText
(
text:
new
TextSpan
(
style:
new
TextStyle
(
fontFamily:
'monospace'
,
fontSize:
10.0
),
children:
<
TextSpan
>[
new
DartSyntaxHighlighter
(
style
).
format
(
_exampleCode
)
]
)
)
)
);
}
...
...
examples/flutter_gallery/lib/gallery/syntax_highlighter.dart
View file @
7c3a9435
...
...
@@ -17,19 +17,32 @@ class SyntaxHighlighterStyle {
this
.
constantStyle
});
static
SyntaxHighlighterStyle
default
Style
()
{
static
SyntaxHighlighterStyle
lightTheme
Style
()
{
return
new
SyntaxHighlighterStyle
(
baseStyle:
new
TextStyle
(
color:
const
Color
(
0x
ff
000000
)),
baseStyle:
new
TextStyle
(
color:
const
Color
(
0x
FF
000000
)),
numberStyle:
new
TextStyle
(
color:
const
Color
(
0xFF1565C0
)),
commentStyle:
new
TextStyle
(
color:
const
Color
(
0xFF9E9E9E
)),
keywordStyle:
new
TextStyle
(
color:
const
Color
(
0xFF9C27B0
)),
stringStyle:
new
TextStyle
(
color:
const
Color
(
0xFF43A047
)),
punctuationStyle:
new
TextStyle
(
color:
const
Color
(
0x
ff
000000
)),
punctuationStyle:
new
TextStyle
(
color:
const
Color
(
0x
FF
000000
)),
classStyle:
new
TextStyle
(
color:
const
Color
(
0xFF512DA8
)),
constantStyle:
new
TextStyle
(
color:
const
Color
(
0xFF795548
))
);
}
static
SyntaxHighlighterStyle
darkThemeStyle
()
{
return
new
SyntaxHighlighterStyle
(
baseStyle:
new
TextStyle
(
color:
const
Color
(
0xFFFFFFFF
)),
numberStyle:
new
TextStyle
(
color:
const
Color
(
0xFF1565C0
)),
commentStyle:
new
TextStyle
(
color:
const
Color
(
0xFF9E9E9E
)),
keywordStyle:
new
TextStyle
(
color:
const
Color
(
0xFF80CBC4
)),
stringStyle:
new
TextStyle
(
color:
const
Color
(
0xFF009688
)),
punctuationStyle:
new
TextStyle
(
color:
const
Color
(
0xFFFFFFFF
)),
classStyle:
new
TextStyle
(
color:
const
Color
(
0xFF009688
)),
constantStyle:
new
TextStyle
(
color:
const
Color
(
0xFF795548
))
);
}
final
TextStyle
baseStyle
;
final
TextStyle
numberStyle
;
final
TextStyle
commentStyle
;
...
...
@@ -49,7 +62,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
_spans
=
<
_HighlightSpan
>[];
if
(
_style
==
null
)
_style
=
SyntaxHighlighterStyle
.
d
efault
Style
();
_style
=
SyntaxHighlighterStyle
.
d
arkTheme
Style
();
}
SyntaxHighlighterStyle
_style
;
...
...
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