-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:DroidKaigi/conference-app-2024 into…
… feature/446-gridlines
- Loading branch information
Showing
74 changed files
with
1,182 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app-android/src/main/java/io/github/droidkaigi/confsched/share/SaveToDisk.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.github.droidkaigi.confsched.share | ||
|
||
import android.content.Context | ||
import android.graphics.Bitmap.CompressFormat.PNG | ||
import androidx.compose.ui.graphics.ImageBitmap | ||
import androidx.compose.ui.graphics.asAndroidBitmap | ||
import kotlinx.datetime.Clock.System | ||
import kotlinx.datetime.TimeZone | ||
import kotlinx.datetime.toLocalDateTime | ||
import java.io.File | ||
import java.io.FileOutputStream | ||
|
||
fun ImageBitmap.saveToDisk(context: Context): String { | ||
val timestamp = System.now() | ||
.toLocalDateTime(TimeZone.UTC) | ||
.toString() | ||
.replace(":", "") | ||
.replace(".", "") | ||
val fileName = "shared_image_$timestamp.png" | ||
|
||
val cachePath = File(context.cacheDir, "images") | ||
cachePath.mkdirs() | ||
val file = File(cachePath, fileName) | ||
val outputStream = FileOutputStream(file) | ||
|
||
this.asAndroidBitmap().compress(PNG, 100, outputStream) | ||
outputStream.flush() | ||
outputStream.close() | ||
|
||
return file.absolutePath | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<paths> | ||
<cache-path name="images" path="images/" /> | ||
</paths> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
app-ios/Sources/CommonComponents/Timetable/CircularUserIcon.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import Foundation | ||
import SwiftUI | ||
|
||
private actor CircularUserIconInMemoryCache { | ||
static let shared = CircularUserIconInMemoryCache() | ||
private init() {} | ||
|
||
private var cache: [String: Data] = [:] | ||
|
||
func data(urlString: String) -> Data? { | ||
return cache[urlString] | ||
} | ||
|
||
func set(data: Data, urlString: String) { | ||
cache[urlString] = data | ||
} | ||
} | ||
|
||
public struct CircularUserIcon: View { | ||
let urlString: String | ||
@State private var iconData: Data? | ||
|
||
public init(urlString: String) { | ||
self.urlString = urlString | ||
} | ||
|
||
public var body: some View { | ||
Group { | ||
if let data = iconData, | ||
let uiImage = UIImage(data: data) { | ||
Image(uiImage: uiImage) | ||
.resizable() | ||
} else { | ||
Circle().stroke(Color.gray) | ||
} | ||
} | ||
.clipShape(Circle()) | ||
.task { | ||
if let data = await CircularUserIconInMemoryCache.shared.data(urlString: urlString) { | ||
iconData = data | ||
return | ||
} | ||
|
||
guard let url = URL(string: urlString) else { | ||
return | ||
} | ||
let urlRequest = URLRequest(url: url, cachePolicy: .useProtocolCachePolicy) | ||
if let (data, _) = try? await URLSession.shared.data(for: urlRequest) { | ||
iconData = data | ||
await CircularUserIconInMemoryCache.shared.set(data: data, urlString: urlString) | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
CircularUserIcon(urlString: "https://avatars.githubusercontent.com/u/10727543?s=96&v=4") | ||
.frame(width: 32, height: 32) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,37 @@ | ||
import SwiftUI | ||
import Theme | ||
import shared | ||
import Model | ||
|
||
public struct RoomTag: View { | ||
let roomName: MultiLangText | ||
let roomType: RoomType | ||
|
||
public init(_ roomName: MultiLangText) { | ||
self.roomName = roomName | ||
self.roomType = .init(enTitle: roomName.enTitle) | ||
} | ||
|
||
public var body: some View { | ||
HStack(spacing: 4) { | ||
roomName.roomType.shape | ||
RoomTypeShape(roomType: roomType) | ||
Text(roomName.currentLangTitle) | ||
.textStyle(.labelMedium) | ||
} | ||
.foregroundStyle(roomName.roomType.theme.primaryColor) | ||
.foregroundStyle(roomType.theme.primaryColor) | ||
.padding(.horizontal, 6) | ||
.overlay( | ||
RoundedRectangle(cornerRadius: 2) | ||
.stroke(roomName.roomType.theme.primaryColor, lineWidth: 1) | ||
.stroke(roomType.theme.primaryColor, lineWidth: 1) | ||
) | ||
} | ||
} | ||
|
||
enum ThemeKey { | ||
static let iguana = "iguana" | ||
static let hedgehog = "hedgehog" | ||
static let giraffe = "giraffe" | ||
static let flamingo = "flamingo" | ||
static let jellyfish = "jellyfish" | ||
} | ||
|
||
|
||
extension MultiLangText { | ||
var roomType: RoomType { | ||
switch enTitle.lowercased() { | ||
case ThemeKey.flamingo: .roomF | ||
case ThemeKey.giraffe: .roomG | ||
case ThemeKey.hedgehog: .roomH | ||
case ThemeKey.iguana: .roomI | ||
case ThemeKey.jellyfish: .roomJ | ||
default: .roomIj | ||
} | ||
} | ||
} | ||
|
||
extension RoomType { | ||
public var shape: some View { | ||
Group { | ||
switch self { | ||
case .roomG: Image(.icCircleFill).renderingMode(.template) | ||
case .roomH: Image(.icDiamondFill).renderingMode(.template) | ||
case .roomF: Image(.icSharpDiamondFill).renderingMode(.template) | ||
case .roomI: Image(.icSquareFill).renderingMode(.template) | ||
case .roomJ: Image(.icTriangleFill).renderingMode(.template) | ||
case .roomIj: Image(.icSquareFill).renderingMode(.template) | ||
} | ||
} | ||
.foregroundStyle(theme.primaryColor) | ||
.frame(width: 12, height: 12) | ||
} | ||
} | ||
|
||
#Preview { | ||
RoomTag( | ||
MultiLangText( | ||
jaTitle: "Iguana", | ||
enTitle: "Iguana" | ||
currentLangTitle: "Iguana", | ||
enTitle: "Iguana", | ||
jaTitle: "Iguana" | ||
) | ||
) | ||
} |
36 changes: 36 additions & 0 deletions
36
app-ios/Sources/CommonComponents/Timetable/RoomTypeShape.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import SwiftUI | ||
import Model | ||
|
||
public struct RoomTypeShape: View { | ||
let roomType: RoomType | ||
|
||
public init(roomType: RoomType) { | ||
self.roomType = roomType | ||
} | ||
|
||
public var body: some View { | ||
Group { | ||
switch roomType { | ||
case .roomG: Image(.icCircleFill).renderingMode(.template) | ||
case .roomH: Image(.icDiamondFill).renderingMode(.template) | ||
case .roomF: Image(.icSharpDiamondFill).renderingMode(.template) | ||
case .roomI: Image(.icSquareFill).renderingMode(.template) | ||
case .roomJ: Image(.icTriangleFill).renderingMode(.template) | ||
case .roomIj: Image(.icSquareFill).renderingMode(.template) | ||
} | ||
} | ||
.foregroundStyle(roomType.theme.primaryColor) | ||
.frame(width: 12, height: 12) | ||
} | ||
} | ||
|
||
#Preview { | ||
Group { | ||
RoomTypeShape(roomType: .roomF) | ||
RoomTypeShape(roomType: .roomG) | ||
RoomTypeShape(roomType: .roomH) | ||
RoomTypeShape(roomType: .roomI) | ||
RoomTypeShape(roomType: .roomJ) | ||
RoomTypeShape(roomType: .roomIj) | ||
} | ||
} |
Oops, something went wrong.