Skip to content

Commit

Permalink
Removing unit defaults. Fixes #67
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed Feb 3, 2022
1 parent 6a48063 commit 8ed65f5
Show file tree
Hide file tree
Showing 23 changed files with 361 additions and 178 deletions.
76 changes: 51 additions & 25 deletions app/src/main/java/com/jerboa/ui/components/comment/CommentNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import com.jerboa.ui.theme.XXL_PADDING
@Composable
fun CommentNodeHeader(
commentView: CommentView,
onPersonClick: (personId: Int) -> Unit = {},
onPersonClick: (personId: Int) -> Unit,
score: Int,
myVote: Int?,
isModerator: Boolean,
Expand Down Expand Up @@ -65,6 +65,7 @@ fun CommentNodeHeaderPreview() {
score = 23,
myVote = 26,
isModerator = false,
onPersonClick = {},
)
}

Expand Down Expand Up @@ -102,15 +103,15 @@ fun CommentBodyPreview() {
fun CommentNode(
node: CommentNodeData,
moderators: List<CommunityModeratorView>,
onUpvoteClick: (commentView: CommentView) -> Unit = {},
onDownvoteClick: (commentView: CommentView) -> Unit = {},
onReplyClick: (commentView: CommentView) -> Unit = {},
onSaveClick: (commentView: CommentView) -> Unit = {},
onUpvoteClick: (commentView: CommentView) -> Unit,
onDownvoteClick: (commentView: CommentView) -> Unit,
onReplyClick: (commentView: CommentView) -> Unit,
onSaveClick: (commentView: CommentView) -> Unit,
onMarkAsReadClick: (commentView: CommentView) -> Unit = {},
onEditCommentClick: (commentView: CommentView) -> Unit = {},
onPersonClick: (personId: Int) -> Unit = {},
onCommunityClick: (community: CommunitySafe) -> Unit = {},
onPostClick: (postId: Int) -> Unit = {},
onEditCommentClick: (commentView: CommentView) -> Unit,
onPersonClick: (personId: Int) -> Unit,
onCommunityClick: (community: CommunitySafe) -> Unit,
onPostClick: (postId: Int) -> Unit,
onReportClick: (commentView: CommentView) -> Unit,
showPostAndCommunityContext: Boolean = false,
showRead: Boolean = false,
Expand Down Expand Up @@ -223,6 +224,7 @@ fun CommentNode(
onCommunityClick = onCommunityClick,
onPostClick = onPostClick,
showPostAndCommunityContext = showPostAndCommunityContext,
onReportClick = onReportClick,
showRead = showRead,
onReplyClick = onReplyClick,
account = account,
Expand All @@ -235,8 +237,8 @@ fun CommentNode(
@Composable
fun PostAndCommunityContextHeader(
commentView: CommentView,
onCommunityClick: (community: CommunitySafe) -> Unit = {},
onPostClick: (postId: Int) -> Unit = {},
onCommunityClick: (community: CommunitySafe) -> Unit,
onPostClick: (postId: Int) -> Unit,
) {
Column(
modifier = Modifier.padding(top = LARGE_PADDING)
Expand All @@ -261,19 +263,23 @@ fun PostAndCommunityContextHeader(
@Preview
@Composable
fun PostAndCommunityContextHeaderPreview() {
PostAndCommunityContextHeader(commentView = sampleCommentView)
PostAndCommunityContextHeader(
commentView = sampleCommentView,
onCommunityClick = {},
onPostClick = {},
)
}

@Composable
fun CommentFooterLine(
commentView: CommentView,
onUpvoteClick: (commentView: CommentView) -> Unit = {},
onDownvoteClick: (commentView: CommentView) -> Unit = {},
onReplyClick: (commentView: CommentView) -> Unit = {},
onSaveClick: (commentView: CommentView) -> Unit = {},
onMarkAsReadClick: (commentView: CommentView) -> Unit = {},
onViewSourceClick: () -> Unit = {},
onEditCommentClick: (commentView: CommentView) -> Unit = {},
onUpvoteClick: (commentView: CommentView) -> Unit,
onDownvoteClick: (commentView: CommentView) -> Unit,
onReplyClick: (commentView: CommentView) -> Unit,
onSaveClick: (commentView: CommentView) -> Unit,
onMarkAsReadClick: (commentView: CommentView) -> Unit,
onViewSourceClick: () -> Unit,
onEditCommentClick: (commentView: CommentView) -> Unit,
onReportClick: (commentView: CommentView) -> Unit,
showRead: Boolean = false,
myVote: Int?,
Expand Down Expand Up @@ -376,15 +382,28 @@ fun CommentNodesPreview() {
sampleSecondCommentReplyView, sampleCommentReplyView, sampleCommentView
)
val tree = buildCommentsTree(comments)
CommentNodes(nodes = tree, moderators = listOf())
CommentNodes(
nodes = tree,
moderators = listOf(),
onCommunityClick = {},
onDownvoteClick = {},
onEditCommentClick = {},
onMarkAsReadClick = {},
onPersonClick = {},
onPostClick = {},
onReportClick = {},
onReplyClick = {},
onSaveClick = {},
onUpvoteClick = {},
)
}

@Composable
fun CommentOptionsDialog(
onDismissRequest: () -> Unit = {},
onViewSourceClick: () -> Unit = {},
onEditCommentClick: () -> Unit = {},
onReportClick: () -> Unit = {},
onDismissRequest: () -> Unit,
onViewSourceClick: () -> Unit,
onEditCommentClick: () -> Unit,
onReportClick: () -> Unit,
isCreator: Boolean,
commentView: CommentView,
) {
Expand Down Expand Up @@ -433,7 +452,14 @@ fun CommentOptionsDialog(
@Preview
@Composable
fun CommentOptionsDialogPreview() {
CommentOptionsDialog(isCreator = true, commentView = sampleCommentView)
CommentOptionsDialog(
isCreator = true,
commentView = sampleCommentView,
onDismissRequest = {},
onEditCommentClick = {},
onReportClick = {},
onViewSourceClick = {}
)
}

@Composable
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/java/com/jerboa/ui/components/comment/CommentNodes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import com.jerboa.sortNodes
@Composable
fun CommentNodes(
nodes: List<CommentNodeData>,
onUpvoteClick: (commentView: CommentView) -> Unit = {},
onDownvoteClick: (commentView: CommentView) -> Unit = {},
onReplyClick: (commentView: CommentView) -> Unit = {},
onSaveClick: (commentView: CommentView) -> Unit = {},
onMarkAsReadClick: (commentView: CommentView) -> Unit = {},
onEditCommentClick: (commentView: CommentView) -> Unit = {},
onReportClick: (commentView: CommentView) -> Unit = {},
onPersonClick: (personId: Int) -> Unit = {},
onCommunityClick: (community: CommunitySafe) -> Unit = {},
onPostClick: (postId: Int) -> Unit = {},
onUpvoteClick: (commentView: CommentView) -> Unit,
onDownvoteClick: (commentView: CommentView) -> Unit,
onReplyClick: (commentView: CommentView) -> Unit,
onSaveClick: (commentView: CommentView) -> Unit,
onMarkAsReadClick: (commentView: CommentView) -> Unit,
onEditCommentClick: (commentView: CommentView) -> Unit,
onReportClick: (commentView: CommentView) -> Unit,
onPersonClick: (personId: Int) -> Unit,
onCommunityClick: (community: CommunitySafe) -> Unit,
onPostClick: (postId: Int) -> Unit,
account: Account? = null,
moderators: List<CommunityModeratorView>,
showPostAndCommunityContext: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.jerboa.ui.theme.MEDIUM_PADDING
@Composable
fun CommentEditHeader(
navController: NavController = rememberNavController(),
onSaveClick: () -> Unit = {},
onSaveClick: () -> Unit,
loading: Boolean,
) {
TopAppBar(
Expand Down Expand Up @@ -66,7 +66,7 @@ fun CommentEditHeader(
fun CommentEdit(
content: String,
onContentChange: (String) -> Unit,
onPickedImage: (image: Uri) -> Unit = {},
onPickedImage: (image: Uri) -> Unit,
) {
LazyColumn {
item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.jerboa.ui.theme.MEDIUM_PADDING
@Composable
fun CommentReplyHeader(
navController: NavController = rememberNavController(),
onSendClick: () -> Unit = {},
onSendClick: () -> Unit,
loading: Boolean,
) {
TopAppBar(
Expand Down Expand Up @@ -71,7 +71,7 @@ fun CommentReplyHeader(
@Composable
fun RepliedComment(
commentView: CommentView,
onPersonClick: (personId: Int) -> Unit = {},
onPersonClick: (personId: Int) -> Unit,
isModerator: Boolean,
) {
Column(modifier = Modifier.padding(MEDIUM_PADDING)) {
Expand All @@ -91,13 +91,17 @@ fun RepliedComment(
@Preview
@Composable
fun RepliedCommentPreview() {
RepliedComment(commentView = sampleCommentView, isModerator = false)
RepliedComment(
commentView = sampleCommentView,
isModerator = false,
onPersonClick = {},
)
}

@Composable
fun RepliedPost(
postView: PostView,
onPersonClick: (personId: Int) -> Unit = {},
onPersonClick: (personId: Int) -> Unit,
isModerator: Boolean,
) {
Column(modifier = Modifier.padding(MEDIUM_PADDING)) {
Expand All @@ -118,8 +122,8 @@ fun CommentReply(
commentView: CommentView,
reply: String,
onReplyChange: (String) -> Unit,
onPersonClick: (personId: Int) -> Unit = {},
onPickedImage: (image: Uri) -> Unit = {},
onPersonClick: (personId: Int) -> Unit,
onPickedImage: (image: Uri) -> Unit,
isModerator: Boolean,
) {
LazyColumn {
Expand Down Expand Up @@ -150,8 +154,8 @@ fun PostReply(
postView: PostView,
reply: String,
onReplyChange: (String) -> Unit,
onPersonClick: (personId: Int) -> Unit = {},
onPickedImage: (image: Uri) -> Unit = {},
onPersonClick: (personId: Int) -> Unit,
onPickedImage: (image: Uri) -> Unit,
isModerator: Boolean,
) {
LazyColumn {
Expand Down
13 changes: 8 additions & 5 deletions app/src/main/java/com/jerboa/ui/components/common/AppBars.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ fun SimpleTopAppBar(
fun BottomAppBarAll(
navController: NavController = rememberNavController(),
unreadCounts: GetUnreadCountResponse? = null,
onClickProfile: () -> Unit = {},
onClickInbox: () -> Unit = {},
onClickProfile: () -> Unit,
onClickInbox: () -> Unit,
) {
var selectedState by remember { mutableStateOf("home") }
val totalUnreads = unreadCounts?.let { unreadCountTotal(it) }
Expand Down Expand Up @@ -136,7 +136,10 @@ fun BottomAppBarAll(
@Preview
@Composable
fun BottomAppBarAllPreview() {
BottomAppBarAll()
BottomAppBarAll(
onClickInbox = {},
onClickProfile = {},
)
}

@OptIn(ExperimentalFoundationApi::class)
Expand All @@ -147,7 +150,7 @@ fun CommentOrPostNodeHeader(
myVote: Int?,
published: String,
updated: String?,
onPersonClick: (personId: Int) -> Unit = {},
onPersonClick: (personId: Int) -> Unit,
isPostCreator: Boolean,
isModerator: Boolean,
isCommunityBanned: Boolean,
Expand Down Expand Up @@ -190,7 +193,7 @@ fun CommentOrPostNodeHeader(

@Composable
fun ActionBarButton(
onClick: () -> Unit = {},
onClick: () -> Unit,
icon: ImageVector,
text: String? = null,
contentColor: Color = Muted,
Expand Down
31 changes: 20 additions & 11 deletions app/src/main/java/com/jerboa/ui/components/common/Dialogs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ val topSortTypes = listOf(

@Composable
fun SortTopOptionsDialog(
onDismissRequest: () -> Unit = {},
onClickSortType: (SortType) -> Unit = {},
onDismissRequest: () -> Unit,
onClickSortType: (SortType) -> Unit,
selectedSortType: SortType,
) {

Expand Down Expand Up @@ -64,13 +64,18 @@ fun SortTopOptionsDialog(
@Preview
@Composable
fun SortOptionsDialogPreview() {
SortOptionsDialog(selectedSortType = SortType.Hot)
SortOptionsDialog(
selectedSortType = SortType.Hot,
onDismissRequest = {},
onClickSortTopOptions = {},
onClickSortType = {},
)
}

@Composable
fun ListingTypeOptionsDialog(
onDismissRequest: () -> Unit = {},
onClickListingType: (ListingType) -> Unit = {},
onDismissRequest: () -> Unit,
onClickListingType: (ListingType) -> Unit,
selectedListingType: ListingType,
) {
AlertDialog(
Expand Down Expand Up @@ -104,9 +109,9 @@ fun ListingTypeOptionsDialog(

@Composable
fun SortOptionsDialog(
onDismissRequest: () -> Unit = {},
onClickSortType: (SortType) -> Unit = {},
onClickSortTopOptions: () -> Unit = {},
onDismissRequest: () -> Unit,
onClickSortType: (SortType) -> Unit,
onClickSortTopOptions: () -> Unit,
selectedSortType: SortType,
) {
AlertDialog(
Expand Down Expand Up @@ -146,8 +151,8 @@ fun SortOptionsDialog(

@Composable
fun UnreadOrAllOptionsDialog(
onDismissRequest: () -> Unit = {},
onClickUnreadOrAll: (UnreadOrAll) -> Unit = {},
onDismissRequest: () -> Unit,
onClickUnreadOrAll: (UnreadOrAll) -> Unit,
selectedUnreadOrAll: UnreadOrAll,
) {
AlertDialog(
Expand Down Expand Up @@ -176,5 +181,9 @@ fun UnreadOrAllOptionsDialog(
@Preview
@Composable
fun ListingTypeOptionsDialogPreview() {
ListingTypeOptionsDialog(selectedListingType = ListingType.Local)
ListingTypeOptionsDialog(
selectedListingType = ListingType.Local,
onClickListingType = {},
onDismissRequest = {},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fun PictrsBannerImage(
@Composable
fun PickImage(
modifier: Modifier = Modifier,
onPickedImage: (image: Uri) -> Unit = {},
onPickedImage: (image: Uri) -> Unit,
showImage: Boolean = true,
) {
val ctx = LocalContext.current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fun <T> VoteGeneric(
votes: Int,
item: T,
type: VoteType,
onVoteClick: (item: T) -> Unit = {},
onVoteClick: (item: T) -> Unit,
showNumber: Boolean = true,
account: Account?,
) {
Expand Down
Loading

0 comments on commit 8ed65f5

Please sign in to comment.