Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dena-sohrabi committed Oct 27, 2024
1 parent 8188131 commit c418571
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,13 @@ iOSInjectionProject/
Network Trash Folder
Temporary Items
.apdisk


.DS_Store
/Packages
xcuserdata/
DerivedData/
**/.build
**/.swiftpm/configuration/registries.json
**/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
**/.netrc
4 changes: 4 additions & 0 deletions InlineIOS/Views/Main/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ struct MainView: View {
if !spaceList.spaces.isEmpty {
List(spaceList.spaces.sorted(by: { $0.date > $1.date })) { space in
Text(space.name)
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
.onTapGesture {
nav.push(.space(id: space.id))
}
Expand All @@ -40,6 +42,8 @@ struct MainView: View {
.padding(.trailing, 6)
Text(chat.title ?? "")
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
.onTapGesture {
nav.push(.chat(id: chat.id))
}
Expand Down
29 changes: 29 additions & 0 deletions InlineUI/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "InlineUI",
platforms: [
.iOS(.v17),
.macOS(.v12),
],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "InlineUI",
targets: ["InlineUI"]
),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "InlineUI"),
.testTarget(
name: "InlineUITests",
dependencies: ["InlineUI"]
),
]
)
43 changes: 43 additions & 0 deletions InlineUI/Sources/InlineUI/Initials.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import SwiftUI

public struct InitialsCircle: View {
let name: String
let size: CGFloat

// sdc
private var initials: String {
name.components(separatedBy: " ")
.prefix(2)
.compactMap { $0.first }
.map(String.init)
.joined()
.uppercased()
}

private var color: Color {
let hash = name.hashValue
let grayValue = Double(abs(hash) % 40) / 100 + 0.8 // Range from 0.8 to 0.99
return Color(white: grayValue)
}

public var body: some View {
ZStack {
Circle()
.fill(color)
.overlay(
Circle()
.strokeBorder(Color.gray.opacity(0.2), lineWidth: 1)
)

Text(initials)
.foregroundColor(.gray)
.font(.system(size: size * 0.5, weight: .medium))
.minimumScaleFactor(0.5)
}
.frame(width: size, height: size)
}
}

#Preview {
InitialsCircle(name: "John Doe", size: 40)
}
2 changes: 2 additions & 0 deletions InlineUI/Sources/InlineUI/InlineUI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// The Swift Programming Language
// https://docs.swift.org/swift-book
6 changes: 6 additions & 0 deletions InlineUI/Tests/InlineUITests/InlineUITests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Testing
@testable import InlineUI

@Test func example() async throws {
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
}

0 comments on commit c418571

Please sign in to comment.