Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ fun CustomerIntakeScreen(
val templateUiState by templateListViewModel.uiState.collectAsStateWithLifecycle()
// Use rememberSaveable so rotation/process death doesn't reset these
var passwordVisible by rememberSaveable { mutableStateOf(false) }
var showQrSheet by rememberSaveable { mutableStateOf(false) }
// Dropdown state is transient - use remember so it collapses on rotation
var templateDropdownExpanded by remember { mutableStateOf(false) }
// Copy success feedback - brief visual confirmation (ChatGPT feedback: animate meaning)
Expand Down Expand Up @@ -132,25 +131,14 @@ fun CustomerIntakeScreen(
}
}

// QR Code Bottom Sheet
// For open networks, only SSID is required
// For secured networks, both SSID and valid password are required
val qrEnabled = if (uiState.isOpenNetwork) {
uiState.ssid.isNotBlank() && uiState.ssidError == null
} else {
uiState.ssid.isNotBlank() &&
uiState.ssidError == null &&
uiState.password.isNotBlank() &&
uiState.password.length >= WifiQrGenerator.MIN_PASSWORD_LENGTH &&
uiState.passwordError == null
}

if (showQrSheet && qrEnabled) {
// QR Code Bottom Sheet — showQrSheet and qrEnabled live in the ViewModel
// so the auto-reset (qrEnabled → false clears the sheet) is testable.
if (uiState.showQrSheet) {
QrCodeBottomSheet(
ssid = uiState.ssid,
password = uiState.password,
isOpenNetwork = uiState.isOpenNetwork,
onDismiss = { showQrSheet = false }
onDismiss = { customerIntakeViewModel.setShowQrSheet(false) }
)
}

Expand Down Expand Up @@ -240,10 +228,10 @@ fun CustomerIntakeScreen(

QrCodeSection(
uiState = uiState,
enabled = qrEnabled,
enabled = uiState.qrEnabled,
onShowQrClick = {
hapticFeedback()
showQrSheet = true
customerIntakeViewModel.setShowQrSheet(true)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.kingpaging.qwelcome.ui

import com.kingpaging.qwelcome.data.CustomerData
import com.kingpaging.qwelcome.util.StringUtils
import com.kingpaging.qwelcome.util.WifiQrGenerator

/**
* UI state for the Customer Intake form.
Expand All @@ -26,8 +27,22 @@ data class CustomerIntakeUiState(
val accountNumberError: String? = null,
/** When true, password validation is skipped (for open/guest networks) */
val isOpenNetwork: Boolean = false,
/** Whether the QR code bottom sheet is currently shown */
val showQrSheet: Boolean = false,
) {

/** True when the WiFi fields are valid enough to generate a QR code. */
val qrEnabled: Boolean
get() = if (isOpenNetwork) {
ssid.isNotBlank() && ssidError == null
} else {
ssid.isNotBlank() &&
ssidError == null &&
password.isNotBlank() &&
password.length >= WifiQrGenerator.MIN_PASSWORD_LENGTH &&
passwordError == null
}

/**
* Returns true if all form fields pass validation (no errors present).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,22 @@ class CustomerIntakeViewModel(
// Track last action time for rate limiting
private var lastActionTime: Long = 0L

/**
* Wraps [MutableStateFlow.update] with an automatic guard:
* if the resulting state has [CustomerIntakeUiState.showQrSheet] true
* but [CustomerIntakeUiState.qrEnabled] false, the sheet flag is cleared.
*/
private inline fun updateState(transform: (CustomerIntakeUiState) -> CustomerIntakeUiState) {
_uiState.update { current ->
val next = transform(current)
if (next.showQrSheet && !next.qrEnabled) next.copy(showQrSheet = false) else next
}
}

fun setShowQrSheet(show: Boolean) {
updateState { it.copy(showQrSheet = show) }
}

fun onPause() {
savedStateHandle[KEY_BACKGROUND_TIMESTAMP] = timeProvider.elapsedRealtime()
}
Expand Down Expand Up @@ -158,7 +174,7 @@ class CustomerIntakeViewModel(
fun onSsidChanged(ssid: String) {
// Real-time validation for SSID byte length (WiFi spec: max 32 bytes UTF-8)
val error = if (ssid.isEmpty()) null else getWifiErrorMessage(WifiQrGenerator.validateSsid(ssid))
_uiState.update { it.copy(ssid = ssid, ssidError = error) }
updateState { it.copy(ssid = ssid, ssidError = error) }
}

fun onPasswordChanged(password: String) {
Expand All @@ -171,7 +187,7 @@ class CustomerIntakeViewModel(
)
else -> getWifiErrorMessage(WifiQrGenerator.validatePassword(password))
}
_uiState.update { it.copy(password = password, passwordError = error) }
updateState { it.copy(password = password, passwordError = error) }
}

fun onAccountNumberChanged(accountNumber: String) {
Expand All @@ -183,7 +199,7 @@ class CustomerIntakeViewModel(
* and the password field is cleared/disabled (for guest networks without passwords).
*/
fun onOpenNetworkChanged(isOpen: Boolean) {
_uiState.update { state ->
updateState { state ->
state.copy(
isOpenNetwork = isOpen,
// Clear password and error when switching to open network
Expand Down Expand Up @@ -293,7 +309,7 @@ class CustomerIntakeViewModel(
val accountNumberError = if (currentState.accountNumber.isBlank()) resourceProvider.getString(R.string.error_account_empty) else null

// Batch all error updates into a single state change to minimize recompositions
_uiState.update { state ->
updateState { state ->
state.copy(
customerNameError = customerNameError,
customerPhoneError = customerPhoneError,
Expand Down
41 changes: 40 additions & 1 deletion docs/RELEASE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,37 @@

## Full Release Workflow

### Phase 0 — Merge All Pending Fix / Feature PRs First

> **This step must happen before creating the release branch.** The release branch is a snapshot of `master` at the point it is cut. Any bug fix or feature that should be included in the release must already be on `master` before you proceed.

**Required order of operations:**

1. **Fix / feature work** lives on its own branch (`fix/<desc>` or `feature/<desc>`).
2. **Open a PR** from that branch → `master`. Fill in the body, get CI green, get approval.
3. **Merge the PR** into `master`.
4. **Pull `master` locally** (`git pull origin master`) to incorporate the merged commits.
5. **Only then** proceed to Phase 1 to create the release branch.

```powershell
# Confirm master is fully up to date before cutting the release branch
git checkout master
git pull origin master

# Verify all expected fix/feature commits are present
git log --oneline -10
```

> **Why?** If you create the release branch before merging a fix PR, that fix is absent from the
> release unless you manually cherry-pick or re-merge — both of which are error-prone. Always
> let `master` converge first.

---

### Phase 1 — Prepare the Release Branch

```powershell
# 1. Make sure you are on master and up to date
# 1. Make sure you are on master and up to date (repeat git pull if needed after Phase 0)
git checkout master
git pull origin master

Expand Down Expand Up @@ -263,6 +290,18 @@ For an AI agent performing a release, here is the exact sequence of operations.
**The agent handles everything — no manual steps required.**

```text
# ── Phase 0: Land all fix/feature PRs into master first ──────────────────────
0a. For each pending fix/feature:
a. git checkout -b fix/<desc> (or feature/<desc>) from master
b. Commit the changes
c. git push -u origin HEAD
d. Create PR → master via API/MCP tools
e. Wait for CI green + approval
f. Merge the PR on GitHub
0b. git checkout master && git pull origin master
# Confirm all expected commits are present: git log --oneline -10
# ─────────────────────────────────────────────────────────────────────────────

1. git checkout master && git pull origin master
2. git fetch --tags
3. $LAST_TAG = git describe --tags --abbrev=0 --match "v*"
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
agp = "9.0.0"
agp = "9.0.1"
coreKtx = "1.17.0"
appcompat = "1.7.1"
junit = "4.13.2"
Expand All @@ -9,7 +9,7 @@ espressoCore = "3.7.0"
# Includes collectAsStateWithLifecycle and other improvements
lifecycle = "2.10.0"
activityCompose = "1.12.2"
kotlin = "2.0.21"
kotlin = "2.2.10"
composeBom = "2026.01.00"
datastorePreferences = "1.2.0"
splashscreen = "1.2.0"
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#Sun Jan 25 02:20:49 CST 2026
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=a17ddd85a26b6a7f5ddb71ff8b05fc5104c0202c6e64782429790c933686c806
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
distributionSha256Sum=72f44c9f8ebcb1af43838f45ee5c4aa9c5444898b3468ab3f4af7b6076c5bc3f
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down