Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2020-11-19 07:55:19 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
84d5cc5950d722ecc75cf8d91051aad74f83927f
84d5cc59
1 parent
590e15ce
Add textDirection parameter to PageTheme
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
13 deletions
pdf/CHANGELOG.md
pdf/lib/widgets/multi_page.dart
pdf/lib/widgets/page.dart
pdf/lib/widgets/page_theme.dart
pdf/lib/widgets/text_style.dart
pdf/lib/widgets/widget.dart
pdf/pubspec.yaml
pdf/CHANGELOG.md
View file @
84d5cc5
# Changelog
## 1.12.0
-
Add textDirection parameter to PageTheme
## 1.11.2
-
Fix Table.fromTextArray vertical alignment
...
...
pdf/lib/widgets/multi_page.dart
View file @
84d5cc5
...
...
@@ -88,6 +88,7 @@ class MultiPage extends Page {
this
.
maxPages
=
20
,
PageOrientation
orientation
,
EdgeInsets
margin
,
TextDirection
textDirection
,
})
:
_buildList
=
build
,
assert
(
mainAxisAlignment
!=
null
),
assert
(
crossAxisAlignment
!=
null
),
...
...
@@ -97,7 +98,9 @@ class MultiPage extends Page {
pageFormat:
pageFormat
,
margin:
margin
,
theme:
theme
,
orientation:
orientation
);
orientation:
orientation
,
textDirection:
textDirection
,
);
final
BuildListCallback
_buildList
;
...
...
@@ -168,7 +171,11 @@ class MultiPage extends Page {
int
index
=
0
;
int
sameCount
=
0
;
final
Context
baseContext
=
Context
(
document:
document
.
document
).
inheritFrom
(
calculatedTheme
);
Context
(
document:
document
.
document
).
inheritFromAll
(<
Inherited
>[
calculatedTheme
,
if
(
pageTheme
.
textDirection
!=
null
)
InheritedDirectionality
(
pageTheme
.
textDirection
),
]);
final
List
<
Widget
>
children
=
_buildList
(
baseContext
);
WidgetContext
widgetContext
;
...
...
pdf/lib/widgets/page.dart
View file @
84d5cc5
...
...
@@ -24,21 +24,23 @@ typedef BuildListCallback = List<Widget> Function(Context context);
enum
PageOrientation
{
natural
,
landscape
,
portrait
}
class
Page
{
Page
(
{
PageTheme
pageTheme
,
Page
({
PageTheme
pageTheme
,
PdfPageFormat
pageFormat
,
BuildCallback
build
,
ThemeData
theme
,
PageOrientation
orientation
,
EdgeInsets
margin
,
bool
clip
=
false
})
:
assert
(
bool
clip
=
false
,
TextDirection
textDirection
,
})
:
assert
(
pageTheme
==
null
||
(
pageFormat
==
null
&&
theme
==
null
&&
orientation
==
null
&&
margin
==
null
&&
clip
==
false
),
clip
==
false
&&
textDirection
==
null
),
'Don
\'
t set both pageTheme and other settings'
),
pageTheme
=
pageTheme
??
PageTheme
(
...
...
@@ -47,6 +49,7 @@ class Page {
margin:
margin
,
theme:
theme
,
clip:
clip
,
textDirection:
textDirection
,
),
_build
=
build
;
...
...
@@ -106,7 +109,11 @@ class Page {
document:
document
.
document
,
page:
_pdfPage
,
canvas:
canvas
,
).
inheritFrom
(
calculatedTheme
);
).
inheritFromAll
(<
Inherited
>[
calculatedTheme
,
if
(
pageTheme
.
textDirection
!=
null
)
InheritedDirectionality
(
pageTheme
.
textDirection
),
]);
Widget
background
;
Widget
content
;
...
...
pdf/lib/widgets/page_theme.dart
View file @
84d5cc5
...
...
@@ -26,6 +26,7 @@ class PageTheme {
PageOrientation
orientation
,
EdgeInsets
margin
,
this
.
clip
=
false
,
this
.
textDirection
,
})
:
pageFormat
=
pageFormat
??
PdfPageFormat
.
standard
,
orientation
=
orientation
??
PageOrientation
.
natural
,
_margin
=
margin
;
...
...
@@ -44,6 +45,8 @@ class PageTheme {
final
bool
clip
;
final
TextDirection
textDirection
;
bool
get
mustRotate
=>
(
orientation
==
PageOrientation
.
landscape
&&
pageFormat
.
height
>
pageFormat
.
width
)
||
...
...
@@ -77,6 +80,7 @@ class PageTheme {
PageOrientation
orientation
,
EdgeInsets
margin
,
bool
clip
,
TextDirection
textDirection
,
})
=>
PageTheme
(
pageFormat:
pageFormat
??
this
.
pageFormat
,
...
...
@@ -86,5 +90,6 @@ class PageTheme {
orientation:
orientation
??
this
.
orientation
,
margin:
margin
??
this
.
margin
,
clip:
clip
??
this
.
clip
,
textDirection:
textDirection
??
this
.
textDirection
,
);
}
...
...
pdf/lib/widgets/text_style.dart
View file @
84d5cc5
...
...
@@ -381,7 +381,14 @@ class TextStyle {
'TextStyle(color:
$color
font:
$font
size:
$fontSize
weight:
$fontWeight
style:
$fontStyle
letterSpacing:
$letterSpacing
wordSpacing:
$wordSpacing
lineSpacing:
$lineSpacing
height:
$height
background:
$background
decoration:
$decoration
decorationColor:
$decorationColor
decorationStyle:
$decorationStyle
decorationThickness:
$decorationThickness
, renderingMode:
$renderingMode
)'
;
}
class
Directionality
extends
StatelessWidget
implements
Inherited
{
class
InheritedDirectionality
extends
Inherited
{
const
InheritedDirectionality
(
this
.
textDirection
);
/// The text direction for this subtree.
final
TextDirection
textDirection
;
}
class
Directionality
extends
StatelessWidget
{
/// Creates a widget that determines the directionality of text and
/// text-direction-sensitive render objects.
///
...
...
@@ -410,15 +417,16 @@ class Directionality extends StatelessWidget implements Inherited {
/// TextDirection textDirection = Directionality.of(context);
/// ```
static
TextDirection
of
(
Context
context
)
{
final
Directionality
widget
=
context
.
inherited
[
Directionality
];
return
widget
?.
textDirection
??
TextDirection
.
ltr
;
final
InheritedDirectionality
inherited
=
context
.
inherited
[
InheritedDirectionality
];
return
inherited
?.
textDirection
??
TextDirection
.
ltr
;
}
@override
Widget
build
(
Context
context
)
{
return
InheritedWidget
(
build:
(
Context
context
)
=>
child
,
inherited:
this
,
inherited:
InheritedDirectionality
(
textDirection
)
,
);
}
}
...
...
pdf/lib/widgets/widget.dart
View file @
84d5cc5
...
...
@@ -68,9 +68,15 @@ class Context {
}
Context
inheritFrom
(
Inherited
object
)
{
return
inheritFromAll
(<
Inherited
>[
object
]);
}
Context
inheritFromAll
(
Iterable
<
Inherited
>
objects
)
{
final
HashMap
<
Type
,
Inherited
>
inherited
=
HashMap
<
Type
,
Inherited
>.
of
(
this
.
inherited
);
for
(
final
Inherited
object
in
objects
)
{
inherited
[
object
.
runtimeType
]
=
object
;
}
return
copyWith
(
inherited:
inherited
);
}
}
...
...
pdf/pubspec.yaml
View file @
84d5cc5
...
...
@@ -4,7 +4,7 @@ description: A pdf producer for Dart. It can create pdf files for both web or fl
homepage
:
https://github.com/DavBfr/dart_pdf/tree/master/pdf
repository
:
https://github.com/DavBfr/dart_pdf
issue_tracker
:
https://github.com/DavBfr/dart_pdf/issues
version
:
1.1
1.2
version
:
1.1
2.0
environment
:
sdk
:
"
>=2.3.0
<3.0.0"
...
...
Please
register
or
login
to post a comment