From c5114f759c16ff01d94b8d6347305d15fbf47e11 Mon Sep 17 00:00:00 2001 From: Sin-Kang Date: Sun, 15 Nov 2026 01:07:55 +0900 Subject: [PATCH] feat(android): customize DDS sign-in controls and sheet --- README.ko.md | 2 +- README.md | 2 +- android/CHANGELOG.ko.md | 4 + android/CHANGELOG.md | 4 + android/README.ko.md | 6 +- android/README.md | 6 +- .../devslab/dds/compose/ScreenReaderTest.kt | 52 ++++++++ .../kr/devslab/dds/compose/component/Auth.kt | 112 +++++++++++++++--- android/gradle.properties | 2 +- 9 files changed, 168 insertions(+), 22 deletions(-) diff --git a/README.ko.md b/README.ko.md index 6308fa2..a19ca87 100644 --- a/README.ko.md +++ b/README.ko.md @@ -120,7 +120,7 @@ Source-Available License 1.0을 따른다. compatibility canary는 비공개· 때만 만든다 (명세 §8): `@devslab/dds-tokens` (✅ 2026-08-13) → `dds-css` v1 인벤토리 (Core 6종 ✅ 2026-08-13, +13종 ✅ 2026-08-15) → AskLinq 적용 → `dds-icons` (✅ 2026-08-15) → `dds-solid` + `site-kit` → 안드로이드 네이티브 값·테마·모션 -(0.6.0, 2026-11-12, Maven Central — 테마·모션·부품·아이콘). 0.7.0(2026-11-13, Maven Central)에서 화면 틀과 `dds-compose-testing` 꾸러미가 생겼다(D-052). 0.8.0(2026-11-13)에서 `DdsSegmentedControl`이 생겼고, 0.8.1에서 어두운 화면의 고른 칸이 밝아졌고(`bg.raised`, D-054), 0.9.0에서 고른 면이 미끄러져 옮겨 가고(D-055), 0.9.1에서 앱이 그 속도를, 0.9.2에서 `DdsTheme`에 자기 글꼴을 넘길 수 있다. 0.10.0에서 `DdsSocialSignIn`과 로그인 제공자 로고가 추가됐다. RN·Ionic 패키지는 그 제품이 생길 때. +(0.6.0, 2026-11-12, Maven Central — 테마·모션·부품·아이콘). 0.7.0(2026-11-13, Maven Central)에서 화면 틀과 `dds-compose-testing` 꾸러미가 생겼다(D-052). 0.8.0(2026-11-13)에서 `DdsSegmentedControl`이 생겼고, 0.8.1에서 어두운 화면의 고른 칸이 밝아졌고(`bg.raised`, D-054), 0.9.0에서 고른 면이 미끄러져 옮겨 가고(D-055), 0.9.1에서 앱이 그 속도를, 0.9.2에서 `DdsTheme`에 자기 글꼴을 넘길 수 있다. 0.10.0에서 `DdsSocialSignIn`과 로그인 제공자 로고가 추가됐고, 0.10.1에서 앱이 로그인 버튼과 시트를 구성할 수 있다. RN·Ionic 패키지는 그 제품이 생길 때. ## 입력·선택·공유 달력 확장 diff --git a/README.md b/README.md index 658d54d..4b38945 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ Priorities live in [`docs/backlog.md`](docs/backlog.md). Packages are created only when a consumer exists (spec §8): `@devslab/dds-tokens` (✅ 2026-08-13) → `dds-css` v1 inventory (Core 6 ✅ 2026-08-13, +13 ✅ 2026-08-15) → AskLinq adoption → `dds-icons` (✅ 2026-08-15) → `dds-solid` + `site-kit` → native Android values, theme and motion -(0.6.0, 2026-11-12, on Maven Central — theme, motion, components, icons). 0.7.0 (2026-11-13, on Maven Central) adds the screen frame and the `dds-compose-testing` artifact (D-052). 0.8.0 (2026-11-13) adds `DdsSegmentedControl`, 0.8.1 its lighter chosen face in dark (`bg.raised`, D-054), 0.9.0 makes that face slide between choices (D-055), 0.9.1 lets an app set the slide speed, and 0.9.2 lets an app pass its own typeface to `DdsTheme`. 0.10.0 adds `DdsSocialSignIn` with selectable providers and their marks. RN and Ionic packages only when such a product exists. +(0.6.0, 2026-11-12, on Maven Central — theme, motion, components, icons). 0.7.0 (2026-11-13, on Maven Central) adds the screen frame and the `dds-compose-testing` artifact (D-052). 0.8.0 (2026-11-13) adds `DdsSegmentedControl`, 0.8.1 its lighter chosen face in dark (`bg.raised`, D-054), 0.9.0 makes that face slide between choices (D-055), 0.9.1 lets an app set the slide speed, and 0.9.2 lets an app pass its own typeface to `DdsTheme`. 0.10.0 adds `DdsSocialSignIn` with selectable providers and their marks. 0.10.1 supports custom sign-in controls and sheet layouts. RN and Ionic packages only when such a product exists. ## Input, choice and shared calendar additions diff --git a/android/CHANGELOG.ko.md b/android/CHANGELOG.ko.md index 4e298a1..09fff79 100644 --- a/android/CHANGELOG.ko.md +++ b/android/CHANGELOG.ko.md @@ -5,6 +5,10 @@ `kr.devslab:dds-android-tokens`, `kr.devslab:dds-compose`, 그리고 0.7.0부터 `kr.devslab:dds-compose-testing`은 한 버전을 쓰고, 웹 패키지와는 버전이 따로다(D-048). 릴리스는 `android-v<버전>` 태그로 낸다. +## 0.10.1 — 2026-11-15 + +- `DdsSocialSignIn`에 시트 상태를 제어하고 로그인 버튼, ‘다른 로그인 방법’ 버튼, 시트를 앱에서 구성할 수 있는 오버로드를 추가했다. 앱 자체 버튼은 `DdsSocialProviderIcon`으로 DDS의 로그인 제공자 로고를 그릴 수 있다. + ## 0.10.0 — 2026-11-15 **새로 생긴 것** diff --git a/android/CHANGELOG.md b/android/CHANGELOG.md index 286602e..40f7e7d 100644 --- a/android/CHANGELOG.md +++ b/android/CHANGELOG.md @@ -5,6 +5,10 @@ `kr.devslab:dds-android-tokens`, `kr.devslab:dds-compose` and (from 0.7.0) `kr.devslab:dds-compose-testing` share one version, separate from the web packages (D-048). Releases are cut by an `android-v` tag. +## 0.10.1 — 2026-11-15 + +- Added controlled sheet state and optional button, overflow trigger, and sheet slots to `DdsSocialSignIn` through a compatible overload. `DdsSocialProviderIcon` renders the bundled mark for custom buttons. + ## 0.10.0 — 2026-11-15 **New** diff --git a/android/README.ko.md b/android/README.ko.md index e09283f..8b8addf 100644 --- a/android/README.ko.md +++ b/android/README.ko.md @@ -26,8 +26,8 @@ dependencies { ```kotlin dependencies { - implementation("kr.devslab:dds-compose:0.10.0") - androidTestImplementation("kr.devslab:dds-compose-testing:0.10.0") + implementation("kr.devslab:dds-compose:0.10.1") + androidTestImplementation("kr.devslab:dds-compose-testing:0.10.1") } ``` @@ -90,6 +90,8 @@ DdsSocialSignIn( 어떤 로그인 수단을 제공할지와 진행 상태는 호출 앱이 정한다. OAuth 설정, 계정 연결, 세션 저장은 해당 앱의 인증 계층이 처리한다. Android 컴포넌트의 공개 제공자 ID는 웹의 [`dds-auth`](../packages/dds-auth/README.ko.md) 카탈로그와 같다. +0.10.1부터 `DdsSocialSignInCustomization`을 넘기면 앱이 시트를 열고 닫거나 버튼, ‘다른 로그인 방법’ 동작, 오류 재시도 영역을 직접 구성할 수 있다. 처음 세 방법과 나머지 목록의 배치는 DDS가 맡는다. `method` 슬롯은 진행 상태, 활성 여부, 시트 배치 여부와 선택 동작을 받는다. `sheet` 슬롯은 받은 폭으로 본문을 배치해 기본 화면과 버튼을 맞출 수 있다. 사용자 지정 버튼에서 `DdsSocialProviderIcon`으로 DDS 로고를 그릴 수 있다. + Google, 카카오, 네이버, LINE, Microsoft, LinkedIn, GitHub, Discord, Figma, Notion, X, Slack, Zoom 로고를 함께 제공한다. GitLab은 기본으로 글자로 표시한다. Apple, Facebook, WeChat은 앱에서 해당 제공자의 승인된 에셋이나 전용 버튼을 사용할 수 있다. Android의 네이버 아이콘은 공식 배포본 `NAVER_login_KR/NAVER_login_Light_KR_green_icon_H56.png` 원본이다. 카카오, Microsoft, GitHub, Slack의 SVG는 원래 색을 유지한 채 PNG로 변환했다. 어두운 테마에서는 GitHub와 카카오 원본에 흰 배경을 받치고 X는 공식 흰색 로고를 사용한다. 공식 출처와 원본 체크섬은 [공통 제공자 에셋 출처 기록](../packages/dds-auth/assets/provenance.json)에서 확인할 수 있다. diff --git a/android/README.md b/android/README.md index 1c9f033..466fc1b 100644 --- a/android/README.md +++ b/android/README.md @@ -26,8 +26,8 @@ dependencies { ```kotlin dependencies { - implementation("kr.devslab:dds-compose:0.10.0") - androidTestImplementation("kr.devslab:dds-compose-testing:0.10.0") + implementation("kr.devslab:dds-compose:0.10.1") + androidTestImplementation("kr.devslab:dds-compose-testing:0.10.1") } ``` @@ -90,6 +90,8 @@ DdsSocialSignIn( The host controls availability and progress. Its auth layer configures OAuth, links identities, and stores sessions. The public provider IDs match the web [`dds-auth`](../packages/dds-auth/README.md) catalog. +In 0.10.1, the `DdsSocialSignInCustomization` overload lets the host control sheet visibility and supply its own method controls, overflow trigger, or sheet with retry content. DDS still arranges the first three methods and the remaining list in order. The `method` slot receives `pending`, `enabled`, and `inSheet`, plus the guarded selection callback. A custom `sheet` can apply the supplied button width to its content so the rows line up with the main column. Custom buttons can use `DdsSocialProviderIcon` to draw the bundled marks. + The bundled assets cover Google, Kakao, Naver, LINE, Microsoft, LinkedIn, GitHub, Discord, Figma, Notion, X, Slack, and Zoom. GitLab uses text by default. Apps can supply approved artwork or a dedicated provider button for Apple, Facebook, and WeChat. Android uses the original full Naver green icon from `NAVER_login_KR/NAVER_login_Light_KR_green_icon_H56.png`. SVG marks from Kakao, Microsoft, GitHub, and Slack are rasterized with their original colors. The dark variants keep the original GitHub and Kakao marks on a white backing and use X’s white artwork. For the official sources and original checksums, see the [shared provider asset provenance](../packages/dds-auth/assets/provenance.json). diff --git a/android/dds-compose/src/androidTest/kotlin/kr/devslab/dds/compose/ScreenReaderTest.kt b/android/dds-compose/src/androidTest/kotlin/kr/devslab/dds/compose/ScreenReaderTest.kt index 78d3c6b..c492b21 100644 --- a/android/dds-compose/src/androidTest/kotlin/kr/devslab/dds/compose/ScreenReaderTest.kt +++ b/android/dds-compose/src/androidTest/kotlin/kr/devslab/dds/compose/ScreenReaderTest.kt @@ -69,6 +69,7 @@ import kr.devslab.dds.compose.component.DdsSelectField import kr.devslab.dds.compose.component.DdsSignInMethod import kr.devslab.dds.compose.component.DdsSocialProvider import kr.devslab.dds.compose.component.DdsSocialSignIn +import kr.devslab.dds.compose.component.DdsSocialSignInCustomization import kr.devslab.dds.compose.component.DdsTabs import kr.devslab.dds.compose.component.DdsTextField import kr.devslab.dds.compose.component.DdsTone @@ -129,6 +130,57 @@ class ScreenReaderTest { rule.onNodeWithText("다른 로그인 방법").assertIsNotEnabled() } + @Test + fun customSignInMethodsKeepTheirOrderAndStayVisibleWhilePending() { + var expanded by mutableStateOf(false) + var pending by mutableStateOf(null) + val attempts = mutableListOf() + show { + DdsSocialSignIn( + methods = listOf( + DdsSignInMethod(DdsSocialProvider.Naver, "Naver"), + DdsSignInMethod(DdsSocialProvider.Google, "Google"), + DdsSignInMethod(DdsSocialProvider.Kakao, "Kakao"), + DdsSignInMethod(DdsSocialProvider.Line, "LINE"), + DdsSignInMethod(DdsSocialProvider.Slack, "Slack", enabled = false), + ), + onSelect = { attempts.add(it); pending = it }, + pending = pending, + customization = DdsSocialSignInCustomization( + expanded = expanded, + onExpandedChange = { expanded = it }, + method = { method, loading, enabled, inSheet, select -> + val placement = if (inSheet) "Additional" else "Main" + val label = if (loading) "Signing in with ${method.label}" else method.label + DdsButton("$placement: $label", onClick = select, enabled = enabled) + }, + more = { enabled, open -> DdsButton("More methods", onClick = open, enabled = enabled) }, + sheet = { _, dismiss, methods -> + Column { + methods() + DdsButton("Close methods", onClick = dismiss) + } + }, + ), + ) + } + rule.onNodeWithText("Main: Kakao").assertExists() + rule.onNodeWithText("Additional: LINE").assertDoesNotExist() + rule.onNodeWithText("More methods").performClick() + rule.onNodeWithText("Additional: Slack").assertIsNotEnabled() + rule.onNodeWithText("Additional: LINE").performClick() + rule.onNodeWithText("Main: Naver").assertIsNotEnabled() + rule.onNodeWithText("More methods").assertIsNotEnabled() + rule.onNodeWithText("Additional: Signing in with LINE").performClick() + rule.onNodeWithText("Close methods").performClick() + rule.onNodeWithText("Additional: Signing in with LINE").assertExists() + rule.runOnIdle { + assertEquals(listOf(DdsSocialProvider.Line), attempts) + pending = null + } + rule.onNodeWithText("Additional: LINE").assertDoesNotExist() + } + // --- text field --------------------------------------------------------- @Test diff --git a/android/dds-compose/src/main/kotlin/kr/devslab/dds/compose/component/Auth.kt b/android/dds-compose/src/main/kotlin/kr/devslab/dds/compose/component/Auth.kt index 7012b6d..42ba2ad 100644 --- a/android/dds-compose/src/main/kotlin/kr/devslab/dds/compose/component/Auth.kt +++ b/android/dds-compose/src/main/kotlin/kr/devslab/dds/compose/component/Auth.kt @@ -78,6 +78,22 @@ public class DdsSignInMethod( public val icon: (@Composable () -> Unit)? = null, ) +/** + * Allows a host to use its own controls with the DDS sign-in layout and order. + * + * [expanded] and [onExpandedChange] control the sheet. It also stays open while an additional + * method is pending. [method] receives the row's pending, enabled and sheet placement states. + * [more] runs inside the centered main column. [sheet] receives the measured main column width + * and the full-width list of additional methods. Omit a slot to render the DDS default. + */ +public class DdsSocialSignInCustomization( + public val expanded: Boolean, + public val onExpandedChange: (Boolean) -> Unit, + public val method: (@Composable (DdsSignInMethod, pending: Boolean, enabled: Boolean, inSheet: Boolean, onClick: () -> Unit) -> Unit)? = null, + public val more: (@Composable (enabled: Boolean, onClick: () -> Unit) -> Unit)? = null, + public val sheet: (@Composable (buttonWidth: Dp, onDismiss: () -> Unit, content: @Composable () -> Unit) -> Unit)? = null, +) + /** * Shows the app's [methods] in order. The first three appear inline and the rest open in a sheet. * An empty list shows nothing. The first entry for each provider wins if the list contains duplicates. @@ -99,6 +115,35 @@ public fun DdsSocialSignIn( moreLabel: String = stringResource(R.string.dds_auth_more_methods), closeLabel: String = stringResource(R.string.dds_auth_close_methods), gutter: Dp = ddsFrame().width.gutter, +) { + SocialSignIn(methods, onSelect, modifier, pending, moreLabel, closeLabel, gutter, customization = null) +} + +/** Uses [customization] to integrate application-specific sign-in controls and recovery content. */ +@Composable +public fun DdsSocialSignIn( + methods: List, + onSelect: (DdsSocialProvider) -> Unit, + customization: DdsSocialSignInCustomization, + modifier: Modifier = Modifier, + pending: DdsSocialProvider? = null, + moreLabel: String = stringResource(R.string.dds_auth_more_methods), + closeLabel: String = stringResource(R.string.dds_auth_close_methods), + gutter: Dp = ddsFrame().width.gutter, +) { + SocialSignIn(methods, onSelect, modifier, pending, moreLabel, closeLabel, gutter, customization) +} + +@Composable +private fun SocialSignIn( + methods: List, + onSelect: (DdsSocialProvider) -> Unit, + modifier: Modifier, + pending: DdsSocialProvider?, + moreLabel: String, + closeLabel: String, + gutter: Dp, + customization: DdsSocialSignInCustomization?, ) { if (methods.isEmpty()) return @@ -115,13 +160,30 @@ public fun DdsSocialSignIn( verticalArrangement = Arrangement.spacedBy(DdsSpace.s12.dp), horizontalAlignment = Alignment.CenterHorizontally, ) { - primary.forEach { SignInButton(it, pending, onSelect) } + primary.forEach { SignInMethod(it, pending, inSheet = false, onSelect, customization?.method) } if (additional.isNotEmpty()) { - var showMore by rememberSaveable { mutableStateOf(false) } - DdsButton(moreLabel, onClick = { showMore = true }, enabled = pending == null, variant = DdsButtonVariant.Plain) - if (showMore) { - SignInSheet(moreLabel, closeLabel, buttonWidth, gutter, onDismiss = { showMore = false }) { - additional.forEach { SignInButton(it, pending, onSelect) } + val localExpanded = if (customization == null) rememberSaveable { mutableStateOf(false) } else null + val expanded = localExpanded?.value ?: (customization?.expanded == true || additional.any { it.provider == pending }) + val updateExpanded = customization?.onExpandedChange ?: { value -> localExpanded?.value = value } + val open = { if (pending == null) updateExpanded(true) } + val more = customization?.more + if (more == null) { + DdsButton(moreLabel, onClick = open, enabled = pending == null, variant = DdsButtonVariant.Plain) + } else { + more(pending == null, open) + } + if (expanded) { + val dismiss = { updateExpanded(false) } + val sheet = customization?.sheet + val content: @Composable () -> Unit = { + Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(DdsSpace.s12.dp)) { + additional.forEach { SignInMethod(it, pending, inSheet = true, onSelect, customization?.method) } + } + } + if (sheet == null) { + SignInSheet(moreLabel, closeLabel, buttonWidth, gutter, dismiss, content) + } else { + sheet(buttonWidth, dismiss, content) } } } @@ -130,13 +192,28 @@ public fun DdsSocialSignIn( } @Composable -private fun SignInButton(method: DdsSignInMethod, pending: DdsSocialProvider?, onSelect: (DdsSocialProvider) -> Unit) { +private fun SignInMethod( + method: DdsSignInMethod, + pending: DdsSocialProvider?, + inSheet: Boolean, + onSelect: (DdsSocialProvider) -> Unit, + render: (@Composable (DdsSignInMethod, Boolean, Boolean, Boolean, () -> Unit) -> Unit)?, +) { + val loading = pending == method.provider + val enabled = method.enabled && (pending == null || loading) + val onClick = { if (enabled && pending == null) onSelect(method.provider) } + if (render == null) SignInButton(method, loading, enabled, onClick) + else render(method, loading, enabled, inSheet, onClick) +} + +@Composable +private fun SignInButton(method: DdsSignInMethod, loading: Boolean, enabled: Boolean, onClick: () -> Unit) { DdsButton( - onClick = { onSelect(method.provider) }, + onClick = onClick, modifier = Modifier.fillMaxWidth(), variant = DdsButtonVariant.Secondary, - enabled = method.enabled && (pending == null || pending == method.provider), - loading = pending == method.provider, + enabled = enabled, + loading = loading, ) { Row( Modifier.fillMaxWidth(), @@ -147,8 +224,7 @@ private fun SignInButton(method: DdsSignInMethod, pending: DdsSocialProvider?, o if (method.icon != null) { method.icon.invoke() } else { - val mark = signedInMark(method.provider) - if (mark != null) Image(painterResource(mark), contentDescription = null, modifier = Modifier.size(DdsIcon.sm.dp)) + DdsSocialProviderIcon(method.provider) } } WordsText(method.label, Modifier.weight(1f), textAlign = TextAlign.Start) @@ -156,8 +232,15 @@ private fun SignInButton(method: DdsSignInMethod, pending: DdsSocialProvider?, o } } +/** Draws the bundled decorative mark, if available. The calling control provides its accessible label. */ +@Composable +public fun DdsSocialProviderIcon(provider: DdsSocialProvider, modifier: Modifier = Modifier) { + val mark = signInMark(provider) ?: return + Image(painterResource(mark), contentDescription = null, modifier = modifier.size(DdsIcon.sm.dp)) +} + @Composable -private fun signedInMark(provider: DdsSocialProvider): Int? { +private fun signInMark(provider: DdsSocialProvider): Int? { // DDS allows an app to force its theme independently of the device configuration. val darkSurface = DdsTheme.colors.bgElevated.luminance() < DdsTheme.colors.textPrimary.luminance() return when (provider) { @@ -211,11 +294,10 @@ private fun SignInSheet( } DdsIconButton(DdsIcons.Close, closeLabel, onClick = onDismiss) } - Column( + Box( Modifier.weight(1f, fill = false).verticalScroll(rememberScrollState()) .padding(start = gutter, end = gutter, top = DdsSpace.s8.dp, bottom = DdsSpace.s16.dp) .widthIn(max = buttonWidth).fillMaxWidth(), - verticalArrangement = Arrangement.spacedBy(DdsSpace.s12.dp), ) { content() } diff --git a/android/gradle.properties b/android/gradle.properties index a82e98f..eb58ee0 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -8,4 +8,4 @@ kotlin.code.style=official # Android releases are versioned apart from the web packages (docs/decisions.md D-048). # The release workflow overrides VERSION_NAME from the android-v* tag. GROUP=kr.devslab -VERSION_NAME=0.10.0 +VERSION_NAME=0.10.1