Skip to content

Commit

Permalink
Fix detekt issues in ZapBottomSheet
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarIlic committed Mar 11, 2024
1 parent 1c3f952 commit 0446a0c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 52 deletions.
10 changes: 3 additions & 7 deletions app/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<ID>CyclomaticComplexMethod:CreateTransactionScreen.kt$@ExperimentalComposeUiApi @ExperimentalMaterial3Api @Composable fun CreateTransactionScreen( state: CreateTransactionContract.UiState, eventPublisher: (CreateTransactionContract.UiEvent) -&gt; Unit, onClose: () -&gt; Unit, )</ID>
<ID>CyclomaticComplexMethod:FeedLazyColumn.kt$@ExperimentalMaterial3Api @ExperimentalFoundationApi @Composable fun FeedLazyColumn( pagingItems: LazyPagingItems&lt;FeedPostUi&gt;, contentPadding: PaddingValues, listState: LazyListState, zappingState: ZappingState, onPostClick: (String) -&gt; Unit, onProfileClick: (String) -&gt; Unit, onPostLikeClick: (FeedPostUi) -&gt; Unit, onRepostClick: (FeedPostUi) -&gt; Unit, onZapClick: (FeedPostUi, ULong?, String?) -&gt; Unit, onPostReplyClick: (String) -&gt; Unit, onPostQuoteClick: (FeedPostUi) -&gt; Unit, onHashtagClick: (String) -&gt; Unit, onMediaClick: (String, String) -&gt; Unit, onGoToWallet: () -&gt; Unit, onMuteClick: ((String) -&gt; Unit)? = null, shouldShowLoadingState: Boolean = true, shouldShowNoContentState: Boolean = true, showReplyTo: Boolean = true, header: @Composable (LazyItemScope.() -&gt; Unit)? = null, stickyHeader: @Composable (LazyItemScope.() -&gt; Unit)? = null, )</ID>
<ID>CyclomaticComplexMethod:FeedRemoteMediator.kt$FeedRemoteMediator$override suspend fun load(loadType: LoadType, state: PagingState&lt;Int, FeedPost&gt;): MediatorResult</ID>
<ID>CyclomaticComplexMethod:LoginScreen.kt$@OptIn(ExperimentalComposeUiApi::class) @Composable fun LoginContent( state: LoginContract.UiState, paddingValues: PaddingValues, onLogin: (String) -&gt; Unit, )</ID>
<ID>CyclomaticComplexMethod:MessagesRemoteMediator.kt$MessagesRemoteMediator$override suspend fun load(loadType: LoadType, state: PagingState&lt;Int, DirectMessage&gt;): MediatorResult</ID>
<ID>CyclomaticComplexMethod:NoteEditorScreen.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun NoteEditorScreen( state: NoteEditorContract.UiState, onClose: () -&gt; Unit, eventPublisher: (UiEvent) -&gt; Unit, )</ID>
<ID>CyclomaticComplexMethod:NotificationEvents.kt$private fun ContentPrimalNotification.parseActionPostId(type: NotificationType): String?</ID>
Expand Down Expand Up @@ -41,7 +40,6 @@
<ID>LongMethod:FeedScreen.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun FeedScreen( state: FeedContract.UiState, eventPublisher: (FeedContract.UiEvent) -&gt; Unit, onFeedsClick: () -&gt; Unit, onNewPostClick: (String?) -&gt; Unit, onPostClick: (String) -&gt; Unit, onPostReplyClick: (String) -&gt; Unit, onProfileClick: (String) -&gt; Unit, onHashtagClick: (String) -&gt; Unit, onMediaClick: (String, String) -&gt; Unit, onGoToWallet: () -&gt; Unit, onPrimaryDestinationChanged: (PrimalTopLevelDestination) -&gt; Unit, onDrawerDestinationClick: (DrawerScreenDestination) -&gt; Unit, )</ID>
<ID>LongMethod:FeedsSettingsScreen.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun FeedsSettingsScreen( state: FeedsSettingsContract.UiState, eventPublisher: (FeedsSettingsContract.UiEvent) -&gt; Unit, onClose: () -&gt; Unit, )</ID>
<ID>LongMethod:FollowRecommendedAccountsStep.kt$@OptIn(ExperimentalFoundationApi::class) @Composable fun FollowRecommendedAccountsStep( state: CreateAccountContract.UiState, eventPublisher: (CreateAccountContract.UiEvent) -&gt; Unit, )</ID>
<ID>LongMethod:LoginScreen.kt$@OptIn(ExperimentalComposeUiApi::class) @Composable fun LoginContent( state: LoginContract.UiState, paddingValues: PaddingValues, onLogin: (String) -&gt; Unit, )</ID>
<ID>LongMethod:MessageConversationListScreen.kt$@Composable private fun MessagesTabs( relation: ConversationRelation, onFollowsTabClick: () -&gt; Unit, onOtherTabClick: () -&gt; Unit, onMarkAllRead: () -&gt; Unit, )</ID>
<ID>LongMethod:NoteDropdownMenu.kt$@Composable fun NoteDropdownMenuIcon( modifier: Modifier, noteId: String, noteContent: String, noteRawData: String, authorId: String, onMuteUserClick: () -&gt; Unit, )</ID>
<ID>LongMethod:NoteEditorScreen.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun NoteEditorScreen( state: NoteEditorContract.UiState, onClose: () -&gt; Unit, eventPublisher: (UiEvent) -&gt; Unit, )</ID>
Expand All @@ -64,12 +62,12 @@
<ID>LongMethod:ThreadScreen.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun ThreadScreen( state: ThreadContract.UiState, onClose: () -&gt; Unit, onPostClick: (String) -&gt; Unit, onPostReplyClick: (String) -&gt; Unit, onPostQuoteClick: (String) -&gt; Unit, onProfileClick: (String) -&gt; Unit, onHashtagClick: (String) -&gt; Unit, onMediaClick: (String, String) -&gt; Unit, onGoToWallet: () -&gt; Unit, onReplyInNoteEditor: (String, Uri?, String) -&gt; Unit, eventPublisher: (ThreadContract.UiEvent) -&gt; Unit, )</ID>
<ID>LongMethod:TransactionEditor.kt$@Composable private fun TransactionHeaderColumn( modifier: Modifier, uiMode: UiDensityMode, state: CreateTransactionContract.UiState, keyboardVisible: Boolean, onAmountClick: () -&gt; Unit, )</ID>
<ID>LongMethod:TransactionEditor.kt$@ExperimentalMaterial3Api @ExperimentalComposeUiApi @Composable fun TransactionEditor( modifier: Modifier, state: CreateTransactionContract.UiState, paddingValues: PaddingValues, eventPublisher: (CreateTransactionContract.UiEvent) -&gt; Unit, onCancelClick: () -&gt; Unit, )</ID>
<ID>LongMethod:WalletActivationScreen.kt$@ExperimentalComposeUiApi @Composable private fun WalletCodeActivationInput( working: Boolean, error: Throwable?, email: String, onCodeChanged: () -&gt; Unit, onCodeConfirmation: (String) -&gt; Unit, isKeyboardVisible: Boolean, )</ID>
<ID>LongMethod:WalletActivationScreen.kt$@Suppress("MagicNumber") @OptIn(ExperimentalMaterial3Api::class) @ExperimentalComposeUiApi @Composable private fun WalletActivationDataInput( data: WalletActivationData, working: Boolean, error: Throwable?, onErrorDismiss: () -&gt; Unit, onDataChanged: (WalletActivationData) -&gt; Unit, onActivationCodeRequest: (WalletActivationData) -&gt; Unit, )</ID>
<ID>LongMethod:WalletActivationScreen.kt$@ExperimentalComposeUiApi @Composable private fun WalletCodeActivationInput( modifier: Modifier = Modifier, working: Boolean, error: Throwable?, email: String, onCodeChanged: () -&gt; Unit, onCodeConfirmation: (String) -&gt; Unit, isKeyboardVisible: Boolean, )</ID>
<ID>LongMethod:WalletActivationScreen.kt$@ExperimentalMaterial3Api @ExperimentalComposeUiApi @Composable fun WalletActivationScreen( uiState: WalletActivationContract.UiState, eventPublisher: (UiEvent) -&gt; Unit, onClose: () -&gt; Unit, )</ID>
<ID>LongMethod:WalletActivationScreen.kt$@Suppress("MagicNumber") @OptIn(ExperimentalMaterial3Api::class) @ExperimentalComposeUiApi @Composable private fun WalletActivationDataInput( modifier: Modifier = Modifier, data: WalletActivationData, working: Boolean, error: Throwable?, onErrorDismiss: () -&gt; Unit, onDataChanged: (WalletActivationData) -&gt; Unit, onActivationCodeRequest: (WalletActivationData) -&gt; Unit, )</ID>
<ID>LongMethod:WalletDashboardScreen.kt$@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) @Composable fun WalletDashboardScreen( state: WalletDashboardContract.UiState, onPrimaryDestinationChanged: (PrimalTopLevelDestination) -&gt; Unit, onDrawerDestinationClick: (DrawerScreenDestination) -&gt; Unit, onWalletActivateClick: () -&gt; Unit, onProfileClick: (String) -&gt; Unit, onTransactionClick: (String) -&gt; Unit, onSendClick: () -&gt; Unit, onScanClick: () -&gt; Unit, onReceiveClick: () -&gt; Unit, eventPublisher: (UiEvent) -&gt; Unit, )</ID>
<ID>LongMethod:WalletSettingsScreen.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun WalletSettingsScreen( state: WalletSettingsContract.UiState, onClose: () -&gt; Unit, onEditProfileClick: () -&gt; Unit, eventPublisher: (UiEvent) -&gt; Unit, )</ID>
<ID>LongMethod:WelcomeScreen.kt$@Composable fun WelcomeScreen(onSignInClick: () -&gt; Unit, onCreateAccountClick: () -&gt; Unit)</ID>
<ID>LongMethod:ZapBottomSheet.kt$@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class) @Composable fun ZapBottomSheet( receiverName: String, zappingState: ZappingState, onDismissRequest: () -&gt; Unit, onZap: (Long, String?) -&gt; Unit, )</ID>
<ID>LongMethod:ZapSettingsScreen.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun ZapSettingsScreen( uiState: ZapSettingsContract.UiState, onClose: () -&gt; Unit, eventPublisher: (ZapSettingsContract.UiEvent) -&gt; Unit, )</ID>
<ID>LongParameterList:CreateAccountViewModel.kt$CreateAccountViewModel$( private val dispatcherProvider: CoroutineDispatcherProvider, private val authRepository: AuthRepository, private val settingsRepository: SettingsRepository, private val profileRepository: ProfileRepository, private val userRepository: UserRepository, private val recommendedFollowsApi: RecommendedFollowsApi, private val relayRepository: RelayRepository, )</ID>
<ID>LongParameterList:ExploreFeedViewModel.kt$ExploreFeedViewModel$( savedStateHandle: SavedStateHandle, private val dispatcherProvider: CoroutineDispatcherProvider, private val activeAccountStore: ActiveAccountStore, private val feedRepository: FeedRepository, private val postRepository: PostRepository, private val profileRepository: ProfileRepository, private val zapHandler: ZapHandler, private val settingsRepository: SettingsRepository, private val mutedUserRepository: MutedUserRepository, )</ID>
Expand Down Expand Up @@ -100,7 +98,6 @@
<ID>MagicNumber:FeedNoteList.kt$30</ID>
<ID>MagicNumber:FeedNoteList.kt$5</ID>
<ID>MagicNumber:FeedViewModel.kt$FeedViewModel$3</ID>
<ID>MagicNumber:Insets.kt$0.5f</ID>
<ID>MagicNumber:IntUtils.kt$10</ID>
<ID>MagicNumber:IntUtils.kt$1000</ID>
<ID>MagicNumber:IntUtils.kt$1000.0</ID>
Expand Down Expand Up @@ -131,7 +128,6 @@
<ID>MagicNumber:Timestamps.kt$7</ID>
<ID>MagicNumber:ValidationUtils.kt$32</ID>
<ID>MagicNumber:WalletDashboardScreen.kt$0.42f</ID>
<ID>MagicNumber:ZapBottomSheet.kt$3</ID>
<ID>MatchingDeclarationName:__PrimalIcons.kt$PrimalIcons</ID>
<ID>NestedBlockDepth:FeedRemoteMediator.kt$FeedRemoteMediator$override suspend fun load(loadType: LoadType, state: PagingState&lt;Int, FeedPost&gt;): MediatorResult</ID>
<ID>ReturnCount:FeedRemoteMediator.kt$FeedRemoteMediator$override suspend fun load(loadType: LoadType, state: PagingState&lt;Int, FeedPost&gt;): MediatorResult</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,7 @@ fun ZapBottomSheet(
}?.message ?: selectedZapComment
},
)
OutlinedTextField(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp),
singleLine = true,
colors = PrimalDefaults.outlinedTextFieldColors(
unfocusedBorderColor = Color.Transparent,
focusedBorderColor = Color.Transparent,
),
shape = RoundedCornerShape(8.dp),
ZapCustomAmountOutlinedTextField(
value = customZapAmount,
onValueChange = {
when {
Expand All @@ -125,44 +116,11 @@ fun ZapBottomSheet(
}
selectedZapAmount = customZapAmount.toLongOrNull() ?: zapConfig.first().amount
},
textStyle = AppTheme.typography.bodyMedium,
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Number,
imeAction = ImeAction.Done,
),
placeholder = {
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(id = R.string.zap_bottom_sheet_custom_amount_placeholder),
textAlign = TextAlign.Left,
style = AppTheme.typography.bodyMedium,
color = AppTheme.extraColorScheme.onSurfaceVariantAlt4,
)
},
)
Spacer(modifier = Modifier.height(16.dp))
OutlinedTextField(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp),
singleLine = true,
colors = PrimalDefaults.outlinedTextFieldColors(
unfocusedBorderColor = Color.Transparent,
focusedBorderColor = Color.Transparent,
),
shape = RoundedCornerShape(8.dp),
ZapCommentOutlinedTextField(
value = selectedZapComment,
onValueChange = { selectedZapComment = it },
textStyle = AppTheme.typography.bodyMedium,
placeholder = {
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(id = R.string.zap_bottom_sheet_comment_placeholder),
textAlign = TextAlign.Left,
style = AppTheme.typography.bodyMedium,
color = AppTheme.extraColorScheme.onSurfaceVariantAlt4,
)
},
)
Spacer(modifier = Modifier.height(16.dp))
if (!keyboardVisible) {
Expand All @@ -183,14 +141,74 @@ fun ZapBottomSheet(
}
}

