-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wire cells upload images & videos previews
- Loading branch information
Showing
71 changed files
with
965 additions
and
87 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
1 change: 1 addition & 0 deletions
1
WireCells/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDETemplateMacros.plist
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 @@ | ||
../../../../../wire-ios-mono.xcworkspace/xcshareddata/IDETemplateMacros.plist |
8 changes: 8 additions & 0 deletions
8
WireCells/.swiftpm/xcode/package.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key> | ||
<false/> | ||
</dict> | ||
</plist> |
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 |
---|---|---|
|
@@ -17,5 +17,5 @@ | |
// | ||
|
||
public enum WireCellsFileQueryError: Error { | ||
case genericError(Error) | ||
case genericError(any Error) | ||
} |
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
File renamed without changes.
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
File renamed without changes.
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
55 changes: 55 additions & 0 deletions
55
WireCells/Sources/WireCellsUI/Components/CircularIconButtonStyle.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,55 @@ | ||
// | ||
// Wire | ||
// Copyright (C) 2025 Wire Swiss GmbH | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see http://www.gnu.org/licenses/. | ||
// | ||
|
||
import SwiftUI | ||
import WireDesign | ||
|
||
struct CircularIconButtonStyle: ButtonStyle { | ||
private enum Constants { | ||
static let backgroundColor: Color = BaseColorPalette.Neutrals.white.color | ||
static let iconColor: Color = BaseColorPalette.Neutrals.black.color | ||
static let strokeColor: Color = BaseColorPalette.Grays.gray40.color | ||
static let strokeWidth: CGFloat = 1 | ||
} | ||
|
||
let padding: CGFloat | ||
|
||
func makeBody(configuration: Configuration) -> some View { | ||
configuration | ||
.label | ||
.foregroundStyle(Constants.backgroundColor) | ||
.overlay(Circle().stroke(Constants.strokeColor, lineWidth: Constants.strokeWidth).padding(padding)) | ||
.background(Circle().fill(Constants.iconColor).padding(padding)) | ||
// Optionally, apply a slight visual change when pressed | ||
.opacity(configuration.isPressed ? 0.6 : 1.0) | ||
} | ||
} | ||
|
||
#Preview { | ||
Button(action: { | ||
print("Tapped") | ||
}, label: { | ||
Image(systemName: "xmark.circle.fill") | ||
.font(.system(size: 24)) | ||
.buttonStyle(CircularIconButtonStyle(padding: 2)) | ||
}) | ||
.foregroundStyle(.white) | ||
.frame(width: 35, height: 35) | ||
.padding(20) | ||
.background(Color.gray) | ||
} |
69 changes: 69 additions & 0 deletions
69
WireCells/Sources/WireCellsUI/Components/DeleteItemButtonViewModifier.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,69 @@ | ||
// | ||
// Wire | ||
// Copyright (C) 2025 Wire Swiss GmbH | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see http://www.gnu.org/licenses/. | ||
// | ||
|
||
import SwiftUI | ||
import WireDesign | ||
|
||
struct DeleteItemButtonViewModifier: ViewModifier { | ||
private enum Constants { | ||
static let iconFontSize: CGFloat = 24 | ||
static let padding: CGFloat = 2 | ||
static let buttonSize: CGFloat = 35 | ||
static let offset: CGFloat = 17.5 | ||
} | ||
|
||
let onRemove: @Sendable () -> Void | ||
|
||
init(onRemove: @escaping @Sendable () -> Void) { | ||
self.onRemove = onRemove | ||
} | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.overlay(alignment: .topTrailing) { | ||
Button(action: { | ||
onRemove() | ||
}, label: { | ||
Image(systemName: "xmark.circle.fill") | ||
.font(.system(size: Constants.iconFontSize)) | ||
}) | ||
.buttonStyle(CircularIconButtonStyle(padding: Constants.padding)) | ||
.frame( | ||
width: Constants.buttonSize, | ||
height: Constants.buttonSize | ||
) | ||
.offset( | ||
x: Constants.offset, | ||
y: -Constants.offset | ||
) | ||
} | ||
} | ||
} | ||
|
||
extension View { | ||
func deleteItemButton(onRemove: @escaping @Sendable () -> Void) -> some View { | ||
modifier(DeleteItemButtonViewModifier(onRemove: onRemove)) | ||
} | ||
} | ||
|
||
#Preview { | ||
RoundedRectangle(cornerRadius: 10) | ||
.fill(.gray) | ||
.deleteItemButton(onRemove: {}) | ||
.frame(width: 200, height: 200) | ||
} |
49 changes: 49 additions & 0 deletions
49
WireCells/Sources/WireCellsUI/Components/LocalImagePreview.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,49 @@ | ||
// | ||
// Wire | ||
// Copyright (C) 2025 Wire Swiss GmbH | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see http://www.gnu.org/licenses/. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct LocalImagePreview: View { | ||
private enum Constants { | ||
static let cornerRadius: CGFloat = 10 | ||
} | ||
|
||
let image: Image | ||
|
||
var body: some View { | ||
GeometryReader { geometry in | ||
image | ||
.resizable() | ||
.scaledToFill() | ||
// Image won't clip to the container's frame. | ||
.frame(width: geometry.size.width, height: geometry.size.height) | ||
.clipShape(RoundedRectangle(cornerRadius: Constants.cornerRadius, style: .circular)) | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
VStack { | ||
LocalImagePreview(image: Image("square-placeholder", bundle: .module)) | ||
.foregroundStyle(.black) | ||
.frame(width: 200, height: 200) | ||
.background(.white) | ||
} | ||
.padding() | ||
.background(.gray) | ||
} |
Oops, something went wrong.