|
1 | | -import 'package:flex_color_scheme/flex_color_scheme.dart'; |
2 | 1 | import 'package:flutter/material.dart'; |
3 | 2 | import 'package:interstellar/src/controller/controller.dart'; |
4 | 3 | import 'package:interstellar/src/controller/server.dart'; |
@@ -575,119 +574,143 @@ class _ContentItemState extends State<ContentItem> { |
575 | 574 | .profile |
576 | 575 | .compactMode)) |
577 | 576 | 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 | + ), |
590 | 605 | ), |
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, |
597 | 618 | ), |
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 | + ), |
614 | 622 | ), |
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( |
648 | 626 | 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 | + ), |
652 | 647 | ], |
653 | 648 | ), |
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 | + ]; |
664 | 671 |
|
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) |
676 | 703 | ...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 | + ), |
691 | 714 | if (!widget.isPreview && |
692 | 715 | widget.notificationControlStatus != null && |
693 | 716 | widget.onNotificationControlStatusChange != |
|
0 commit comments