Skip to content

Commit

Permalink
-Languages Screen Impl
Browse files Browse the repository at this point in the history
  • Loading branch information
KhubaibKhan4 committed Dec 22, 2024
1 parent a03cd53 commit c756527
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 23 deletions.
15 changes: 15 additions & 0 deletions Notes/setting/Countries.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Countries.swift
// Notes
//
// Created by Muhammad Khubaib Imtiaz on 22/12/2024.
//

import SwiftUI

struct Country: Identifiable {
let id = UUID()
let name: String
let flag: String
let code: String
}
2 changes: 1 addition & 1 deletion Notes/setting/SettingScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct SettingScreen: View {
Form {
Group {
Section("Localization") {
NavigationLink(destination: SettingView(setting: "Language"), label: {
NavigationLink(destination: CountrySelectorView(), label: {
Label("Languages", systemImage: "globe")
})
}
Expand Down
65 changes: 62 additions & 3 deletions Notes/setting/SettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,68 @@

import SwiftUI

struct SettingView: View {
@State var setting: String
struct CountrySelectorView: View {
@State private var searchText: String = ""
@State private var selectedCountry: Country? = nil
@State private var countries: [Country] = [
Country(name: "United States", flag: "🇺🇸", code: "+1"),
Country(name: "Canada", flag: "🇨🇦", code: "+1"),
Country(name: "United Kingdom", flag: "🇬🇧", code: "+44"),
Country(name: "India", flag: "🇮🇳", code: "+91"),
Country(name: "Germany", flag: "🇩🇪", code: "+49"),
Country(name: "Australia", flag: "🇦🇺", code: "+61"),
Country(name: "Japan", flag: "🇯🇵", code: "+81"),
Country(name: "France", flag: "🇫🇷", code: "+33"),
]

var filteredCountries: [Country] {
if searchText.isEmpty {
return countries
} else {
return countries.filter { $0.name.lowercased().contains(searchText.lowercased()) }
}
}

var body: some View {
Text("Setting \(setting)")
NavigationView {
VStack {
TextField("Search countries", text: $searchText)
.padding(10)
.background(Color(.systemGray6))
.cornerRadius(8)
.padding(.horizontal)

List(filteredCountries) { country in
HStack {
Text(country.flag)
.font(.largeTitle)
VStack(alignment: .leading) {
Text(country.name)
.font(.headline)
Text(country.code)
.font(.subheadline)
.foregroundColor(.gray)
}
Spacer()
if selectedCountry?.id == country.id {
Image(systemName: "checkmark.circle.fill")
.foregroundColor(.blue)
}
}
.contentShape(Rectangle())
.onTapGesture {
selectedCountry = country
}
}
.listStyle(PlainListStyle())
}
.navigationTitle("Select Country")
}
}
}

struct CountrySelectorView_Previews: PreviewProvider {
static var previews: some View {
CountrySelectorView()
}
}
38 changes: 19 additions & 19 deletions Notes/todo/TodoScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@ struct TodoScreen: View {

VStack {

if todoList.isEmpty {
ContentUnavailableView("No Notes Found", systemImage: "text.document.fill", description: Text("There're no notes yet. Add a note to get started."))
} else {
List {
if !completedList.isEmpty {
Section("Complete Tasks") {
ForEach(completedList) { completeItem in
todoRow(for: completeItem)
}
if todoList.isEmpty {
ContentUnavailableView("No Notes Found", systemImage: "text.document.fill", description: Text("There're no notes yet. Add a note to get started."))
} else {
List {
if !completedList.isEmpty {
Section("Complete Tasks") {
ForEach(completedList) { completeItem in
todoRow(for: completeItem)
}
}
if !inCompleteList.isEmpty {
Section("Incomplete Tasks") {
ForEach(inCompleteList) { item in
todoRow(for: item)
}
}

if !inCompleteList.isEmpty {
Section("Incomplete Tasks") {
ForEach(inCompleteList) { item in
todoRow(for: item)
}
}
}.refreshable {
print("Pull to Refresh Init")
}

}.refreshable {
print("Pull to Refresh Init")
}

}

}

.toolbar {
ToolbarItem {
Button {
Expand Down

0 comments on commit c756527

Please sign in to comment.