Skip to content

Commit 95d64f0

Browse files
authored
Merge pull request #2 from easydev991/updates-1
Обновление 1.1 - Сохраняем сортировку в UserDefaults - При появлении экрана создания/редактирования записи фокусируемся на первом текстфилде - Добавил кнопку "Поделиться приложением"
2 parents f82d6a1 + a882dd9 commit 95d64f0

File tree

7 files changed

+72
-26
lines changed

7 files changed

+72
-26
lines changed

SwiftUI-Days.xcodeproj/project.pbxproj

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
attributes = {
189189
BuildIndependentTargetsInParallel = 1;
190190
LastSwiftUpdateCheck = 1610;
191-
LastUpgradeCheck = 1610;
191+
LastUpgradeCheck = 1630;
192192
TargetAttributes = {
193193
6717F8CD2BBEA5F700A32083 = {
194194
CreatedOnToolsVersion = 15.3;
@@ -291,7 +291,6 @@
291291
buildSettings = {
292292
CODE_SIGN_STYLE = Automatic;
293293
CURRENT_PROJECT_VERSION = 1;
294-
DEVELOPMENT_TEAM = 3PHS45582J;
295294
GENERATE_INFOPLIST_FILE = YES;
296295
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
297296
MARKETING_VERSION = 1.0;
@@ -313,7 +312,6 @@
313312
buildSettings = {
314313
CODE_SIGN_STYLE = Automatic;
315314
CURRENT_PROJECT_VERSION = 1;
316-
DEVELOPMENT_TEAM = 3PHS45582J;
317315
GENERATE_INFOPLIST_FILE = YES;
318316
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
319317
MARKETING_VERSION = 1.0;
@@ -337,7 +335,6 @@
337335
BUNDLE_LOADER = "$(TEST_HOST)";
338336
CODE_SIGN_STYLE = Automatic;
339337
CURRENT_PROJECT_VERSION = 1;
340-
DEVELOPMENT_TEAM = 3PHS45582J;
341338
GENERATE_INFOPLIST_FILE = YES;
342339
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
343340
MARKETING_VERSION = 1.0;
@@ -360,7 +357,6 @@
360357
BUNDLE_LOADER = "$(TEST_HOST)";
361358
CODE_SIGN_STYLE = Automatic;
362359
CURRENT_PROJECT_VERSION = 1;
363-
DEVELOPMENT_TEAM = 3PHS45582J;
364360
GENERATE_INFOPLIST_FILE = YES;
365361
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
366362
MARKETING_VERSION = 1.0;
@@ -415,6 +411,7 @@
415411
COPY_PHASE_STRIP = NO;
416412
DEAD_CODE_STRIPPING = YES;
417413
DEBUG_INFORMATION_FORMAT = dwarf;
414+
DEVELOPMENT_TEAM = 3PHS45582J;
418415
ENABLE_STRICT_OBJC_MSGSEND = YES;
419416
ENABLE_TESTABILITY = YES;
420417
ENABLE_USER_SCRIPT_SANDBOXING = YES;
@@ -481,6 +478,7 @@
481478
COPY_PHASE_STRIP = NO;
482479
DEAD_CODE_STRIPPING = YES;
483480
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
481+
DEVELOPMENT_TEAM = 3PHS45582J;
484482
ENABLE_NS_ASSERTIONS = NO;
485483
ENABLE_STRICT_OBJC_MSGSEND = YES;
486484
ENABLE_USER_SCRIPT_SANDBOXING = YES;
@@ -512,7 +510,6 @@
512510
CURRENT_PROJECT_VERSION = 1;
513511
DEAD_CODE_STRIPPING = YES;
514512
DEVELOPMENT_ASSET_PATHS = "\"SwiftUI-Days/Preview Content\"";
515-
DEVELOPMENT_TEAM = 3PHS45582J;
516513
ENABLE_HARDENED_RUNTIME = YES;
517514
ENABLE_PREVIEWS = YES;
518515
GENERATE_INFOPLIST_FILE = YES;
@@ -534,7 +531,7 @@
534531
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
535532
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
536533
MACOSX_DEPLOYMENT_TARGET = 14.0;
537-
MARKETING_VERSION = 1.0;
534+
MARKETING_VERSION = 1.1;
538535
PRODUCT_BUNDLE_IDENTIFIER = "com.oleg991.SwiftUI-Days";
539536
PRODUCT_NAME = "$(TARGET_NAME)";
540537
SDKROOT = auto;
@@ -558,7 +555,6 @@
558555
CURRENT_PROJECT_VERSION = 1;
559556
DEAD_CODE_STRIPPING = YES;
560557
DEVELOPMENT_ASSET_PATHS = "\"SwiftUI-Days/Preview Content\"";
561-
DEVELOPMENT_TEAM = 3PHS45582J;
562558
ENABLE_HARDENED_RUNTIME = YES;
563559
ENABLE_PREVIEWS = YES;
564560
GENERATE_INFOPLIST_FILE = YES;
@@ -580,7 +576,7 @@
580576
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
581577
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
582578
MACOSX_DEPLOYMENT_TARGET = 14.0;
583-
MARKETING_VERSION = 1.0;
579+
MARKETING_VERSION = 1.1;
584580
PRODUCT_BUNDLE_IDENTIFIER = "com.oleg991.SwiftUI-Days";
585581
PRODUCT_NAME = "$(TARGET_NAME)";
586582
SDKROOT = auto;

SwiftUI-Days.xcodeproj/xcshareddata/xcschemes/SwiftUI-Days.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1610"
3+
LastUpgradeVersion = "1630"
44
version = "1.7">
55
<BuildAction
66
parallelizeBuildables = "YES"

SwiftUI-Days/Models/SortOrder+.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// SortOrder+.swift
3+
// SwiftUI-Days
4+
//
5+
// Created by Oleg991 on 03.04.2025.
6+
//
7+
8+
import SwiftUI
9+
10+
extension SortOrder {
11+
var name: LocalizedStringKey {
12+
switch self {
13+
case .forward: "Old first"
14+
case .reverse: "New first"
15+
}
16+
}
17+
}
18+
19+
// Для использования с `@AppStorage`
20+
extension SortOrder: @retroactive RawRepresentable {
21+
public init?(rawValue: Int) {
22+
switch rawValue {
23+
case 0: self = .forward
24+
case 1: self = .reverse
25+
default: return nil
26+
}
27+
}
28+
29+
public var rawValue: Int {
30+
switch self {
31+
case .forward: 0
32+
case .reverse: 1
33+
}
34+
}
35+
}

SwiftUI-Days/Screens/Detail/EditItemScreen.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct EditItemScreen: View {
1212
@State private var title: String
1313
@State private var details: String
1414
@State private var timestamp: Date
15+
@FocusState private var isFirstFieldFocused
1516
private let oldItem: Item?
1617
private let closeAction: () -> Void
1718

@@ -33,6 +34,8 @@ struct EditItemScreen: View {
3334
placeholder: "Title for the Item",
3435
text: $title
3536
)
37+
.focused($isFirstFieldFocused)
38+
.onAppear { isFirstFieldFocused = true }
3639
EditSectionView(
3740
headerText: "Details",
3841
placeholder: "Details for the Item",
@@ -64,9 +67,6 @@ struct EditItemScreen: View {
6467
.accessibilityIdentifier("saveItemNavButton")
6568
}
6669
}
67-
.onAppear {
68-
UITextField.appearance().clearButtonMode = .whileEditing
69-
}
7070
}
7171

7272
private var navigationTitle: LocalizedStringKey {

SwiftUI-Days/Screens/Main/MainScreen.swift

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import SwiftData
1111
struct MainScreen: View {
1212
@Query private var items: [Item]
1313
@State private var showAddItemSheet = false
14-
@State private var sortOrder = SortOrder.forward
14+
@AppStorage("listSortOrder") private var sortOrder = SortOrder.forward.rawValue
1515
@State private var searchQuery = ""
1616
@State private var editItem: Item?
1717

@@ -39,6 +39,7 @@ struct MainScreen: View {
3939
Picker("Sort Order", selection: $sortOrder) {
4040
ForEach([SortOrder.forward, .reverse], id: \.self) { order in
4141
Text(order.name)
42+
.tag(order.rawValue)
4243
}
4344
}
4445
} label: {
@@ -57,7 +58,7 @@ struct MainScreen: View {
5758
private var itemListView: some View {
5859
ListView(
5960
searchText: searchQuery,
60-
sortOrder: sortOrder,
61+
sortOrder: .init(rawValue: sortOrder) ?? .forward,
6162
editItem: $editItem
6263
)
6364
.navigationDestination(for: Item.self) { ItemScreen(item: $0) }
@@ -92,15 +93,6 @@ struct MainScreen: View {
9293
}
9394
}
9495

95-
extension SortOrder {
96-
var name: LocalizedStringKey {
97-
switch self {
98-
case .forward: "Old first"
99-
case .reverse: "New first"
100-
}
101-
}
102-
}
103-
10496
#if DEBUG
10597
#Preview("Пусто") {
10698
MainScreen()

SwiftUI-Days/Screens/MoreScreen.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import SwiftUI
99
import SwiftData
1010

1111
struct MoreScreen: View {
12+
@Environment(\.locale) private var locale
1213
@Environment(\.modelContext) private var modelContext
1314
@Environment(AppSettings.self) private var appSettings
1415
@Query private var items: [Item]
@@ -23,6 +24,7 @@ struct MoreScreen: View {
2324
Group {
2425
appThemePicker
2526
feedbackButton
27+
shareAppButton
2628
githubButton
2729
if !items.isEmpty {
2830
removeAllDataButton
@@ -64,10 +66,21 @@ struct MoreScreen: View {
6466
.accessibilityIdentifier("sendFeedbackButton")
6567
}
6668

69+
@ViewBuilder
70+
private var shareAppButton: some View {
71+
let languageCode = locale.identifier.split(separator: "_").first == "ru" ? "ru" : "us"
72+
if let appStoreLink = URL(string: "https://apps.apple.com/\(languageCode)/app/id6744068216") {
73+
ShareLink(item: appStoreLink) {
74+
Text("Share the app")
75+
}
76+
.accessibilityIdentifier("shareAppButton")
77+
}
78+
}
79+
6780
@ViewBuilder
6881
private var githubButton: some View {
69-
if let easyDevLink = URL(string: "https://github.com/easydev991/SwiftUI-Days") {
70-
Link(destination: easyDevLink) {
82+
if let githubLink = URL(string: "https://github.com/easydev991/SwiftUI-Days") {
83+
Link(destination: githubLink) {
7184
Text("GitHub page")
7285
}
7386
.accessibilityIdentifier("linkToGitHubPage")

SwiftUI-Days/SupportingFiles/Localizable.xcstrings

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,16 @@
330330
}
331331
}
332332
},
333+
"Share the app" : {
334+
"localizations" : {
335+
"ru" : {
336+
"stringUnit" : {
337+
"state" : "translated",
338+
"value" : "Поделиться приложением"
339+
}
340+
}
341+
}
342+
},
333343
"Sort" : {
334344
"localizations" : {
335345
"ru" : {

0 commit comments

Comments
 (0)