Components

Sign in

Email and password, Sign in with Apple, and a way back for a forgotten password. Built in all 5 Effect UI styles, in light and dark mode.

Sign in in Prism, light mode
Sign in in Prism, dark mode
Prism ProLiquid Glass on living colour.
Sign in in Ledger, light mode
Sign in in Ledger, dark mode
Ledger FreeCalm, precise, trustworthy.
Sign in in Bounce, light mode
Sign in in Bounce, dark mode
Bounce ProChunky, tactile, joyful.
Sign in in Folio, light mode
Sign in in Folio, dark mode
Folio ProEditorial and literary.
Sign in in Bloom, light mode
Sign in in Bloom, dark mode
Bloom ProSoft, organic, calming.

Source: Ledger

SignInView.swift in the free Ledger style. It needs Ledger's Theme.swift, which comes with the style: join early access on the home page and it's emailed to you.

import SwiftUI

private enum SignInField: Hashable {
    case email, password
}

struct SignInView: View {
    @State private var email = "maya.okafor@fastmail.com"
    @State private var password = "quiet-ledger-42"
    @State private var revealed = false
    /// The field drawn as focused. Starts on password so the state reads without a keyboard.
    @State private var active: SignInField? = .password
    @FocusState private var focus: SignInField?

    private var canSubmit: Bool { email.contains("@") && password.count >= 8 }

    var body: some View {
        ScrollView {
            VStack(alignment: .leading, spacing: Theme.Space.xxl) {
                brand
                intro
                fields
            }
            .padding(.horizontal, Theme.Space.margin)
            .padding(.top, Theme.Space.sm)
            .padding(.bottom, Theme.Space.xl)
        }
        .scrollIndicators(.hidden)
        .scrollDismissesKeyboard(.interactively)
        .paperBackground()
        .safeAreaInset(edge: .bottom) { actions }
        .onChange(of: focus) { _, new in
            if let new { active = new }
        }
    }

    // MARK: Sections

    private var brand: some View {
        HStack(spacing: Theme.Space.sm) {
            RoundedRectangle(cornerRadius: Theme.Radius.md, style: .continuous)
                .fill(Theme.ruleStrong)
                .frame(width: 36, height: 36)
                .overlay(
                    Text("~")
                        .font(.system(size: 24, weight: .semibold))
                        .foregroundStyle(Theme.surface)
                        .offset(y: -2)
                )
            Text("Tilde")
                .ledgerType(.headlineMd)
                .foregroundStyle(Theme.onSurface)
            Spacer()
        }
        .accessibilityElement(children: .combine)
    }

    private var intro: some View {
        VStack(alignment: .leading, spacing: Theme.Space.md) {
            Text("Sign in to Tilde")
                .ledgerType(.headlineLg)
                .foregroundStyle(Theme.onSurface)
            Text("Your accounts, budgets and history are where you left them.")
                .ledgerType(.bodyMd)
                .foregroundStyle(Theme.onSurfaceVariant)
                .fixedSize(horizontal: false, vertical: true)
            Hairline(strong: true).padding(.top, Theme.Space.sm)
        }
    }

    private var fields: some View {
        VStack(alignment: .leading, spacing: Theme.Space.xl) {
            VStack(alignment: .leading, spacing: Theme.Space.sm) {
                label("Email", for: .email)
                TextField("name@example.com", text: $email)
                    .ledgerType(.bodyMd)
                    .foregroundStyle(Theme.onSurface)
                    .keyboardType(.emailAddress)
                    .textContentType(.username)
                    .textInputAutocapitalization(.never)
                    .autocorrectionDisabled()
                    .focused($focus, equals: .email)
                    .submitLabel(.next)
                    .onSubmit { focus = .password }
                    .ledgerField(focused: active == .email)
            }

            VStack(alignment: .leading, spacing: Theme.Space.sm) {
                HStack(alignment: .firstTextBaseline) {
                    label("Password", for: .password)
                    Spacer()
                    Button("Forgot password?") {}
                        .font(.system(size: 13, weight: .semibold))
                        .foregroundStyle(Theme.onSurfaceVariant)
                }
                HStack(spacing: Theme.Space.sm) {
                    Group {
                        if revealed {
                            TextField("At least 8 characters", text: $password)
                        } else {
                            SecureField("At least 8 characters", text: $password)
                        }
                    }
                    .ledgerType(.bodyMd)
                    .foregroundStyle(Theme.onSurface)
                    .textContentType(.password)
                    .textInputAutocapitalization(.never)
                    .autocorrectionDisabled()
                    .focused($focus, equals: .password)
                    .submitLabel(.go)

                    Button {
                        revealed.toggle()
                    } label: {
                        Image(systemName: revealed ? "eye.slash" : "eye")
                            .font(.system(size: 15, weight: .regular))
                            .foregroundStyle(Theme.onSurfaceMuted)
                            .frame(width: 32, height: 32)
                            .contentShape(Rectangle())
                    }
                    .buttonStyle(.plain)
                    .accessibilityLabel(revealed ? "Hide password" : "Show password")
                }
                .ledgerField(focused: active == .password)
            }

            HStack(spacing: Theme.Space.sm) {
                Image(systemName: "faceid")
                    .font(.system(size: 13, weight: .regular))
                Text("After this, Tilde opens with Face ID.")
                    .ledgerType(.bodySm)
            }
            .foregroundStyle(Theme.onSurfaceMuted)
        }
    }

    private func label(_ text: String, for field: SignInField) -> some View {
        MicroLabel(text, color: active == field ? Theme.onSurface : Theme.onSurfaceMuted)
            .animation(Theme.Motion.stateChange, value: active)
    }

    private var actions: some View {
        BottomActionBar {
            Button("Sign in") {}
                .buttonStyle(.ledgerPrimary)
                .disabled(!canSubmit)

            Button {} label: {
                HStack(spacing: Theme.Space.sm) {
                    Image(systemName: "apple.logo")
                        .font(.system(size: 17, weight: .semibold))
                        .offset(y: -1)
                    Text("Sign in with Apple")
                }
            }
            .buttonStyle(.ledgerSecondary)
            .padding(.top, Theme.Space.xs)

            HStack(spacing: Theme.Space.xs) {
                Text("New to Tilde?")
                    .ledgerType(.bodyMd)
                    .foregroundStyle(Theme.onSurfaceMuted)
                Button("Create account") {}
                    .buttonStyle(TextButtonStyle(color: Theme.primaryInk))
            }
            .frame(maxWidth: .infinity)
        }
    }
}

#Preview("Light") {
    SignInView()
}

#Preview("Dark") {
    SignInView().preferredColorScheme(.dark)
}

More screens