-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
265 additions
and
5 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
22 changes: 22 additions & 0 deletions
22
ios-playground/Assets.xcassets/icon_whatsapp.imageset/Contents.json
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,22 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+39.7 KB
ios-playground/Assets.xcassets/icon_whatsapp.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+73.3 KB
ios-playground/Assets.xcassets/icon_whatsapp.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,169 @@ | ||
//// | ||
//// DragDropDemo.swift | ||
//// ios-playground | ||
//// | ||
//// Created by 王杜伟 on 2022/9/7. | ||
//// | ||
// | ||
//import SwiftUI | ||
//import Cocoa | ||
// | ||
//class DragDropDemo: SwiftWithUikitVC<DragDropView> { | ||
// override var body: DragDropView { | ||
// DragDropView() | ||
// } | ||
//} | ||
// | ||
//struct DragDropView: View { | ||
// let img1url = Bundle.main.url(forResource: "Images/grapes", withExtension: "png") | ||
// let img2url = Bundle.main.url(forResource: "Images/banana", withExtension: "png") | ||
// let img3url = Bundle.main.url(forResource: "Images/peach", withExtension: "png") | ||
// let img4url = Bundle.main.url(forResource: "Images/kiwi", withExtension: "png") | ||
// | ||
// var body: some View { | ||
// HStack { | ||
// VStack { | ||
// DragableImage(url: img1url!) | ||
// | ||
// DragableImage(url: img3url!) | ||
// } | ||
// | ||
// VStack { | ||
// DragableImage(url: img2url!) | ||
// | ||
// DragableImage(url: img4url!) | ||
// } | ||
// | ||
// DroppableArea() | ||
// }.padding(40) | ||
// } | ||
// | ||
// struct DragableImage: View { | ||
// let url: URL | ||
// | ||
// var body: some View { | ||
// Image(nsImage: NSImage(byReferencing: url)) | ||
// .resizable() | ||
// .frame(width: 150, height: 150) | ||
// .clipShape(Circle()) | ||
// .overlay(Circle().stroke(Color.white, lineWidth: 2)) | ||
// .padding(2) | ||
// .overlay(Circle().strokeBorder(Color.black.opacity(0.1))) | ||
// .shadow(radius: 3) | ||
// .padding(4) | ||
// .onDrag { return NSItemProvider(object: self.url as NSURL) } | ||
// } | ||
// } | ||
// | ||
// struct DroppableArea: View { | ||
// @State private var imageUrls: [Int: URL] = [:] | ||
// @State private var active = 0 | ||
// | ||
// var body: some View { | ||
// let dropDelegate = MyDropDelegate(imageUrls: $imageUrls, active: $active) | ||
// | ||
// return VStack { | ||
// HStack { | ||
// GridCell(active: self.active == 1, url: imageUrls[1]) | ||
// | ||
// GridCell(active: self.active == 3, url: imageUrls[3]) | ||
// } | ||
// | ||
// HStack { | ||
// GridCell(active: self.active == 2, url: imageUrls[2]) | ||
// | ||
// GridCell(active: self.active == 4, url: imageUrls[4]) | ||
// } | ||
// | ||
// } | ||
// .background(Rectangle().fill(Color.gray)) | ||
// .frame(width: 300, height: 300) | ||
// .onDrop(of: ["public.file-url"], delegate: dropDelegate) | ||
// | ||
// } | ||
// } | ||
// | ||
// | ||
// struct GridCell: View { | ||
// let active: Bool | ||
// let url: URL? | ||
// | ||
// var body: some View { | ||
// let img = Image(nsImage: url != nil ? NSImage(byReferencing: url!) : NSImage()) | ||
// .resizable() | ||
// .frame(width: 150, height: 150) | ||
// | ||
// return Rectangle() | ||
// .fill(self.active ? Color.green : Color.clear) | ||
// .frame(width: 150, height: 150) | ||
// .overlay(img) | ||
// } | ||
// } | ||
// | ||
// | ||
// struct MyDropDelegate: DropDelegate { | ||
// @Binding var imageUrls: [Int: URL] | ||
// @Binding var active: Int | ||
// | ||
// func validateDrop(info: DropInfo) -> Bool { | ||
// return info.hasItemsConforming(to: ["public.file-url"]) | ||
// } | ||
// | ||
// func dropEntered(info: DropInfo) { | ||
// NSSound(named: "Morse")?.play() | ||
// } | ||
// | ||
// func performDrop(info: DropInfo) -> Bool { | ||
// NSSound(named: "Submarine")?.play() | ||
// | ||
// let gridPosition = getGridPosition(location: info.location) | ||
// self.active = gridPosition | ||
// | ||
// if let item = info.itemProviders(for: ["public.file-url"]).first { | ||
// item.loadItem(forTypeIdentifier: "public.file-url", options: nil) { (urlData, error) in | ||
// DispatchQueue.main.async { | ||
// if let urlData = urlData as? Data { | ||
// self.imageUrls[gridPosition] = NSURL(absoluteURLWithDataRepresentation: urlData, relativeTo: nil) as URL | ||
// } | ||
// } | ||
// } | ||
// | ||
// return true | ||
// | ||
// } else { | ||
// return false | ||
// } | ||
// | ||
// } | ||
// | ||
// func dropUpdated(info: DropInfo) -> DropProposal? { | ||
// self.active = getGridPosition(location: info.location) | ||
// | ||
// return nil | ||
// } | ||
// | ||
// func dropExited(info: DropInfo) { | ||
// self.active = 0 | ||
// } | ||
// | ||
// func getGridPosition(location: CGPoint) -> Int { | ||
// if location.x > 150 && location.y > 150 { | ||
// return 4 | ||
// } else if location.x > 150 && location.y < 150 { | ||
// return 3 | ||
// } else if location.x < 150 && location.y > 150 { | ||
// return 2 | ||
// } else if location.x < 150 && location.y < 150 { | ||
// return 1 | ||
// } else { | ||
// return 0 | ||
// } | ||
// } | ||
// } | ||
//} | ||
// | ||
//struct DragDropDemo_Previews: PreviewProvider { | ||
// static var previews: some View { | ||
// DragDropView() | ||
// } | ||
//} |
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,61 @@ | ||
// | ||
// ToolbarDemo.swift | ||
// ios-playground | ||
// | ||
// Created by 王杜伟 on 2022/9/9. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ToolbarView: View { | ||
var body: some View { | ||
NavigationView { | ||
VStack { | ||
Text("小王子的藝想世界") | ||
.font(.largeTitle) | ||
Image("icon_whatsapp") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 100, height: 100) | ||
} | ||
.toolbar { | ||
ToolbarItem(placement: .navigationBarLeading) { | ||
Button {} label: { | ||
Text("edit") | ||
} | ||
} | ||
|
||
ToolbarItem(placement: .cancellationAction) { | ||
Button("Cancel") { | ||
} | ||
} | ||
ToolbarItemGroup(placement: .navigationBarTrailing) { | ||
Button {} label: { | ||
Text("edit") | ||
} | ||
|
||
Button {} label: { | ||
Image(systemName: "plus") | ||
} | ||
} | ||
|
||
ToolbarItem(placement: .principal) { | ||
HStack { | ||
Image("test_image_02") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 50, height: 50) | ||
.offset(y: 1) | ||
Text("Peter") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct ToolbarDemo_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ToolbarView() | ||
} | ||
} |