ESP-IDF CI / Host Tests (Unity) (push) Successful in 1m8s
CI / firmware-native (push) Successful in 2m57s
Rust Protection Tests / Cargo test (host) (push) Failing after 3m21s
ESP-IDF CI / ESP-IDF Build (v5.4) (push) Failing after 6m55s
ESP-IDF CI / Memory Budget Gate (push) Has been skipped
qa-cicd-environments / qa-kxkm-s3-build (push) Successful in 8m53s
qa-cicd-environments / qa-sim-host (push) Successful in 2m2s
qa-cicd-environments / qa-kxkm-s3-memory-budget (push) Successful in 11m17s
Context: the project archive (KXKM_Batterie_Parallelator-main) had no git history locally; a fresh repository is needed to host it on git.saillant.cc (electron/KXKM_Batterie_Parallelator). Approach: initialize a new repo on branch main, stage the archive content, and harden .gitignore before the first commit. Changes: - Import the full project tree: firmware/, firmware-idf/, firmware-rs/, iosApp/, kxkm-bmu-app/, kxkm-api/, hardware/, docs/, specs/, scripts/, models/, tests/ - Keep project dotfiles tracked despite the trailing '.*' ignore rule: .github/, .claude/, .superpowers/, .gitattributes, .markdownlint.json - Extend .gitignore: firmware/src/credentials.h (local secrets, template kept), kxkm-bmu-app/**/build/ (66 MB compiled iOS framework), .remember/ (session data) Impact: the project can now be maintained on the self-hosted Gitea forge with a clean, secret-free initial history.
118 lines
3.5 KiB
Swift
118 lines
3.5 KiB
Swift
import SwiftUI
|
|
import LocalAuthentication
|
|
|
|
struct PinEntryView: View {
|
|
@EnvironmentObject var authVM: AuthViewModel
|
|
@State private var pin = ""
|
|
@State private var showBiometric = true
|
|
|
|
private var biometryLabel: String {
|
|
let context = LAContext()
|
|
_ = context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil)
|
|
switch context.biometryType {
|
|
case .touchID: return "Touch ID"
|
|
case .faceID: return "Face ID"
|
|
default: return "Biométrie"
|
|
}
|
|
}
|
|
|
|
private var biometryIcon: String {
|
|
let context = LAContext()
|
|
_ = context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil)
|
|
switch context.biometryType {
|
|
case .touchID: return "touchid"
|
|
case .faceID: return "faceid"
|
|
default: return "faceid"
|
|
}
|
|
}
|
|
|
|
var body: some View {
|
|
VStack(spacing: 32) {
|
|
Spacer()
|
|
|
|
Image(systemName: "battery.100.bolt")
|
|
.font(.system(size: 60))
|
|
.foregroundColor(.green)
|
|
|
|
Text("KXKM BMU")
|
|
.font(.title.bold())
|
|
|
|
Text("Entrez votre PIN")
|
|
.font(.subheadline)
|
|
.foregroundColor(.secondary)
|
|
|
|
// PIN dots
|
|
HStack(spacing: 16) {
|
|
ForEach(0..<6, id: \.self) { i in
|
|
Circle()
|
|
.fill(i < pin.count ? Color.primary : Color.gray.opacity(0.3))
|
|
.frame(width: 16, height: 16)
|
|
}
|
|
}
|
|
|
|
if let error = authVM.pinError {
|
|
Text(error)
|
|
.foregroundColor(.red)
|
|
.font(.caption)
|
|
}
|
|
|
|
// Number pad
|
|
LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 3), spacing: 16) {
|
|
ForEach(1...9, id: \.self) { num in
|
|
PinButton(label: "\(num)") { pin.append("\(num)") }
|
|
}
|
|
PinButton(label: biometryLabel, icon: biometryIcon) {
|
|
authenticateWithBiometrics()
|
|
}
|
|
PinButton(label: "0") { pin.append("0") }
|
|
PinButton(label: "←", icon: "delete.left") {
|
|
if !pin.isEmpty { pin.removeLast() }
|
|
}
|
|
}
|
|
.padding(.horizontal, 40)
|
|
|
|
Spacer()
|
|
}
|
|
.onChange(of: pin) { newValue in
|
|
if newValue.count == 6 {
|
|
authVM.login(pin: newValue)
|
|
if !authVM.isAuthenticated { pin = "" }
|
|
}
|
|
}
|
|
}
|
|
|
|
private func authenticateWithBiometrics() {
|
|
BiometricAuth.authenticate { success in
|
|
if success {
|
|
// Use stored last-user PIN from keychain
|
|
if let storedPin = BiometricAuth.getStoredPin() {
|
|
authVM.login(pin: storedPin)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct PinButton: View {
|
|
let label: String
|
|
var icon: String? = nil
|
|
let action: () -> Void
|
|
|
|
var body: some View {
|
|
Button(action: action) {
|
|
if let icon = icon {
|
|
Image(systemName: icon)
|
|
.font(.title2)
|
|
.frame(width: 72, height: 72)
|
|
} else {
|
|
Text(label)
|
|
.font(.title)
|
|
.frame(width: 72, height: 72)
|
|
}
|
|
}
|
|
.foregroundColor(.primary)
|
|
.background(Color(.systemGray6))
|
|
.clipShape(Circle())
|
|
}
|
|
}
|