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
2019-03-25 10:13:58 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7a7694350c73aad509df93dfd6172c7ca06843c8
7a769435
1 parent
2ebeb104
Add Circular Progress Indicator
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
4 deletions
pdf/CHANGELOG.md
pdf/lib/src/graphics.dart
pdf/lib/widgets.dart
pdf/lib/widgets/progress.dart
pdf/test/widget_test.dart
pdf/CHANGELOG.md
View file @
7a76943
...
...
@@ -3,6 +3,7 @@
*
Remove color constants from PdfColor, use PdfColors
*
Add TTF Font SubSetting
*
Add Unicode support for TTF Fonts
*
Add Circular Progress Indicator
# 1.3.4
*
Add available dimensions for PdfPageFormat
...
...
pdf/lib/src/graphics.dart
View file @
7a76943
...
...
@@ -397,7 +397,7 @@ class PdfGraphics {
/// The center (cx, cy) of the ellipse is calculated automatically to satisfy
/// the constraints imposed by the other parameters. large and sweep flags
/// contribute to the automatic calculations and help determine how the arc is drawn.
void
_
bezierArc
(
void
bezierArc
(
double
x1
,
double
y1
,
double
rx
,
double
ry
,
double
x2
,
double
y2
,
{
bool
large
=
false
,
bool
sweep
=
false
,
double
phi
=
0.0
})
{
if
(
x1
==
x2
&&
y1
==
y2
)
{
...
...
@@ -555,7 +555,7 @@ class PdfGraphics {
case
'A'
:
// elliptical arc, absolute
int
len
=
0
;
while
(
len
<
points
.
length
)
{
_
bezierArc
(
lastPoint
.
x
,
lastPoint
.
y
,
points
[
len
+
0
],
bezierArc
(
lastPoint
.
x
,
lastPoint
.
y
,
points
[
len
+
0
],
points
[
len
+
1
],
points
[
len
+
5
],
points
[
len
+
6
],
phi:
points
[
len
+
2
]
*
math
.
pi
/
180.0
,
large:
points
[
len
+
3
]
!=
0.0
,
...
...
@@ -569,7 +569,7 @@ class PdfGraphics {
while
(
len
<
points
.
length
)
{
points
[
len
+
5
]
+=
lastPoint
.
x
;
points
[
len
+
6
]
+=
lastPoint
.
y
;
_
bezierArc
(
lastPoint
.
x
,
lastPoint
.
y
,
points
[
len
+
0
],
bezierArc
(
lastPoint
.
x
,
lastPoint
.
y
,
points
[
len
+
0
],
points
[
len
+
1
],
points
[
len
+
5
],
points
[
len
+
6
],
phi:
points
[
len
+
2
]
*
math
.
pi
/
180.0
,
large:
points
[
len
+
3
]
!=
0.0
,
...
...
pdf/lib/widgets.dart
View file @
7a76943
...
...
@@ -36,6 +36,7 @@ part 'widgets/grid_view.dart';
part
'widgets/image.dart'
;
part
'widgets/multi_page.dart'
;
part
'widgets/placeholders.dart'
;
part
'widgets/progress.dart'
;
part
'widgets/stack.dart'
;
part
'widgets/table.dart'
;
part
'widgets/text.dart'
;
...
...
pdf/lib/widgets/progress.dart
0 → 100644
View file @
7a76943
/*
* Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
part of
widget
;
class
CircularProgressIndicator
extends
Widget
{
CircularProgressIndicator
(
{
@required
this
.
value
,
this
.
color
,
this
.
strokeWidth
=
4.0
,
this
.
backgroundColor
})
:
assert
(
value
!=
null
),
assert
(
strokeWidth
!=
null
);
final
double
value
;
final
PdfColor
color
;
final
PdfColor
backgroundColor
;
final
double
strokeWidth
;
@override
void
layout
(
Context
context
,
BoxConstraints
constraints
,
{
bool
parentUsesSize
=
false
})
{
box
=
PdfRect
.
fromPoints
(
PdfPoint
.
zero
,
constraints
.
biggest
);
}
@override
void
paint
(
Context
context
)
{
super
.
paint
(
context
);
final
double
adjustedValue
=
value
.
clamp
(
0.00001
,
.
99999
);
final
double
rx
=
box
.
width
/
2
;
final
double
ry
=
box
.
height
/
2
;
const
double
angleStart
=
math
.
pi
/
2
;
final
double
angleEnd
=
angleStart
-
math
.
pi
*
2
*
adjustedValue
;
final
PdfPoint
startTop
=
PdfPoint
(
box
.
x
+
rx
+
math
.
cos
(
angleStart
)
*
rx
,
box
.
y
+
ry
+
math
.
sin
(
angleStart
)
*
ry
,
);
final
PdfPoint
endTop
=
PdfPoint
(
box
.
x
+
rx
+
math
.
cos
(
angleEnd
)
*
rx
,
box
.
y
+
ry
+
math
.
sin
(
angleEnd
)
*
ry
,
);
final
PdfPoint
startBottom
=
PdfPoint
(
box
.
x
+
rx
+
math
.
cos
(
angleStart
)
*
(
rx
-
strokeWidth
),
box
.
y
+
ry
+
math
.
sin
(
angleStart
)
*
(
ry
-
strokeWidth
),
);
final
PdfPoint
endBottom
=
PdfPoint
(
box
.
x
+
rx
+
math
.
cos
(
angleEnd
)
*
(
rx
-
strokeWidth
),
box
.
y
+
ry
+
math
.
sin
(
angleEnd
)
*
(
ry
-
strokeWidth
),
);
if
(
backgroundColor
!=
null
&&
value
<
1
)
{
context
.
canvas
..
moveTo
(
startTop
.
x
,
startTop
.
y
)
..
bezierArc
(
startTop
.
x
,
startTop
.
y
,
rx
,
ry
,
endTop
.
x
,
endTop
.
y
,
large:
adjustedValue
<
.
5
,
sweep:
true
)
..
lineTo
(
endBottom
.
x
,
endBottom
.
y
)
..
bezierArc
(
endBottom
.
x
,
endBottom
.
y
,
rx
-
strokeWidth
,
ry
-
strokeWidth
,
startBottom
.
x
,
startBottom
.
y
,
large:
adjustedValue
<
.
5
)
..
lineTo
(
startTop
.
x
,
startTop
.
y
)
..
setFillColor
(
backgroundColor
)
..
fillPath
();
}
if
(
value
>
0
)
{
context
.
canvas
..
moveTo
(
startTop
.
x
,
startTop
.
y
)
..
bezierArc
(
startTop
.
x
,
startTop
.
y
,
rx
,
ry
,
endTop
.
x
,
endTop
.
y
,
large:
adjustedValue
>
.
5
)
..
lineTo
(
endBottom
.
x
,
endBottom
.
y
)
..
bezierArc
(
endBottom
.
x
,
endBottom
.
y
,
rx
-
strokeWidth
,
ry
-
strokeWidth
,
startBottom
.
x
,
startBottom
.
y
,
large:
adjustedValue
>
.
5
,
sweep:
true
)
..
lineTo
(
startTop
.
x
,
startTop
.
y
)
..
setFillColor
(
color
??
PdfColors
.
indigo
)
..
fillPath
();
}
}
}
...
...
pdf/test/widget_test.dart
View file @
7a76943
...
...
@@ -182,7 +182,24 @@ void main() {
bottom:
10
,
child:
UrlLink
(
child:
Text
(
'dart_pdf'
),
destination:
'https://github.com/DavBfr/dart_pdf/'
))
destination:
'https://github.com/DavBfr/dart_pdf/'
)),
Positioned
(
left:
10
,
top:
10
,
child:
Container
(
width:
100
,
height:
100
,
child:
Stack
(
alignment:
Alignment
.
center
,
fit:
StackFit
.
expand
,
children:
<
Widget
>[
Center
(
child:
Text
(
'30%'
,
textScaleFactor:
1.5
)),
CircularProgressIndicator
(
value:
.
3
,
backgroundColor:
PdfColors
.
grey300
,
strokeWidth:
15
),
])))
])));
final
File
file
=
File
(
'widgets.pdf'
);
...
...
Please
register
or
login
to post a comment