-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
06cab48
commit 8402934
Showing
4 changed files
with
127 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// MemojiContentView.swift | ||
// MemojiView | ||
// | ||
// Created by Emre Armagan on 05.01.25. | ||
// Copyright © 2025 Emre Armagan. All rights reserved. | ||
// | ||
|
||
import MemojiView | ||
import SwiftUI | ||
|
||
struct MemojiContentView: View { | ||
@State private var displayedImage: UIImage? | ||
@State private var displayedType: MemojiImageType? | ||
@State private var isEditable: Bool = true | ||
|
||
var body: some View { | ||
VStack(spacing: 20) { | ||
Text("Memoji Editor").font(.headline) | ||
|
||
MemojiViewRepresentable( | ||
image: $displayedImage, | ||
memojiType: $displayedType, | ||
isEditable: $isEditable, | ||
maxLetters: 10, | ||
textColor: .blue | ||
) { updatedImage, updatedType in | ||
print("Updated image: \(updatedImage?.description ?? "nil")") | ||
print("Updated type: \(updatedType)") | ||
} | ||
.frame(height: 200) | ||
.border(Color.gray, width: 1) | ||
|
||
Toggle("Enable Editing", isOn: $isEditable) | ||
.padding() | ||
|
||
if let image = displayedImage { | ||
Image(uiImage: image) | ||
.resizable() | ||
.scaledToFit() | ||
.frame(height: 100) | ||
} | ||
} | ||
.padding() | ||
} | ||
} | ||
|
||
struct MemojiContentView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
MemojiContentView() | ||
.previewDevice("iPhone 14 Pro") | ||
.previewDisplayName("ContentView Preview") | ||
} | ||
} |
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,35 @@ | ||
// | ||
// SwiftUIExampleViewController.swift | ||
// MemojiView | ||
// | ||
// Created by Emre Armagan on 05.01.25. | ||
// Copyright © 2025 Emre Armagan. All rights reserved. | ||
// | ||
|
||
import MemojiView | ||
import SwiftUI | ||
import UIKit | ||
|
||
class SwiftUIExampleViewController: UIViewController { | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
setupSwiftUIContent() | ||
} | ||
|
||
private func setupSwiftUIContent() { | ||
let hostingController = UIHostingController(rootView: MemojiContentView()) | ||
addChild(hostingController) | ||
|
||
hostingController.view.translatesAutoresizingMaskIntoConstraints = false | ||
view.addSubview(hostingController.view) | ||
|
||
NSLayoutConstraint.activate([ | ||
hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), | ||
hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), | ||
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor), | ||
hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor) | ||
]) | ||
|
||
hostingController.didMove(toParent: self) | ||
} | ||
} |