UI updates for labwise branding
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x3D",
|
||||
"green" : "0x18",
|
||||
"red" : "0xD4"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
20
LabWise/Assets.xcassets/BrandMuted.colorset/Contents.json
Normal file
20
LabWise/Assets.xcassets/BrandMuted.colorset/Contents.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xF3",
|
||||
"green" : "0xF5",
|
||||
"red" : "0xF0"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x6F",
|
||||
"green" : "0x7A",
|
||||
"red" : "0x5A"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
20
LabWise/Assets.xcassets/BrandPrimary.colorset/Contents.json
Normal file
20
LabWise/Assets.xcassets/BrandPrimary.colorset/Contents.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x4A",
|
||||
"green" : "0x5A",
|
||||
"red" : "0x2D"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xF0",
|
||||
"green" : "0xF3",
|
||||
"red" : "0xE8"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
15
LabWise/Assets.xcassets/GoogleLogo.imageset/Contents.json
vendored
Normal file
15
LabWise/Assets.xcassets/GoogleLogo.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "google-logo.svg",
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
}
|
||||
}
|
||||
6
LabWise/Assets.xcassets/GoogleLogo.imageset/google-logo.svg
vendored
Normal file
6
LabWise/Assets.xcassets/GoogleLogo.imageset/google-logo.svg
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4"/>
|
||||
<path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/>
|
||||
<path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l3.66-2.84z" fill="#FBBC05"/>
|
||||
<path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 689 B |
21
LabWise/Assets.xcassets/Logo.imageset/Contents.json
vendored
Normal file
21
LabWise/Assets.xcassets/Logo.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "logo.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
LabWise/Assets.xcassets/Logo.imageset/logo.png
vendored
Normal file
BIN
LabWise/Assets.xcassets/Logo.imageset/logo.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 75 KiB |
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// ContentView.swift
|
||||
// LabWise
|
||||
//
|
||||
// Created by Aditya Pulipaka on 3/19/26.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
var body: some View {
|
||||
VStack {
|
||||
Image(systemName: "globe")
|
||||
.imageScale(.large)
|
||||
.foregroundStyle(.tint)
|
||||
Text("Hello, world!")
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ContentView()
|
||||
}
|
||||
22
LabWise/DashboardView.swift
Normal file
22
LabWise/DashboardView.swift
Normal file
@@ -0,0 +1,22 @@
|
||||
import SwiftUI
|
||||
|
||||
struct DashboardView: View {
|
||||
var body: some View {
|
||||
TabView {
|
||||
Tab("Chemicals", systemImage: "flask.fill") {
|
||||
ChemicalsListView()
|
||||
}
|
||||
Tab("Scan", systemImage: "camera.fill") {
|
||||
ScanView()
|
||||
}
|
||||
Tab("Profile", systemImage: "person.fill") {
|
||||
ProfileView()
|
||||
}
|
||||
}
|
||||
.tint(Color("Brand/BrandPrimary"))
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
DashboardView()
|
||||
}
|
||||
200
LabWise/LoginView.swift
Normal file
200
LabWise/LoginView.swift
Normal file
@@ -0,0 +1,200 @@
|
||||
import SwiftUI
|
||||
import AuthenticationServices
|
||||
import LabWiseKit
|
||||
|
||||
struct LoginView: View {
|
||||
@Environment(AppState.self) private var appState
|
||||
|
||||
@State private var email = ""
|
||||
@State private var password = ""
|
||||
@State private var isLoading = false
|
||||
@State private var isGoogleLoading = false
|
||||
@State private var errorMessage: String?
|
||||
|
||||
private let authClient = AuthClient()
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
ZStack {
|
||||
Color(UIColor.systemGroupedBackground)
|
||||
.ignoresSafeArea()
|
||||
|
||||
VStack(spacing: 32) {
|
||||
Spacer()
|
||||
|
||||
// Logo
|
||||
VStack(spacing: 16) {
|
||||
Image("Logo")
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(height: 52)
|
||||
Text("Chemical Inventory Management")
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(Color("Brand/BrandMutedForeground"))
|
||||
}
|
||||
|
||||
// Card
|
||||
VStack(spacing: 20) {
|
||||
VStack(spacing: 12) {
|
||||
TextField("Email", text: $email)
|
||||
.keyboardType(.emailAddress)
|
||||
.textContentType(.emailAddress)
|
||||
.autocapitalization(.none)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 10)
|
||||
.background(Color(UIColor.secondarySystemGroupedBackground))
|
||||
.clipShape(RoundedRectangle(cornerRadius: 10))
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.strokeBorder(Color("Brand/BrandPrimary").opacity(0.2), lineWidth: 1)
|
||||
)
|
||||
|
||||
SecureField("Password", text: $password)
|
||||
.textContentType(.password)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 10)
|
||||
.background(Color(UIColor.secondarySystemGroupedBackground))
|
||||
.clipShape(RoundedRectangle(cornerRadius: 10))
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.strokeBorder(Color("Brand/BrandPrimary").opacity(0.2), lineWidth: 1)
|
||||
)
|
||||
}
|
||||
|
||||
if let errorMessage {
|
||||
Text(errorMessage)
|
||||
.foregroundStyle(.red)
|
||||
.font(.footnote)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
|
||||
Button {
|
||||
Task { await signIn() }
|
||||
} label: {
|
||||
Group {
|
||||
if isLoading {
|
||||
ProgressView()
|
||||
.tint(.white)
|
||||
} else {
|
||||
Text("Sign In")
|
||||
.fontWeight(.semibold)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 44)
|
||||
}
|
||||
.background(Color("Brand/BrandPrimary"))
|
||||
.foregroundStyle(.white)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 10))
|
||||
.disabled(email.isEmpty || password.isEmpty || isLoading || isGoogleLoading)
|
||||
.opacity((email.isEmpty || password.isEmpty || isLoading || isGoogleLoading) ? 0.5 : 1)
|
||||
|
||||
HStack {
|
||||
Rectangle()
|
||||
.fill(Color("Brand/BrandPrimary").opacity(0.15))
|
||||
.frame(height: 1)
|
||||
Text("or")
|
||||
.font(.footnote)
|
||||
.foregroundStyle(Color("Brand/BrandMutedForeground"))
|
||||
Rectangle()
|
||||
.fill(Color("Brand/BrandPrimary").opacity(0.15))
|
||||
.frame(height: 1)
|
||||
}
|
||||
|
||||
GoogleSignInButton(isLoading: isGoogleLoading) {
|
||||
Task { await signInWithGoogle() }
|
||||
}
|
||||
.disabled(isLoading || isGoogleLoading)
|
||||
}
|
||||
.padding(24)
|
||||
.background(Color(UIColor.secondarySystemGroupedBackground))
|
||||
.clipShape(RoundedRectangle(cornerRadius: 16))
|
||||
.shadow(color: Color("Brand/BrandPrimary").opacity(0.06), radius: 12, x: 0, y: 4)
|
||||
.padding(.horizontal, 24)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.navigationBarHidden(true)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
private func signIn() async {
|
||||
isLoading = true
|
||||
errorMessage = nil
|
||||
defer { isLoading = false }
|
||||
|
||||
do {
|
||||
let user = try await authClient.signIn(email: email, password: password)
|
||||
await MainActor.run { appState.signedIn(user: user) }
|
||||
} catch APIError.httpError(let code, _) where code == 401 {
|
||||
await MainActor.run { errorMessage = "Invalid email or password." }
|
||||
} catch APIError.httpError(_, let data) {
|
||||
let msg = String(data: data, encoding: .utf8) ?? "Sign in failed."
|
||||
await MainActor.run { errorMessage = msg }
|
||||
} catch {
|
||||
await MainActor.run { errorMessage = "Sign in failed. Please check your connection." }
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func signInWithGoogle() async {
|
||||
guard let window = UIApplication.shared.connectedScenes
|
||||
.compactMap({ $0 as? UIWindowScene })
|
||||
.flatMap({ $0.windows })
|
||||
.first(where: { $0.isKeyWindow }) else { return }
|
||||
|
||||
isGoogleLoading = true
|
||||
errorMessage = nil
|
||||
defer { isGoogleLoading = false }
|
||||
|
||||
do {
|
||||
let user = try await authClient.signInWithGoogle(presentingWindow: window)
|
||||
appState.signedIn(user: user)
|
||||
} catch ASWebAuthenticationSessionError.canceledLogin {
|
||||
// User cancelled — no error shown
|
||||
} catch {
|
||||
errorMessage = "Google sign-in failed. Please try again."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Google button
|
||||
|
||||
struct GoogleSignInButton: View {
|
||||
let isLoading: Bool
|
||||
let action: () -> Void
|
||||
|
||||
var body: some View {
|
||||
Button(action: action) {
|
||||
HStack(spacing: 10) {
|
||||
if isLoading {
|
||||
ProgressView()
|
||||
.frame(maxWidth: .infinity)
|
||||
} else {
|
||||
Image(systemName: "globe")
|
||||
.foregroundStyle(Color("Brand/BrandPrimary"))
|
||||
Text("Continue with Google")
|
||||
.fontWeight(.medium)
|
||||
.foregroundStyle(Color(UIColor.label))
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 44)
|
||||
.background(Color(UIColor.systemBackground))
|
||||
.clipShape(RoundedRectangle(cornerRadius: 10))
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.strokeBorder(Color("Brand/BrandPrimary").opacity(0.25), lineWidth: 1)
|
||||
)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
LoginView()
|
||||
.environment(AppState.shared)
|
||||
}
|
||||
Reference in New Issue
Block a user