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
Milad akarie
2023-07-01 17:54:41 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
David PHAM-VAN
2023-07-24 08:39:22 -0300
Commit
cc103de7cb29d1386fee856ff16c270104358a05
cc103de7
1 parent
68ed48b0
Add RTL support to Wrap widget
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
1 deletions
pdf/lib/src/widgets/wrap.dart
pdf/test/rtl_layout_test.dart
pdf/lib/src/widgets/wrap.dart
View file @
cc103de
...
...
@@ -16,6 +16,7 @@
import
'dart:math'
as
math
;
import
'package:pdf/widgets.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
import
'../../pdf.dart'
;
...
...
@@ -164,11 +165,14 @@ class Wrap extends MultiChildWidget with SpanningWidget {
double
?
mainAxisLimit
=
0.0
;
var
flipMainAxis
=
false
;
var
flipCrossAxis
=
false
;
final
textDirection
=
Directionality
.
of
(
context
);
switch
(
direction
)
{
case
Axis
.
horizontal
:
childConstraints
=
BoxConstraints
(
maxWidth:
constraints
.
maxWidth
);
mainAxisLimit
=
constraints
.
maxWidth
;
if
(
textDirection
==
TextDirection
.
rtl
)
{
flipMainAxis
=
true
;
}
if
(
verticalDirection
==
VerticalDirection
.
down
)
{
flipCrossAxis
=
true
;
}
...
...
@@ -179,6 +183,9 @@ class Wrap extends MultiChildWidget with SpanningWidget {
if
(
verticalDirection
==
VerticalDirection
.
down
)
{
flipMainAxis
=
true
;
}
if
(
textDirection
==
TextDirection
.
rtl
)
{
flipCrossAxis
=
true
;
}
break
;
}
...
...
pdf/test/rtl_layout_test.dart
View file @
cc103de
...
...
@@ -34,6 +34,17 @@ final _redBox = Container(
color:
PdfColors
.
red
,
);
final
_yellowBox
=
Container
(
width:
50
,
height:
50
,
color:
PdfColors
.
yellow
,
);
final
_greenBox
=
Container
(
width:
50
,
height:
50
,
color:
PdfColors
.
green
,
);
void
main
(
)
{
setUpAll
(()
{
Document
.
debug
=
true
;
...
...
@@ -124,6 +135,75 @@ void main() {
);
});
test
(
'Wrap Should render blue,red,yellow ordered RTL'
,
()
{
pdf
.
addPage
(
Page
(
textDirection:
TextDirection
.
rtl
,
pageFormat:
const
PdfPageFormat
(
150
,
150
),
build:
(
Context
context
)
=>
SizedBox
(
width:
150
,
height:
150
,
child:
Wrap
(
children:
[
_blueBox
,
_redBox
,
_yellowBox
],
)
),
),
);
});
test
(
'Wrap Should render blue,red,yellow ordered LTR'
,
()
{
pdf
.
addPage
(
Page
(
textDirection:
TextDirection
.
ltr
,
pageFormat:
const
PdfPageFormat
(
150
,
150
),
build:
(
Context
context
)
=>
SizedBox
(
width:
150
,
height:
150
,
child:
Wrap
(
children:
[
_blueBox
,
_redBox
,
_yellowBox
],
)
),
),
);
});
test
(
'Wrap Should render blue,red,yellow ordered RTL aligned center'
,
()
{
pdf
.
addPage
(
Page
(
textDirection:
TextDirection
.
rtl
,
pageFormat:
const
PdfPageFormat
(
150
,
150
),
build:
(
Context
context
)
=>
SizedBox
(
width:
150
,
height:
150
,
child:
Wrap
(
spacing:
10
,
runSpacing:
10
,
runAlignment:
WrapAlignment
.
center
,
children:
[
_blueBox
,
_redBox
,
_yellowBox
],
)
),
),
);
});
test
(
'Wrap Should render blue,red,yellow ordered RTL aligned bottom'
,
()
{
pdf
.
addPage
(
Page
(
textDirection:
TextDirection
.
rtl
,
pageFormat:
const
PdfPageFormat
(
150
,
150
),
build:
(
Context
context
)
=>
SizedBox
(
width:
150
,
height:
150
,
child:
Wrap
(
spacing:
10
,
runSpacing:
10
,
runAlignment:
WrapAlignment
.
end
,
children:
[
_blueBox
,
_redBox
,
_yellowBox
],
)
),
),
);
});
tearDownAll
(()
async
{
final
file
=
File
(
'rtl-layout.pdf'
);
await
file
.
writeAsBytes
(
await
pdf
.
save
());
...
...
Please
register
or
login
to post a comment