Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions feedback/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class _MyAppState extends State<MyApp> {
scrollController: scrollController,
)
: null,
showModeButtons: true,
theme: FeedbackThemeData(
background: Colors.grey,
feedbackSheetColor: Colors.grey[50]!,
Expand Down
7 changes: 7 additions & 0 deletions feedback/lib/src/better_feedback.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class BetterFeedback extends StatefulWidget {
this.localeOverride,
this.mode = FeedbackMode.draw,
this.pixelRatio = 3.0,
this.showModeButtons = true,
}) : assert(
pixelRatio > 0,
'pixelRatio needs to be larger than 0',
Expand Down Expand Up @@ -176,6 +177,11 @@ class BetterFeedback extends StatefulWidget {
/// for information on the underlying implementation.
final double pixelRatio;

/// Displays the mode switch buttons in the feedback UI.
///
/// If set to `false`, the mode can only be changed through the `mode` property.
final bool showModeButtons;

/// Call `BetterFeedback.of(context)` to get an
/// instance of [FeedbackData] on which you can call `.show()` or `.hide()`
/// to enable or disable the feedback view.
Expand Down Expand Up @@ -233,6 +239,7 @@ class _BetterFeedbackState extends State<BetterFeedback> {
isFeedbackVisible: controller.isVisible,
drawColors: FeedbackTheme.of(context).drawColors,
mode: widget.mode,
showModeButtons: widget.showModeButtons,
pixelRatio: widget.pixelRatio,
feedbackBuilder:
widget.feedbackBuilder ?? simpleFeedbackBuilder,
Expand Down
52 changes: 28 additions & 24 deletions feedback/lib/src/controls_column.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ControlsColumn extends StatelessWidget {
required this.onUndo,
required this.onControlModeChanged,
required this.onCloseFeedback,
required this.showModeButtons,
required this.onClearDrawing,
required this.colors,
}) : assert(
Expand All @@ -32,6 +33,7 @@ class ControlsColumn extends StatelessWidget {
final VoidCallback onClearDrawing;
final List<Color> colors;
final Color activeColor;
final bool showModeButtons;
final FeedbackMode mode;

@override
Expand All @@ -55,32 +57,34 @@ class ControlsColumn extends StatelessWidget {
onPressed: onCloseFeedback,
),
_ColumnDivider(),
RotatedBox(
quarterTurns: 1,
child: MaterialButton(
key: const ValueKey<String>('navigate_button'),
onPressed: isNavigatingActive
? null
: () => onControlModeChanged(FeedbackMode.navigate),
disabledTextColor:
FeedbackTheme.of(context).activeFeedbackModeColor,
child: Text(FeedbackLocalizations.of(context).navigate),
if (showModeButtons) ...[
RotatedBox(
quarterTurns: 1,
child: MaterialButton(
key: const ValueKey<String>('navigate_button'),
onPressed: isNavigatingActive
? null
: () => onControlModeChanged(FeedbackMode.navigate),
disabledTextColor:
FeedbackTheme.of(context).activeFeedbackModeColor,
child: Text(FeedbackLocalizations.of(context).navigate),
),
),
),
_ColumnDivider(),
RotatedBox(
quarterTurns: 1,
child: MaterialButton(
key: const ValueKey<String>('draw_button'),
minWidth: 20,
onPressed: isNavigatingActive
? () => onControlModeChanged(FeedbackMode.draw)
: null,
disabledTextColor:
FeedbackTheme.of(context).activeFeedbackModeColor,
child: Text(FeedbackLocalizations.of(context).draw),
_ColumnDivider(),
RotatedBox(
quarterTurns: 1,
child: MaterialButton(
key: const ValueKey<String>('draw_button'),
minWidth: 20,
onPressed: isNavigatingActive
? () => onControlModeChanged(FeedbackMode.draw)
: null,
disabledTextColor:
FeedbackTheme.of(context).activeFeedbackModeColor,
child: Text(FeedbackLocalizations.of(context).draw),
),
),
),
],
IconButton(
key: const ValueKey<String>('undo_button'),
icon: const Icon(Icons.undo),
Expand Down
3 changes: 3 additions & 0 deletions feedback/lib/src/feedback_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class FeedbackWidget extends StatefulWidget {
required this.child,
required this.isFeedbackVisible,
required this.drawColors,
required this.showModeButtons,
required this.mode,
required this.pixelRatio,
required this.feedbackBuilder,
Expand All @@ -35,6 +36,7 @@ class FeedbackWidget extends StatefulWidget {
);

final bool isFeedbackVisible;
final bool showModeButtons;
final FeedbackMode mode;
final double pixelRatio;
final Widget child;
Expand Down Expand Up @@ -219,6 +221,7 @@ class FeedbackWidgetState extends State<FeedbackWidget>
child: ControlsColumn(
mode: mode,
activeColor: painterController.drawColor,
showModeButtons: widget.showModeButtons,
colors: widget.drawColors,
onColorChanged: (color) {
setState(() {
Expand Down
2 changes: 2 additions & 0 deletions feedback/test/controls_column_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ void main() {
Widget create({
Color? activeColor,
FeedbackMode? mode,
bool? showNavigateButton,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool? showNavigateButton,
bool? showModeButton,

ValueChanged<Color>? onColorChanged,
VoidCallback? onUndo,
ValueChanged<FeedbackMode>? onControlModeChanged,
Expand All @@ -19,6 +20,7 @@ void main() {
child: ControlsColumn(
activeColor: activeColor ?? Colors.red,
mode: mode ?? FeedbackMode.draw,
showModeButtons: showNavigateButton ?? true,
colors:
colors ?? [Colors.red, Colors.green, Colors.blue, Colors.yellow],
onClearDrawing: onClearDrawing ?? () {},
Expand Down