@Composable
private fun ZapCommentOutlinedTextField(value: String, onValueChange: (String) -> Unit) {
OutlinedTextField(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp),
singleLine = true,
colors = PrimalDefaults.outlinedTextFieldColors(
unfocusedBorderColor = Color.Transparent,
focusedBorderColor = Color.Transparent,
),
shape = RoundedCornerShape(8.dp),
value = value,
onValueChange = onValueChange,
textStyle = AppTheme.typography.bodyMedium,
placeholder = {
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(id = R.string.zap_bottom_sheet_comment_placeholder),
textAlign = TextAlign.Left,
style = AppTheme.typography.bodyMedium,
color = AppTheme.extraColorScheme.onSurfaceVariantAlt4,
)
},
)
}

@Composable
private fun ZapCustomAmountOutlinedTextField(value: String, onValueChange: (String) -> Unit) {
OutlinedTextField(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp),
singleLine = true,
colors = PrimalDefaults.outlinedTextFieldColors(
unfocusedBorderColor = Color.Transparent,
focusedBorderColor = Color.Transparent,
),
shape = RoundedCornerShape(8.dp),
value = value,
onValueChange = onValueChange,
textStyle = AppTheme.typography.bodyMedium,
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Number,
imeAction = ImeAction.Done,
),
placeholder = {
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(id = R.string.zap_bottom_sheet_custom_amount_placeholder),
textAlign = TextAlign.Left,
style = AppTheme.typography.bodyMedium,
color = AppTheme.extraColorScheme.onSurfaceVariantAlt4,
)
},
)
}

private const val ZAP_OPTIONS_COLUMNS_COUNT = 3

@Composable
private fun ZapOptions(
zapConfig: List<ContentZapConfigItem>,
selectedZapAmount: Long,
onSelectedZapAmountChange: (Long) -> Unit,
) {
LazyVerticalGrid(
columns = GridCells.Fixed(3),
columns = GridCells.Fixed(ZAP_OPTIONS_COLUMNS_COUNT),
contentPadding = PaddingValues(12.dp),
) {
items(zapConfig) {
Expand Down

0 comments on commit 0446a0c

Please sign in to comment.