Skip to content

Commit 77df555

Browse files
committed
Add options to hide the vote and or comment buttons on content items
1 parent a7c4c08 commit 77df555

4 files changed

Lines changed: 161 additions & 106 deletions

File tree

lib/l10n/app_en.arb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@
189189
"settings_enableTrueBlack": "Enable true black",
190190
"settings_enableTrueBlack_help": "Might save power on AMOLED displays",
191191
"settings_compactMode": "Compact mode",
192+
"settings_hideVoteButtons": "Hide vote buttons",
193+
"settings_hideCommentButtons": "Hide comment buttons",
192194
"settings_alwaysShowInstance": "Always show instance",
193195
"settings_alwaysShowInstance_help": "When enabled, the instance of a user/magazine will always display after their username",
194196
"settings_coverMediaMarkedSensitive": "Cover up media marked as sensitive",

lib/src/controller/profile.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class ProfileRequired with _$ProfileRequired {
3737
required FlexScheme colorScheme,
3838
required bool enableTrueBlack,
3939
required bool compactMode,
40+
required bool hideVoteButtons,
41+
required bool hideCommentButtons,
4042
required bool alwaysShowInstance,
4143
required bool coverMediaMarkedSensitive,
4244
required bool fullImageSizeThreads,
@@ -98,6 +100,10 @@ class ProfileRequired with _$ProfileRequired {
98100
enableTrueBlack:
99101
profile?.enableTrueBlack ?? defaultProfile.enableTrueBlack,
100102
compactMode: profile?.compactMode ?? defaultProfile.compactMode,
103+
hideVoteButtons:
104+
profile?.hideVoteButtons ?? defaultProfile.hideVoteButtons,
105+
hideCommentButtons:
106+
profile?.hideCommentButtons ?? defaultProfile.hideCommentButtons,
101107
alwaysShowInstance:
102108
profile?.alwaysShowInstance ?? defaultProfile.alwaysShowInstance,
103109
coverMediaMarkedSensitive: profile?.coverMediaMarkedSensitive ??
@@ -167,6 +173,8 @@ class ProfileRequired with _$ProfileRequired {
167173
colorScheme: FlexScheme.custom,
168174
enableTrueBlack: false,
169175
compactMode: false,
176+
hideVoteButtons: false,
177+
hideCommentButtons: false,
170178
alwaysShowInstance: false,
171179
coverMediaMarkedSensitive: true,
172180
fullImageSizeThreads: false,
@@ -220,6 +228,8 @@ class ProfileOptional with _$ProfileOptional {
220228
required FlexScheme? colorScheme,
221229
required bool? enableTrueBlack,
222230
required bool? compactMode,
231+
required bool? hideVoteButtons,
232+
required bool? hideCommentButtons,
223233
required bool? alwaysShowInstance,
224234
required bool? coverMediaMarkedSensitive,
225235
required bool? fullImageSizeThreads,
@@ -270,6 +280,8 @@ class ProfileOptional with _$ProfileOptional {
270280
colorScheme: null,
271281
enableTrueBlack: null,
272282
compactMode: null,
283+
hideVoteButtons: null,
284+
hideCommentButtons: null,
273285
alwaysShowInstance: null,
274286
coverMediaMarkedSensitive: null,
275287
fullImageSizeThreads: null,
@@ -319,6 +331,8 @@ class ProfileOptional with _$ProfileOptional {
319331
colorScheme: other.colorScheme ?? colorScheme,
320332
enableTrueBlack: other.enableTrueBlack ?? enableTrueBlack,
321333
compactMode: other.compactMode ?? compactMode,
334+
hideVoteButtons: other.hideVoteButtons ?? hideVoteButtons,
335+
hideCommentButtons: other.hideCommentButtons ?? hideCommentButtons,
322336
alwaysShowInstance: other.alwaysShowInstance ?? alwaysShowInstance,
323337
coverMediaMarkedSensitive:
324338
other.coverMediaMarkedSensitive ?? coverMediaMarkedSensitive,

lib/src/screens/settings/display_screen.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ class DisplaySettingsScreen extends StatelessWidget {
8989
ac.selectedProfileValue.copyWith(compactMode: newValue),
9090
),
9191
),
92+
ListTileSwitch(
93+
leading: const Icon(Symbols.view_agenda_rounded),
94+
title: Text(l(context).settings_hideVoteButtons),
95+
value: ac.profile.hideVoteButtons,
96+
onChanged: (newValue) => ac.updateProfile(
97+
ac.selectedProfileValue.copyWith(hideVoteButtons: newValue),
98+
),
99+
),
100+
ListTileSwitch(
101+
leading: const Icon(Symbols.view_agenda_rounded),
102+
title: Text(l(context).settings_hideCommentButtons),
103+
value: ac.profile.hideCommentButtons,
104+
onChanged: (newValue) => ac.updateProfile(
105+
ac.selectedProfileValue.copyWith(hideCommentButtons: newValue),
106+
),
107+
),
92108
const Divider(),
93109
ListTileSwitch(
94110
leading: const Icon(Symbols.globe_rounded),

lib/src/widgets/content_item/content_item.dart

Lines changed: 129 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:flex_color_scheme/flex_color_scheme.dart';
21
import 'package:flutter/material.dart';
32
import 'package:interstellar/src/controller/controller.dart';
43
import 'package:interstellar/src/controller/server.dart';
@@ -575,119 +574,143 @@ class _ContentItemState extends State<ContentItem> {
575574
.profile
576575
.compactMode))
577576
contentBody(context),
578-
Padding(
579-
padding: const EdgeInsets.only(top: 10),
580-
child:
581-
LayoutBuilder(builder: (context, constrains) {
582-
final votingWidgets = [
583-
if (widget.activeBookmarkLists != null)
584-
widget.activeBookmarkLists!.isEmpty
585-
? LoadingIconButton(
586-
onPressed: widget.onAddBookmark,
587-
icon: const Icon(
588-
Symbols.bookmark_rounded,
589-
fill: 0,
577+
if (!context
578+
.read<AppController>()
579+
.profile
580+
.hideVoteButtons ||
581+
!context
582+
.read<AppController>()
583+
.profile
584+
.hideCommentButtons)
585+
Padding(
586+
padding: const EdgeInsets.only(top: 10),
587+
child:
588+
LayoutBuilder(builder: (context, constrains) {
589+
final votingWidgets = [
590+
if (widget.activeBookmarkLists != null)
591+
widget.activeBookmarkLists!.isEmpty
592+
? LoadingIconButton(
593+
onPressed: widget.onAddBookmark,
594+
icon: const Icon(
595+
Symbols.bookmark_rounded,
596+
fill: 0,
597+
),
598+
)
599+
: LoadingIconButton(
600+
onPressed: widget.onRemoveBookmark,
601+
icon: const Icon(
602+
Symbols.bookmark_rounded,
603+
fill: 1,
604+
),
590605
),
591-
)
592-
: LoadingIconButton(
593-
onPressed: widget.onRemoveBookmark,
594-
icon: const Icon(
595-
Symbols.bookmark_rounded,
596-
fill: 1,
606+
if (widget.boosts != null)
607+
Padding(
608+
padding: const EdgeInsets.only(right: 8),
609+
child: Row(
610+
children: [
611+
IconButton(
612+
icon: const Icon(
613+
Symbols.rocket_launch_rounded),
614+
color: widget.isBoosted
615+
? Colors.purple.shade400
616+
: null,
617+
onPressed: widget.onBoost,
597618
),
598-
),
599-
if (widget.boosts != null)
600-
Padding(
601-
padding: const EdgeInsets.only(right: 8),
602-
child: Row(
603-
children: [
604-
IconButton(
605-
icon: const Icon(
606-
Symbols.rocket_launch_rounded),
607-
color: widget.isBoosted
608-
? Colors.purple.shade400
609-
: null,
610-
onPressed: widget.onBoost,
611-
),
612-
Text(intFormat(widget.boosts!))
613-
],
619+
Text(intFormat(widget.boosts!))
620+
],
621+
),
614622
),
615-
),
616-
if (widget.upVotes != null ||
617-
widget.downVotes != null)
618-
Row(
619-
children: [
620-
if (widget.upVotes != null)
621-
IconButton(
622-
icon: const Icon(
623-
Symbols.arrow_upward_rounded),
624-
color: widget.isUpVoted
625-
? Colors.green.shade400
626-
: null,
627-
onPressed: widget.onUpVote,
628-
),
629-
Text(intFormat((widget.upVotes ?? 0) -
630-
(widget.downVotes ?? 0))),
631-
if (widget.downVotes != null)
632-
IconButton(
633-
icon: const Icon(
634-
Symbols.arrow_downward_rounded),
635-
color: widget.isDownVoted
636-
? Colors.red.shade400
637-
: null,
638-
onPressed: widget.onDownVote,
639-
),
640-
],
641-
),
642-
];
643-
final commentWidgets = [
644-
if (widget.numComments != null)
645-
Padding(
646-
padding: const EdgeInsets.only(right: 8),
647-
child: Row(
623+
if (widget.upVotes != null ||
624+
widget.downVotes != null)
625+
Row(
648626
children: [
649-
Icon(Symbols.comment_rounded),
650-
const SizedBox(width: 4),
651-
Text(intFormat(widget.numComments!))
627+
if (widget.upVotes != null)
628+
IconButton(
629+
icon: const Icon(
630+
Symbols.arrow_upward_rounded),
631+
color: widget.isUpVoted
632+
? Colors.green.shade400
633+
: null,
634+
onPressed: widget.onUpVote,
635+
),
636+
Text(intFormat((widget.upVotes ?? 0) -
637+
(widget.downVotes ?? 0))),
638+
if (widget.downVotes != null)
639+
IconButton(
640+
icon: const Icon(
641+
Symbols.arrow_downward_rounded),
642+
color: widget.isDownVoted
643+
? Colors.red.shade400
644+
: null,
645+
onPressed: widget.onDownVote,
646+
),
652647
],
653648
),
654-
),
655-
if (widget.onReply != null)
656-
IconButton(
657-
icon: const Icon(Symbols.reply_rounded),
658-
onPressed: () => setState(() {
659-
_replyTextController =
660-
TextEditingController();
661-
}),
662-
),
663-
];
649+
];
650+
final commentWidgets = [
651+
if (widget.numComments != null)
652+
Padding(
653+
padding: const EdgeInsets.only(right: 8),
654+
child: Row(
655+
children: [
656+
Icon(Symbols.comment_rounded),
657+
const SizedBox(width: 4),
658+
Text(intFormat(widget.numComments!))
659+
],
660+
),
661+
),
662+
if (widget.onReply != null)
663+
IconButton(
664+
icon: const Icon(Symbols.reply_rounded),
665+
onPressed: () => setState(() {
666+
_replyTextController =
667+
TextEditingController();
668+
}),
669+
),
670+
];
664671

665-
return constrains.maxWidth < 300
666-
? Column(
667-
children: [
668-
Row(
669-
mainAxisAlignment:
670-
MainAxisAlignment.center,
671-
children: votingWidgets,
672-
),
673-
const SizedBox(height: 4),
674-
Row(
675-
children: <Widget>[
672+
return constrains.maxWidth < 300
673+
? Column(
674+
children: [
675+
if (!context
676+
.read<AppController>()
677+
.profile
678+
.hideVoteButtons)
679+
Row(
680+
mainAxisAlignment:
681+
MainAxisAlignment.center,
682+
children: votingWidgets,
683+
),
684+
const SizedBox(height: 4),
685+
if (!context
686+
.read<AppController>()
687+
.profile
688+
.hideCommentButtons)
689+
Row(
690+
children: <Widget>[
691+
...commentWidgets,
692+
const Spacer(),
693+
],
694+
),
695+
],
696+
)
697+
: Row(
698+
children: <Widget>[
699+
if (!context
700+
.read<AppController>()
701+
.profile
702+
.hideCommentButtons)
676703
...commentWidgets,
677-
const Spacer(),
678-
],
679-
),
680-
],
681-
)
682-
: Row(
683-
children: <Widget>[
684-
...commentWidgets,
685-
const Spacer(),
686-
...votingWidgets,
687-
],
688-
);
689-
}),
690-
),
704+
const Spacer(),
705+
if (!context
706+
.read<AppController>()
707+
.profile
708+
.hideVoteButtons)
709+
...votingWidgets,
710+
],
711+
);
712+
}),
713+
),
691714
if (!widget.isPreview &&
692715
widget.notificationControlStatus != null &&
693716
widget.onNotificationControlStatusChange !=

0 commit comments

Comments
 (0)