-
Notifications
You must be signed in to change notification settings - Fork 4
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
0e2d4c9
commit a6a7d69
Showing
12 changed files
with
205 additions
and
22 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
37 changes: 37 additions & 0 deletions
37
SwiftRorty.iOS/extensions/LocalizedStringKeyExtension.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,37 @@ | ||
// | ||
// LocalizedStringKeyExtension.swift | ||
// SwiftRorty.iOS | ||
// | ||
// Created by developersancho on 7.03.2022. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
extension LocalizedStringKey { | ||
|
||
/** | ||
Return localized value of thisLocalizedStringKey | ||
*/ | ||
public func toString() -> String { | ||
//use reflection | ||
let mirror = Mirror(reflecting: self) | ||
|
||
//try to find 'key' attribute value | ||
let attributeLabelAndValue = mirror.children.first { (arg0) -> Bool in | ||
let (label, _) = arg0 | ||
if(label == "key"){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
if(attributeLabelAndValue != nil) { | ||
//ask for localization of found key via NSLocalizedString | ||
return String.localizedStringWithFormat(NSLocalizedString(attributeLabelAndValue!.value as! String, comment: "")); | ||
} | ||
else { | ||
return "Swift LocalizedStringKey signature must have changed. @see Apple documentation." | ||
} | ||
} | ||
} |
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,25 @@ | ||
/* | ||
Localizable.strings | ||
SwiftRorty.iOS | ||
|
||
Created by developersancho on 7.03.2022. | ||
|
||
*/ | ||
|
||
"bottom_menu_characters" = "Characters"; | ||
"bottom_menu_favorites" = "Favorites"; | ||
"bottom_menu_settings" = "Settings"; | ||
"toolbar_characters_title" = "Characters"; | ||
"toolbar_favorites_title" = "Favorites"; | ||
"toolbar_settings_title" = "Settings"; | ||
"toolbar_detail_title" = "Detail"; | ||
|
||
"text_theme_mode" = "Theme Mode"; | ||
"text_app_version" = "App Version"; | ||
|
||
"text_name" = "Name"; | ||
"text_species" = "Species"; | ||
"text_gender" = "Gender"; | ||
"text_last_know_location" = "Last Know Location"; | ||
"text_location" = "Location"; | ||
|
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
83 changes: 83 additions & 0 deletions
83
SwiftRorty.iOS/presentation/features/favorites/FavoriteRow.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,83 @@ | ||
// | ||
// FavoriteRow.swift | ||
// SwiftRorty.iOS | ||
// | ||
// Created by developersancho on 6.03.2022. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct FavoriteRow: View { | ||
var dto: CharacterDto | ||
|
||
var body: some View { | ||
HStack { | ||
if let image = dto.image, | ||
let url = URL(string: image) { | ||
AsyncImage(url: url) { image in | ||
image.resizable() | ||
} placeholder: { | ||
Color.gray | ||
} | ||
.aspectRatio(contentMode: .fit) | ||
.frame(width: 80, height: 80) | ||
.clipShape(RoundedRectangle(cornerRadius: 8)) | ||
} else { | ||
RoundedRectangle(cornerRadius: 8) | ||
.frame(width: 80, height: 80) | ||
.foregroundColor(.gray) | ||
} | ||
VStack(alignment: .leading, spacing: 8) { | ||
Text("\(dto.name ?? "Loading...")") | ||
.fontTemplate(AppFontTemplate.body2) | ||
.redacted(reason: dto.name == nil ? .placeholder : []) | ||
Text("\(dto.species ?? "")") | ||
.fontTemplate(AppFontTemplate.body2) | ||
.redacted(reason: dto.species == nil ? .placeholder : []) | ||
HStack { | ||
LazyHStack { | ||
if dto.status == Status.alive { | ||
Circle() | ||
.size(width: 12, height: 12) | ||
.fill(Color.green) | ||
} else if dto.status == Status.dead { | ||
Circle() | ||
.size(width: 12, height: 12) | ||
.fill(Color.red) | ||
} else { | ||
Circle() | ||
.size(width: 12, height: 12) | ||
.fill(Color.gray) | ||
} | ||
|
||
Text("\(dto.status?.rawValue ?? "")") | ||
.fontTemplate(AppFontTemplate.body3) | ||
.redacted(reason: dto.status?.rawValue == nil ? .placeholder : []) | ||
}.frame( | ||
maxWidth: .infinity, | ||
maxHeight: .infinity, | ||
alignment: .leading | ||
) | ||
} | ||
} | ||
.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0)) | ||
.frame( | ||
maxWidth: .infinity, | ||
maxHeight: .infinity, | ||
alignment: .topLeading | ||
) | ||
} | ||
.frame(width: .infinity) | ||
.padding(10) | ||
.background(Color.Card) | ||
.cornerRadius(8) | ||
.shadow(radius: 2) | ||
|
||
} | ||
} | ||
|
||
struct FavoriteRow_Previews: PreviewProvider { | ||
static var previews: some View { | ||
FavoriteRow(dto: CharacterDto.defaultDto()) | ||
} | ||
} |
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
Oops, something went wrong.