Skip to content
Snippets Groups Projects
Commit 0660f805 authored by Kenanja Nuding's avatar Kenanja Nuding
Browse files

#90 Added CustomTextfield and TButton

Added (Toggle) TButton
Added CustomTextfield
Changed to them at all occurences
parent 32319b2e
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,8 @@
1BD2A3D3254B036F00FCA510 /* RSS_Reader.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 1BD2A3D1254B036F00FCA510 /* RSS_Reader.xcdatamodeld */; };
1BD2A3DE254B036F00FCA510 /* RSS_ReaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BD2A3DD254B036F00FCA510 /* RSS_ReaderTests.swift */; };
1BD2A3E9254B036F00FCA510 /* RSS_ReaderUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BD2A3E8254B036F00FCA510 /* RSS_ReaderUITests.swift */; };
7C22853525C2EA1F00FC6EE9 /* CustomTextfield.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C22853425C2EA1F00FC6EE9 /* CustomTextfield.swift */; };
7C22853A25C2FA2300FC6EE9 /* TButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C22853925C2FA2300FC6EE9 /* TButton.swift */; };
7C86307225BC49F9008EB6F0 /* DefaultScreenLayoutModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C86307125BC49F9008EB6F0 /* DefaultScreenLayoutModifier.swift */; };
7C91656425BAF7D90017FE3C /* DefaultListEntryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C91656325BAF7D90017FE3C /* DefaultListEntryView.swift */; };
7C91656C25BB13300017FE3C /* NavigationViewStyleModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C91656B25BB13300017FE3C /* NavigationViewStyleModifier.swift */; };
......@@ -100,6 +102,8 @@
1BD2A3E8254B036F00FCA510 /* RSS_ReaderUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RSS_ReaderUITests.swift; sourceTree = "<group>"; };
1BD2A3EA254B036F00FCA510 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1BD2A484254B177B00FCA510 /* RSS_Reader.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RSS_Reader.entitlements; sourceTree = "<group>"; };
7C22853425C2EA1F00FC6EE9 /* CustomTextfield.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTextfield.swift; sourceTree = "<group>"; };
7C22853925C2FA2300FC6EE9 /* TButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TButton.swift; sourceTree = "<group>"; };
7C86307125BC49F9008EB6F0 /* DefaultScreenLayoutModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultScreenLayoutModifier.swift; sourceTree = "<group>"; };
7C91656325BAF7D90017FE3C /* DefaultListEntryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultListEntryView.swift; sourceTree = "<group>"; };
7C91656B25BB13300017FE3C /* NavigationViewStyleModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationViewStyleModifier.swift; sourceTree = "<group>"; };
......@@ -237,6 +241,8 @@
7CC52C5125C1F8E200DA2100 /* ImageStyle.swift */,
7CC52C5625C20ED900DA2100 /* ImageSize.swift */,
7CC52C5B25C20F2D00DA2100 /* CustomSystemImage.swift */,
7C22853425C2EA1F00FC6EE9 /* CustomTextfield.swift */,
7C22853925C2FA2300FC6EE9 /* TButton.swift */,
);
path = RSS_Reader;
sourceTree = "<group>";
......@@ -438,6 +444,7 @@
1B3F89F925894AD100B6F9CA /* Errors.swift in Sources */,
1BD2A3D3254B036F00FCA510 /* RSS_Reader.xcdatamodeld in Sources */,
1BD2A3C9254B036E00FCA510 /* ContentView.swift in Sources */,
7C22853525C2EA1F00FC6EE9 /* CustomTextfield.swift in Sources */,
7CC52C4825C1C3B100DA2100 /* SystemImage.swift in Sources */,
1BBFF80D25532AD30091541B /* ArticleListRow.swift in Sources */,
EBAB4B9D25680F9F00ABF623 /* AsyncImage.swift in Sources */,
......@@ -465,6 +472,7 @@
7CC52C5725C20ED900DA2100 /* ImageSize.swift in Sources */,
EB7383AA258A70AC0025864B /* SearchPhrase.swift in Sources */,
1BC46CB425576D0C0029D436 /* RefreshableScrollView.swift in Sources */,
7C22853A25C2FA2300FC6EE9 /* TButton.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -57,22 +57,11 @@ struct AddFeedView: View {
})
}
HStack {
HStack {
TextField(
"url_textfield".localized,
text: $text
)
// x Button
Button(action: {
text = ""
}, label: {
Image(systemName: "xmark.circle.fill")
.foregroundColor(.secondary)
.opacity(text == "" ? 0 : 1)
})
}
.textFieldStyle(RoundedBorderTextFieldStyle())
CustomTextfield(placholder: "Enter URL",
text: $text,
on_commit: {
detector.detect(text)
})
.padding(.horizontal, 25.0)
.onChange(of: text) { newValue in
detector.detect(text)
......
......@@ -27,43 +27,20 @@ struct ArticleList: View {
var body: some View {
List {
// Search bar
HStack {
//search bar magnifying glass image
Image(systemName: "magnifyingglass")
//search bar text field
TextField("search_bar_textfield".localized, text: $search_phrase)
// x Button
Button(action: {
search_phrase = ""
}, label: {
Image(systemName: "xmark.circle.fill")
.opacity(search_phrase == "" ? 0 : 1)
})
.buttonStyle(BorderlessButtonStyle())
HStack{
CustomTextfield(image: .search,
placholder: "Search",
text: $search_phrase,
on_commit: {})
// Casing selector
Button(action: {
search_ignore_casing = !search_ignore_casing
TButton(action: {
print("Ignore Casing set to \(search_ignore_casing)")
}, label: {
if search_ignore_casing {
Image(systemName: "textformat.size.larger")
} else {
Image(systemName: "textformat")
}
})
.buttonStyle(BorderlessButtonStyle())
}, image_one: .casing_insensitive, image_two: .casing_sensitive,
bool: $search_ignore_casing)
}
.listRowBackground(Color.clear)
.padding(10)
.foregroundColor(.secondary)
.background(Color(.secondarySystemBackground))
.cornerRadius(10)
/** Create search object */
......
......@@ -9,8 +9,11 @@ import SwiftUI
/// simpel Create-Delete Button shows in case true the minus-label and in case false the plus-label
struct CDButton: View {
///
var action: () -> Void
///
var exits: Bool
var body: some View {
Button(action: {
action()
......
//
// CustomButtonProtocol.swift
// RSS_Reader
//
// Created by Kenanja Nuding on 1/28/21.
//
import Foundation
//
// CustomTextfield.swift
// RSS_Reader
//
// Created by Kenanja Nuding on 1/28/21.
//
import SwiftUI
///
struct CustomTextfield: View {
///
var image: SystemImage?
///
var placholder: String = ""
///
@Binding var text: String
///
var on_commit: () -> Void
///
var button: AnyView?
///
@State private var is_editing: Bool = false
var body: some View {
HStack {
if image != nil {
CustomSystemImage(image: image!, style: .nothing, size: .xsmall)
}
TextField(placholder,
text: $text,
onEditingChanged: { is_editing in
self.is_editing = is_editing
}, onCommit: {
if self.text != "" {
on_commit()
}
})
Button(action: {
self.text = ""
}) {
CustomSystemImage(image: .xmark, style: .nothing, size: .xsmall)
.opacity(self.text == "" ? 0 : 1)
}
.buttonStyle(BorderlessButtonStyle())
if button != nil {
button
}
}
.padding(10)
.foregroundColor(.secondary)
.background(Color(.secondarySystemBackground))
.cornerRadius(10)
}
}
......@@ -67,26 +67,12 @@ struct FeedEditSettingsView: View {
Text("Name")
.padding(.trailing)
// input textfield
HStack {
TextField(feed.name, text: $name) { isEditing in
self.isEditing = isEditing
} onCommit: {
feed.name = self.name
self.name = ""
}
// x-button
Button(action: {
self.name = ""
}) {
Image(systemName: "xmark.circle.fill")
.opacity(self.name == "" ? 0 : 1)
}
.buttonStyle(BorderlessButtonStyle())
}
.padding(10)
.background(Color(.secondarySystemBackground))
.foregroundColor(.secondary)
.cornerRadius(10)
CustomTextfield(placholder: feed.name,
text: $name,
on_commit: {
feed.name = self.name
self.name = ""
})
}
.padding(.horizontal)
......
......@@ -75,26 +75,12 @@ struct FeedProviderSettingsView: View {
Text("Name")
.padding(.trailing)
// input textfield
HStack{
TextField(feed_provider.name, text: $name) { isEditing in
self.isEditing = isEditing
} onCommit: {
feed_provider.name = self.name
self.name = ""
}
// x-button
Button(action: {
self.name = ""
}, label: {
Image(systemName: "xmark.circle.fill")
.opacity(self.name == "" ? 0 : 1)
})
.buttonStyle(BorderlessButtonStyle())
}
.padding(10)
.background(Color(.secondarySystemBackground))
.foregroundColor(.secondary)
.cornerRadius(10)
CustomTextfield(placholder: feed_provider.name,
text: $name,
on_commit: {
feed_provider.name = self.name
self.name = ""
})
}
.padding(.horizontal)
......@@ -103,26 +89,12 @@ struct FeedProviderSettingsView: View {
Text("Abbreviation")
.padding(.trailing)
// input textfield
HStack{
TextField(feed_provider.token, text: $abbreviation) { isEditing in
self.isEditing = isEditing
} onCommit: {
feed_provider.token = self.abbreviation
self.abbreviation = ""
}
// x-button
Button(action: {
self.abbreviation = ""
}, label: {
Image(systemName: "xmark.circle.fill")
.opacity(self.abbreviation == "" ? 0 : 1)
})
.buttonStyle(BorderlessButtonStyle())
}
.padding(10)
.background(Color(.secondarySystemBackground))
.foregroundColor(.secondary)
.cornerRadius(10)
CustomTextfield(placholder: feed_provider.token,
text: $abbreviation,
on_commit: {
feed_provider.token = self.abbreviation
self.abbreviation = ""
})
}
.padding(.horizontal)
......
//
// TButton.swift
// RSS_Reader
//
// Created by Kenanja Nuding on 1/28/21.
//
import SwiftUI
/// simpel Toggle Button shows to different Images
struct TButton: View {
///
var action: () -> Void
///
var image_one: SystemImage
///
var image_two: SystemImage
///
@Binding var bool: Bool
var body: some View {
Button(action: {
bool.toggle()
action()
}, label: {
if (bool) {
CustomSystemImage(image: image_one, style: .nothing, size: .xsmall)
} else {
CustomSystemImage(image: image_two, style: .nothing, size: .xsmall)
}
})
.buttonStyle(BorderlessButtonStyle())
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment