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
Aleksei
2023-12-21 17:34:47 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
David PHAM-VAN
2024-01-27 12:11:28 -0400
Commit
2bc581d6d511524968aaa0d3c37a680522c67c39
2bc581d6
1 parent
df3167c7
Implement and apply `PdfActionBarTheme`
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
4 deletions
printing/lib/src/preview/action_bar_theme.dart
printing/lib/src/preview/pdf_preview.dart
printing/lib/src/preview/action_bar_theme.dart
0 → 100644
View file @
2bc581d
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
class
PdfActionBarTheme
with
Diagnosticable
{
/// Creates a theme for action bar of [PdfPreviewController].
const
PdfActionBarTheme
({
this
.
backgroundColor
,
this
.
iconColor
,
this
.
height
,
this
.
textStyle
,
this
.
elevation
=
4
,
this
.
alignment
=
WrapAlignment
.
spaceAround
,
});
final
Color
?
backgroundColor
;
final
Color
?
iconColor
;
final
double
?
height
;
final
TextStyle
?
textStyle
;
final
double
elevation
;
final
WrapAlignment
alignment
;
/// Creates a copy of this object but with the given fields replaced with the
/// new values.
PdfActionBarTheme
copyWith
({
Color
?
backgroundColor
,
Color
?
iconColor
,
double
?
height
,
TextStyle
?
textStyle
,
double
?
elevation
,
WrapAlignment
?
alignment
,
})
{
return
PdfActionBarTheme
(
backgroundColor:
backgroundColor
??
this
.
backgroundColor
,
iconColor:
iconColor
??
this
.
iconColor
,
height:
height
??
this
.
height
,
textStyle:
textStyle
??
this
.
textStyle
,
elevation:
elevation
??
this
.
elevation
,
alignment:
alignment
??
this
.
alignment
,
);
}
@override
int
get
hashCode
=>
Object
.
hashAll
(
[
backgroundColor
,
iconColor
,
height
,
textStyle
,
elevation
,
alignment
]);
@override
bool
operator
==(
Object
other
)
{
if
(
identical
(
this
,
other
))
{
return
true
;
}
if
(
other
.
runtimeType
!=
runtimeType
)
{
return
false
;
}
return
other
is
PdfActionBarTheme
&&
other
.
backgroundColor
==
backgroundColor
&&
other
.
iconColor
==
iconColor
&&
other
.
height
==
height
&&
other
.
textStyle
==
textStyle
&&
other
.
elevation
==
elevation
&&
other
.
alignment
==
alignment
;
}
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
properties
.
add
(
ColorProperty
(
'backgroundColor'
,
backgroundColor
));
properties
.
add
(
ColorProperty
(
'iconColor'
,
iconColor
));
properties
.
add
(
DoubleProperty
(
'height'
,
height
));
properties
.
add
(
DiagnosticsProperty
<
TextStyle
>(
'textStyle'
,
textStyle
));
properties
.
add
(
DoubleProperty
(
'elevation'
,
elevation
));
properties
.
add
(
DiagnosticsProperty
<
WrapAlignment
>(
'alignment'
,
alignment
,
defaultValue:
WrapAlignment
.
spaceAround
));
}
}
...
...
printing/lib/src/preview/pdf_preview.dart
View file @
2bc581d
...
...
@@ -21,6 +21,7 @@ import 'package:pdf/widgets.dart' as pw;
import
'../callback.dart'
;
import
'../printing.dart'
;
import
'../printing_info.dart'
;
import
'action_bar_theme.dart'
;
import
'actions.dart'
;
import
'controller.dart'
;
import
'custom.dart'
;
...
...
@@ -62,6 +63,7 @@ class PdfPreview extends StatefulWidget {
this
.
loadingWidget
,
this
.
onPageFormatChanged
,
this
.
dpi
,
this
.
actionBarTheme
=
const
PdfActionBarTheme
(),
})
:
_pagesBuilder
=
null
,
super
(
key:
key
);
...
...
@@ -119,6 +121,7 @@ class PdfPreview extends StatefulWidget {
this
.
loadingWidget
,
this
.
onPageFormatChanged
,
this
.
dpi
,
this
.
actionBarTheme
=
const
PdfActionBarTheme
(),
required
CustomPdfPagesBuilder
pagesBuilder
,
})
:
_pagesBuilder
=
pagesBuilder
,
super
(
key:
key
);
...
...
@@ -223,6 +226,9 @@ class PdfPreview extends StatefulWidget {
/// If not provided, this value is calculated.
final
double
?
dpi
;
/// The style of actions bar.
final
PdfActionBarTheme
actionBarTheme
;
/// clients can pass this builder to render
/// their own pages.
final
CustomPdfPagesBuilder
?
_pagesBuilder
;
...
...
@@ -406,16 +412,19 @@ class PdfPreviewState extends State<PdfPreview> {
if
(
actions
.
isNotEmpty
)
IconTheme
.
merge
(
data:
IconThemeData
(
color:
iconColor
,
color:
widget
.
actionBarTheme
.
iconColor
??
iconColor
,
),
child:
Material
(
elevation:
4
,
color:
theme
.
primaryColor
,
elevation:
widget
.
actionBarTheme
.
elevation
,
color:
widget
.
actionBarTheme
.
backgroundColor
??
theme
.
primaryColor
,
textStyle:
widget
.
actionBarTheme
.
textStyle
,
child:
SizedBox
(
width:
double
.
infinity
,
height:
widget
.
actionBarTheme
.
height
,
child:
SafeArea
(
child:
Wrap
(
alignment:
WrapAlignment
.
spaceAround
,
alignment:
widget
.
actionBarTheme
.
alignment
,
children:
actions
,
),
),
...
...
Please
register
or
login
to post a comment