Refactoring. Change avatar size in autocomplete.
This commit is contained in:
parent
39d4214097
commit
88d8a99fcb
|
@ -77,7 +77,7 @@
|
||||||
F87AEB942986C51B00434FB6 /* AppConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = F87AEB932986C51B00434FB6 /* AppConstants.swift */; };
|
F87AEB942986C51B00434FB6 /* AppConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = F87AEB932986C51B00434FB6 /* AppConstants.swift */; };
|
||||||
F87AEB972986D16D00434FB6 /* AuthorisationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = F87AEB962986D16D00434FB6 /* AuthorisationError.swift */; };
|
F87AEB972986D16D00434FB6 /* AuthorisationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = F87AEB962986D16D00434FB6 /* AuthorisationError.swift */; };
|
||||||
F8864CE929ACAF820020C534 /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8864CE829ACAF820020C534 /* TextView.swift */; };
|
F8864CE929ACAF820020C534 /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8864CE829ACAF820020C534 /* TextView.swift */; };
|
||||||
F8864CEB29ACBAA80020C534 /* TextFieldViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8864CEA29ACBAA80020C534 /* TextFieldViewModel.swift */; };
|
F8864CEB29ACBAA80020C534 /* TextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8864CEA29ACBAA80020C534 /* TextModel.swift */; };
|
||||||
F8864CEF29ACE90B0020C534 /* UIFont+Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8864CEE29ACE90B0020C534 /* UIFont+Font.swift */; };
|
F8864CEF29ACE90B0020C534 /* UIFont+Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8864CEE29ACE90B0020C534 /* UIFont+Font.swift */; };
|
||||||
F8864CF129ACFFB80020C534 /* View+Keyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8864CF029ACFFB80020C534 /* View+Keyboard.swift */; };
|
F8864CF129ACFFB80020C534 /* View+Keyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8864CF029ACFFB80020C534 /* View+Keyboard.swift */; };
|
||||||
F886F257297859E300879356 /* CacheImageService.swift in Sources */ = {isa = PBXBuildFile; fileRef = F886F256297859E300879356 /* CacheImageService.swift */; };
|
F886F257297859E300879356 /* CacheImageService.swift in Sources */ = {isa = PBXBuildFile; fileRef = F886F256297859E300879356 /* CacheImageService.swift */; };
|
||||||
|
@ -223,7 +223,7 @@
|
||||||
F87AEB932986C51B00434FB6 /* AppConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppConstants.swift; sourceTree = "<group>"; };
|
F87AEB932986C51B00434FB6 /* AppConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppConstants.swift; sourceTree = "<group>"; };
|
||||||
F87AEB962986D16D00434FB6 /* AuthorisationError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthorisationError.swift; sourceTree = "<group>"; };
|
F87AEB962986D16D00434FB6 /* AuthorisationError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthorisationError.swift; sourceTree = "<group>"; };
|
||||||
F8864CE829ACAF820020C534 /* TextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = "<group>"; };
|
F8864CE829ACAF820020C534 /* TextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = "<group>"; };
|
||||||
F8864CEA29ACBAA80020C534 /* TextFieldViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldViewModel.swift; sourceTree = "<group>"; };
|
F8864CEA29ACBAA80020C534 /* TextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextModel.swift; sourceTree = "<group>"; };
|
||||||
F8864CEE29ACE90B0020C534 /* UIFont+Font.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIFont+Font.swift"; sourceTree = "<group>"; };
|
F8864CEE29ACE90B0020C534 /* UIFont+Font.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIFont+Font.swift"; sourceTree = "<group>"; };
|
||||||
F8864CF029ACFFB80020C534 /* View+Keyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Keyboard.swift"; sourceTree = "<group>"; };
|
F8864CF029ACFFB80020C534 /* View+Keyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Keyboard.swift"; sourceTree = "<group>"; };
|
||||||
F886F256297859E300879356 /* CacheImageService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CacheImageService.swift; sourceTree = "<group>"; };
|
F886F256297859E300879356 /* CacheImageService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CacheImageService.swift; sourceTree = "<group>"; };
|
||||||
|
@ -450,6 +450,7 @@
|
||||||
F83901A2295D863B00456AE2 /* Widgets */ = {
|
F83901A2295D863B00456AE2 /* Widgets */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
F8864CF229AD05420020C534 /* TextView */,
|
||||||
F83901A5295D8EC000456AE2 /* LabelIcon.swift */,
|
F83901A5295D8EC000456AE2 /* LabelIcon.swift */,
|
||||||
F85D4972296406E700751DF7 /* BottomRight.swift */,
|
F85D4972296406E700751DF7 /* BottomRight.swift */,
|
||||||
F85D497629640A5200751DF7 /* ImageRow.swift */,
|
F85D497629640A5200751DF7 /* ImageRow.swift */,
|
||||||
|
@ -470,7 +471,6 @@
|
||||||
F876418A298AC1B80057D362 /* NoDataView.swift */,
|
F876418A298AC1B80057D362 /* NoDataView.swift */,
|
||||||
F86FB554298BF83F000131F0 /* FavouriteTouch.swift */,
|
F86FB554298BF83F000131F0 /* FavouriteTouch.swift */,
|
||||||
F8FA991F299FDDC3007AB130 /* TextInputField.swift */,
|
F8FA991F299FDDC3007AB130 /* TextInputField.swift */,
|
||||||
F8864CE829ACAF820020C534 /* TextView.swift */,
|
|
||||||
);
|
);
|
||||||
path = Widgets;
|
path = Widgets;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -540,6 +540,15 @@
|
||||||
path = Subviews;
|
path = Subviews;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
F8864CF229AD05420020C534 /* TextView */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
F8864CEA29ACBAA80020C534 /* TextModel.swift */,
|
||||||
|
F8864CE829ACAF820020C534 /* TextView.swift */,
|
||||||
|
);
|
||||||
|
path = TextView;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
F88ABD9029686F00004EF61E /* Cache */ = {
|
F88ABD9029686F00004EF61E /* Cache */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
@ -698,7 +707,6 @@
|
||||||
children = (
|
children = (
|
||||||
F878842029A494E3003CFAD2 /* Subviews */,
|
F878842029A494E3003CFAD2 /* Subviews */,
|
||||||
F88ABD9329687CA4004EF61E /* ComposeView.swift */,
|
F88ABD9329687CA4004EF61E /* ComposeView.swift */,
|
||||||
F8864CEA29ACBAA80020C534 /* TextFieldViewModel.swift */,
|
|
||||||
);
|
);
|
||||||
path = ComposeView;
|
path = ComposeView;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -913,7 +921,7 @@
|
||||||
F8FA9920299FDDC3007AB130 /* TextInputField.swift in Sources */,
|
F8FA9920299FDDC3007AB130 /* TextInputField.swift in Sources */,
|
||||||
F86A4303299A9AF500DF7645 /* TipsStore.swift in Sources */,
|
F86A4303299A9AF500DF7645 /* TipsStore.swift in Sources */,
|
||||||
F8C5E56229892CC300ADF6A7 /* FirstAppear.swift in Sources */,
|
F8C5E56229892CC300ADF6A7 /* FirstAppear.swift in Sources */,
|
||||||
F8864CEB29ACBAA80020C534 /* TextFieldViewModel.swift in Sources */,
|
F8864CEB29ACBAA80020C534 /* TextModel.swift in Sources */,
|
||||||
F8C14394296AF21B001FE31D /* Double+Round.swift in Sources */,
|
F8C14394296AF21B001FE31D /* Double+Round.swift in Sources */,
|
||||||
F83CBEFB298298A1002972C8 /* ImageCarouselPicture.swift in Sources */,
|
F83CBEFB298298A1002972C8 /* ImageCarouselPicture.swift in Sources */,
|
||||||
F89A46DC296EAACE0062125F /* SettingsView.swift in Sources */,
|
F89A46DC296EAACE0062125F /* SettingsView.swift in Sources */,
|
||||||
|
@ -1051,7 +1059,7 @@
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 39;
|
CURRENT_PROJECT_VERSION = 40;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
|
@ -1088,7 +1096,7 @@
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 39;
|
CURRENT_PROJECT_VERSION = 40;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
|
|
|
@ -16,7 +16,7 @@ struct ComposeView: View {
|
||||||
|
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
|
||||||
@StateObject private var textFieldViewModel: TextFieldViewModel
|
@StateObject private var textModel: TextModel
|
||||||
|
|
||||||
@State private var isKeyboardPresented = false
|
@State private var isKeyboardPresented = false
|
||||||
@State private var isSensitive = false
|
@State private var isSensitive = false
|
||||||
|
@ -66,7 +66,7 @@ struct ComposeView: View {
|
||||||
private let keyboardFontTextSize = 16.0
|
private let keyboardFontTextSize = 16.0
|
||||||
|
|
||||||
public init(statusViewModel: StatusModel? = nil) {
|
public init(statusViewModel: StatusModel? = nil) {
|
||||||
_textFieldViewModel = StateObject(wrappedValue: .init())
|
_textModel = StateObject(wrappedValue: .init())
|
||||||
self.statusViewModel = statusViewModel
|
self.statusViewModel = statusViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +103,9 @@ struct ComposeView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
self.textFieldViewModel.client = self.client
|
self.textModel.client = self.client
|
||||||
}
|
}
|
||||||
.onChange(of: self.textFieldViewModel.text) { newValue in
|
.onChange(of: self.textModel.text) { newValue in
|
||||||
self.refreshScreenState()
|
self.refreshScreenState()
|
||||||
}
|
}
|
||||||
.onChange(of: self.selectedItems) { selectedItem in
|
.onChange(of: self.selectedItems) { selectedItem in
|
||||||
|
@ -226,8 +226,8 @@ struct ComposeView: View {
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private func statusTextView() -> some View {
|
private func statusTextView() -> some View {
|
||||||
TextView($textFieldViewModel.text, getTextView: { textView in
|
TextView($textModel.text, getTextView: { textView in
|
||||||
self.textFieldViewModel.textView = textView
|
self.textModel.textView = textView
|
||||||
})
|
})
|
||||||
.placeholder(self.placeholder())
|
.placeholder(self.placeholder())
|
||||||
.padding(.horizontal, 8)
|
.padding(.horizontal, 8)
|
||||||
|
@ -335,27 +335,27 @@ struct ComposeView: View {
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private func autocompleteToolbar() -> some View {
|
private func autocompleteToolbar() -> some View {
|
||||||
if !textFieldViewModel.mentionsSuggestions.isEmpty || !textFieldViewModel.tagsSuggestions.isEmpty {
|
if !textModel.mentionsSuggestions.isEmpty || !textModel.tagsSuggestions.isEmpty {
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
LazyHStack {
|
LazyHStack {
|
||||||
if !textFieldViewModel.mentionsSuggestions.isEmpty {
|
if !textModel.mentionsSuggestions.isEmpty {
|
||||||
ForEach(textFieldViewModel.mentionsSuggestions, id: \.id) { account in
|
ForEach(textModel.mentionsSuggestions, id: \.id) { account in
|
||||||
Button {
|
Button {
|
||||||
textFieldViewModel.selectMentionSuggestion(account: account)
|
textModel.selectMentionSuggestion(account: account)
|
||||||
} label: {
|
} label: {
|
||||||
UsernameRow(
|
UsernameRow(
|
||||||
accountId: account.id,
|
accountId: account.id,
|
||||||
accountAvatar: account.avatar,
|
accountAvatar: account.avatar,
|
||||||
accountDisplayName: account.displayNameWithoutEmojis,
|
accountDisplayName: account.displayNameWithoutEmojis,
|
||||||
accountUsername: account.acct,
|
accountUsername: account.acct,
|
||||||
size: .mini)
|
size: .comment)
|
||||||
.padding(.trailing, 8)
|
.padding(.trailing, 8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ForEach(textFieldViewModel.tagsSuggestions, id: \.url) { tag in
|
ForEach(textModel.tagsSuggestions, id: \.url) { tag in
|
||||||
Button {
|
Button {
|
||||||
textFieldViewModel.selectHashtagSuggestion(tag: tag)
|
textModel.selectHashtagSuggestion(tag: tag)
|
||||||
} label: {
|
} label: {
|
||||||
Text("#\(tag.name)")
|
Text("#\(tag.name)")
|
||||||
.font(.callout)
|
.font(.callout)
|
||||||
|
@ -420,20 +420,20 @@ struct ComposeView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
self.textFieldViewModel.append(content: "#")
|
self.textModel.append(content: "#")
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "number")
|
Image(systemName: "number")
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
self.textFieldViewModel.append(content: "@")
|
self.textModel.append(content: "@")
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "at")
|
Image(systemName: "at")
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
Text("\(self.applicationState.statusMaxCharacters - textFieldViewModel.text.string.utf16.count)")
|
Text("\(self.applicationState.statusMaxCharacters - textModel.text.string.utf16.count)")
|
||||||
.foregroundColor(.lightGrayColor)
|
.foregroundColor(.lightGrayColor)
|
||||||
.font(.system(size: self.keyboardFontTextSize))
|
.font(.system(size: self.keyboardFontTextSize))
|
||||||
}
|
}
|
||||||
|
@ -449,7 +449,7 @@ struct ComposeView: View {
|
||||||
|
|
||||||
private func isPublishButtonDisabled() -> Bool {
|
private func isPublishButtonDisabled() -> Bool {
|
||||||
// Publish always disabled when there is not status text.
|
// Publish always disabled when there is not status text.
|
||||||
if self.textFieldViewModel.text.string.isEmpty {
|
if self.textModel.text.string.isEmpty {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ struct ComposeView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func isInteractiveDismissDisabled() -> Bool {
|
private func isInteractiveDismissDisabled() -> Bool {
|
||||||
if self.textFieldViewModel.text.string.isEmpty == false {
|
if self.textModel.text.string.isEmpty == false {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,7 +597,7 @@ struct ComposeView: View {
|
||||||
|
|
||||||
private func createStatus() -> Pixelfed.Statuses.Components {
|
private func createStatus() -> Pixelfed.Statuses.Components {
|
||||||
return Pixelfed.Statuses.Components(inReplyToId: self.statusViewModel?.id,
|
return Pixelfed.Statuses.Components(inReplyToId: self.statusViewModel?.id,
|
||||||
text: self.textFieldViewModel.text.string,
|
text: self.textModel.text.string,
|
||||||
spoilerText: self.isSensitive ? self.spoilerText : String.empty(),
|
spoilerText: self.isSensitive ? self.spoilerText : String.empty(),
|
||||||
mediaIds: self.photosAttachment.getUploadedPhotoIds(),
|
mediaIds: self.photosAttachment.getUploadedPhotoIds(),
|
||||||
visibility: self.visibility,
|
visibility: self.visibility,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import SwiftUI
|
||||||
import PixelfedKit
|
import PixelfedKit
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
public class TextFieldViewModel: NSObject, ObservableObject {
|
public class TextModel: NSObject, ObservableObject {
|
||||||
var client: Client?
|
var client: Client?
|
||||||
var textView: UITextView?
|
var textView: UITextView?
|
||||||
|
|
||||||
|
@ -120,7 +120,9 @@ public class TextFieldViewModel: NSObject, ObservableObject {
|
||||||
text.removeAttribute(.link, range: range)
|
text.removeAttribute(.link, range: range)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch { }
|
} catch {
|
||||||
|
ErrorService.shared.handle(error, message: "Error during composing attribute string.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func loadAutoCompleteResults(query: String) {
|
private func loadAutoCompleteResults(query: String) {
|
||||||
|
@ -145,7 +147,9 @@ public class TextFieldViewModel: NSObject, ObservableObject {
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} catch { }
|
} catch {
|
||||||
|
ErrorService.shared.handle(error, message: "Error during downloading autocomplete.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue