Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#21 add StringCatalogEnumSample App demonstrating use cases #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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>SchemeUserState</key>
<dict>
<key>StringCatalogEnumSample.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// StringCatalogEnumSampleApp.swift
// StringCatalogEnumSample
//
// Created by Vatsal Patel on 3/21/24.
//

import SwiftUI

@main
struct StringCatalogEnumSampleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "logoQuible.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "nba.jpeg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// Card.swift
// StringCatalogEnumSample
//
// Created by Vatsal Patel on 3/21/24.
//

import SwiftUI

struct RoundedCorner: Shape {
var radius: CGFloat = .infinity
var corners: UIRectCorner = .allCorners

func path(in rect: CGRect) -> Path {
let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
return Path(path.cgPath)
}
}

struct Card: View {
var body: some View {
ZStack(alignment:.topLeading) {
RoundedRectangle(cornerRadius: 15)
.fill(Color(red: 0.10, green: 0.10, blue: 0.10))
VStack(alignment: .leading) {
Image("nba")
.resizable()
.aspectRatio(contentMode: .fit)
.clipShape(RoundedCorner(radius: 15, corners: [.topLeft, .topRight]))
.padding(.bottom)
VStack(alignment: .leading, spacing: 10) {
Text(XCS.chasingHistoryNuggetsReachNbaSummitEp31.key)
.font(.callout)
.fontWeight(.semibold)
Text(XCS.afterA47YearWaitTheNuggetsAreNbaChampsAfterAGame5WinVsTheHeatInWhichNikolaJokicClaimedBillRussellNbaFinalsMvpHonors.key)
.font(.caption)
.fontWeight(.medium)
}
.padding(.horizontal, 8)
}
}
.foregroundStyle(.white)
.padding()
.frame(width:350, height: 375)
}
}

#Preview {
Card()
}


// Chasing History: Nuggets reach NBA summit (Ep. 31)
// After a 47-year wait, the Nuggets are NBA champs after a Game 5 win vs. the Heat in which Nikola Jokic claimed Bill Russell NBA Finals MVP honors.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// TopBar.swift
// StringCatalogEnumSample
//
// Created by Vatsal Patel on 3/21/24.
//

import SwiftUI

struct TopBar: View {
var body: some View {
HStack(alignment: .bottom){
Image("logoQuible")
.resizable()
.frame(width: 80, height: 40)
Spacer()
Button {
print("Notification Clicked!")
} label: {
Image(systemName: "bell.fill")
.foregroundStyle(.white)
.frame(width: 40, height: 40)
}
}
.padding(.top, 50)
.padding(.horizontal)
.padding(.bottom, 10)
.background(Color(red: 0.11, green: 0.11, blue: 0.11))
.clipShape(RoundedRectangle(
cornerRadius: 0,
style: .continuous
))
}
}

#Preview {
TopBar()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// ContentView.swift
// StringCatalogEnumSample
//
// Created by Vatsal Patel on 3/21/24.
//

import SwiftUI

struct ContentView: View {
let user = "Aarav"
let noOfBets = 4

var body: some View {
ZStack(alignment: .topLeading) {
Color.black

VStack(alignment: .leading) {
TopBar()
Text(
String(format: NSLocalizedString("welcomeBack", comment: "displayed as a greeting on top of app"), user)
)
.font(.title2)
.fontWeight(.bold)
.foregroundStyle(.white)
.padding()

Text(String.localizedStringWithFormat(NSLocalizedString(XCS.bets.rawValue, comment: ""),noOfBets))
.font(.title2)
.fontWeight(.bold)
.foregroundStyle(.white)
.padding()

Text(XCS.trendingNewsForBasketball.key)
.font(.headline)
.fontWeight(.semibold)
.foregroundStyle(.white)
.padding(.top)
.padding(.horizontal)

VStack{
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 0) {
ForEach(0..<5){ i in
Card()
}
}
}
}
}
}
.ignoresSafeArea()
}
}

#Preview {
ContentView()
}

#Preview("Spanish") {
ContentView()
.environment(\.locale, Locale(identifier: "ES"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This file is generated by XcodeStringEnum. Please do *NOT* update it manually.
// As a common practice, swiftLint is disabled for generated files.
// swiftlint:disable all

import SwiftUI

/// Makes it a bit easier to type.
typealias XCS = XcodeStringKey

/// Generated by StringCatalogEnum, this enum contains all existing Strin Category keys.
enum XcodeStringKey: String, CaseIterable {
/// 'es': "Bienvenido de nuevo, %@"
/// 'en': "Welcome Back, %@"
case welcomeBack
/// No localizations available
case bets

// MARK: - The following cases should be manually replaced in your codebase.

/// 'es': "Después de una espera de 47 años, los Nuggets son campeones de la NBA después de una victoria en el Juego 5 contra el Heat en la que Nikola Jokic reclamó los honores de Jugador Más Valioso de las Finales de la NBA Bill Russell."
case afterA47YearWaitTheNuggetsAreNbaChampsAfterAGame5WinVsTheHeatInWhichNikolaJokicClaimedBillRussellNbaFinalsMvpHonors = "After a 47-year wait, the Nuggets are NBA champs after a Game 5 win vs. the Heat in which Nikola Jokic claimed Bill Russell NBA Finals MVP honors."
/// 'es': "Noticias de actualidad para el baloncesto 🏀"
case trendingNewsForBasketball = "Trending News for Basketball 🏀"
/// 'es': "Persiguiendo la historia: los Nuggets alcanzan la cima de la NBA (EP: 31)"
case chasingHistoryNuggetsReachNbaSummitEp31 = "Chasing History: Nuggets reach NBA summit (EP: 31)"

/// Usage: `SwiftUI.Text(XCS.yourStringCatalogKey.key)`
var key: LocalizedStringKey { LocalizedStringKey(rawValue) }

var string: String { NSLocalizedString(self.rawValue, comment: "Generated localization from String Catalog key: \(key)") }

// var text: String.LocalizationValue { String.LocalizationValue(rawValue) }
}
// swiftlint:enable all
Loading