diff --git a/PlantUML/PlantUMLApp.swift b/PlantUML/PlantUMLApp.swift index ef27688..26201d0 100644 --- a/PlantUML/PlantUMLApp.swift +++ b/PlantUML/PlantUMLApp.swift @@ -18,14 +18,12 @@ struct PlantUMLApp: App { var body: some Scene { DocumentGroup(newDocument: PlantUMLDocument()) { file in if #available(iOS 16, *) { - PlantUMLContentView( - document: PlantUMLDocumentProxy( document: file.$document) ) + PlantUMLContentView( document: PlantUMLDocumentProxy( document: file.$document) ) // [Document based app shows 2 back chevrons on iPad](https://stackoverflow.com/a/74245034/521197) .toolbarRole(.navigationStack) } else { - PlantUMLContentView( - document: PlantUMLDocumentProxy( document: file.$document)) + PlantUMLContentView( document: PlantUMLDocumentProxy( document: file.$document)) } } } diff --git a/PlantUML/PlantUMLContentView.swift b/PlantUML/PlantUMLContentView.swift index cf3e182..0c532f6 100644 --- a/PlantUML/PlantUMLContentView.swift +++ b/PlantUML/PlantUMLContentView.swift @@ -29,6 +29,10 @@ struct PlantUMLContentView: View { @Environment(\.editMode) private var editMode @Environment(\.openURL) private var openURL + @AppStorage("lightTheme") var lightTheme:String = CodeWebView.Theme.chrome.rawValue + @AppStorage("darkTheme") var darkTheme:String = CodeWebView.Theme.monokai.rawValue + @AppStorage("fontSize") var fontSize:Int = 20 + @StateObject var document: PlantUMLDocumentProxy @StateObject private var openAIService = OpenAIService() @@ -40,7 +44,6 @@ struct PlantUMLContentView: View { @State var keyboardTab: String = "general" @State private var isScaleToFit = true - @State private var fontSize = CGFloat(15) @State private var showLine:Bool = false @State private var saving = false @State private var diagramImage:UIImage? @@ -147,10 +150,10 @@ extension PlantUMLContentView { PlantUMLLineEditorView( content: $document.text, mode: .plantuml, - darkTheme: .terminal, - lightTheme: .chrome, + darkTheme: CodeWebView.Theme(rawValue: darkTheme)!, + lightTheme: CodeWebView.Theme(rawValue: lightTheme)!, isReadOnly: false, - fontSize: fontSize + fontSize: CGFloat(fontSize) ) // PlantUMLLineEditorView( text: $document.text, diff --git a/PlantUML/Settings.bundle/Root.plist b/PlantUML/Settings.bundle/Root.plist new file mode 100644 index 0000000..b34de75 --- /dev/null +++ b/PlantUML/Settings.bundle/Root.plist @@ -0,0 +1,255 @@ + + + + + PreferenceSpecifiers + + + Title + Editor + Type + PSGroupSpecifier + + + + DefaultValue + chrome + Key + lightTheme + Title + Light Theme + Titles + + ambiance + chrome + clouds + clouds_midnight + cobalt + crimson_editor + dawn + dracula + dreamweaver + chaos + eclipse + github + gob + gruvbox + idle_fingers + iplastic + katzenmilch + kr_theme + kuroir + merbivore + merbivore_soft + mono_industrial + monokai + nord_dark + pastel_on_dark + solarized_dark + solarized_light + sqlserver + terminal + textmate + tomorrow + tomorrow_night + tomorrow_night_blue + tomorrow_night_bright + tomorrow_night_eighties + twilight + vibrant_ink + xcode + + Type + PSMultiValueSpecifier + Values + + ambiance + chrome + clouds + clouds_midnight + cobalt + crimson_editor + dawn + dracula + dreamweaver + chaos + eclipse + github + gob + gruvbox + idle_fingers + iplastic + katzenmilch + kr_theme + kuroir + merbivore + merbivore_soft + mono_industrial + monokai + nord_dark + pastel_on_dark + solarized_dark + solarized_light + sqlserver + terminal + textmate + tomorrow + tomorrow_night + tomorrow_night_blue + tomorrow_night_bright + tomorrow_night_eighties + twilight + vibrant_ink + xcode + + + + DefaultValue + monokai + Key + darkTheme + Title + Dark Theme + Titles + + ambiance + chrome + clouds + clouds_midnight + cobalt + crimson_editor + dawn + dracula + dreamweaver + chaos + eclipse + github + gob + gruvbox + idle_fingers + iplastic + katzenmilch + kr_theme + kuroir + merbivore + merbivore_soft + mono_industrial + monokai + nord_dark + pastel_on_dark + solarized_dark + solarized_light + sqlserver + terminal + textmate + tomorrow + tomorrow_night + tomorrow_night_blue + tomorrow_night_bright + tomorrow_night_eighties + twilight + vibrant_ink + xcode + + Type + PSMultiValueSpecifier + Values + + ambiance + chrome + clouds + clouds_midnight + cobalt + crimson_editor + dawn + dracula + dreamweaver + chaos + eclipse + github + gob + gruvbox + idle_fingers + iplastic + katzenmilch + kr_theme + kuroir + merbivore + merbivore_soft + mono_industrial + monokai + nord_dark + pastel_on_dark + solarized_dark + solarized_light + sqlserver + terminal + textmate + tomorrow + tomorrow_night + tomorrow_night_blue + tomorrow_night_bright + tomorrow_night_eighties + twilight + vibrant_ink + xcode + + + + Title + AI + Type + PSGroupSpecifier + + + DefaultValue + text-davinci-edit-001 + Key + openaiModel + Title + Model + Titles + + code-davinci-edit-001 + text-davinci-edit-001 + + Type + PSMultiValueSpecifier + Values + + code-davinci-edit-001 + text-davinci-edit-001 + + + + + diff --git a/PlantUML/Settings.bundle/en.lproj/Root.strings b/PlantUML/Settings.bundle/en.lproj/Root.strings new file mode 100644 index 0000000..8cd87b9 Binary files /dev/null and b/PlantUML/Settings.bundle/en.lproj/Root.strings differ diff --git a/PlantUML/Settings.bundle/textformat_size_larger.png b/PlantUML/Settings.bundle/textformat_size_larger.png new file mode 100644 index 0000000..2dc3908 Binary files /dev/null and b/PlantUML/Settings.bundle/textformat_size_larger.png differ diff --git a/PlantUML/Settings.bundle/textformat_size_smaller.png b/PlantUML/Settings.bundle/textformat_size_smaller.png new file mode 100644 index 0000000..9345957 Binary files /dev/null and b/PlantUML/Settings.bundle/textformat_size_smaller.png differ diff --git a/PlantUMLApp.xcodeproj/project.pbxproj b/PlantUMLApp.xcodeproj/project.pbxproj index a0c33c7..d0d7389 100644 --- a/PlantUMLApp.xcodeproj/project.pbxproj +++ b/PlantUMLApp.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ A074F6992A16D40500061398 /* OpenAI.prod.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = A074F6982A16D40500061398 /* OpenAI.prod.xcconfig */; }; A074F69A2A16D40500061398 /* OpenAI.prod.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = A074F6982A16D40500061398 /* OpenAI.prod.xcconfig */; }; A074F69B2A16D40500061398 /* OpenAI.prod.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = A074F6982A16D40500061398 /* OpenAI.prod.xcconfig */; }; + A082CB002A9A68D80055D6D6 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = A082CAFF2A9A68D80055D6D6 /* Settings.bundle */; }; A0943A6F2944A44900342426 /* ScaleToFit+ToggleStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0943A6E2944A44900342426 /* ScaleToFit+ToggleStyle.swift */; }; A09F62DD29DDD08600650C9A /* PlantUMLFramework in Frameworks */ = {isa = PBXBuildFile; productRef = A09F62DC29DDD08600650C9A /* PlantUMLFramework */; }; A09F62DF29DDD08D00650C9A /* PlantUMLKeyboard in Frameworks */ = {isa = PBXBuildFile; productRef = A09F62DE29DDD08D00650C9A /* PlantUMLKeyboard */; }; @@ -75,6 +76,7 @@ A05F2E372A1FFC49007FDF36 /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = ""; }; A068572D29D8B31100E82C2F /* View+Clipboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Clipboard.swift"; sourceTree = ""; }; A074F6982A16D40500061398 /* OpenAI.prod.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = OpenAI.prod.xcconfig; sourceTree = ""; }; + A082CAFF2A9A68D80055D6D6 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = ""; }; A08AA78329561170004DE329 /* View+UIImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+UIImage.swift"; sourceTree = ""; }; A0943A6D29448A1700342426 /* AppStore.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = AppStore.xcassets; sourceTree = ""; }; A0943A6E2944A44900342426 /* ScaleToFit+ToggleStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ScaleToFit+ToggleStyle.swift"; sourceTree = ""; }; @@ -201,6 +203,7 @@ A038DB5F29D489BA0032E312 /* PlantUML+OpenAI.swift */, A0BFBA9C290D551F008340E3 /* Localizable.strings */, A0D3C64F28984A10000838D7 /* Assets.xcassets */, + A082CAFF2A9A68D80055D6D6 /* Settings.bundle */, A0D3C65428984A10000838D7 /* Info.plist */, A0D3C65128984A10000838D7 /* Preview Content */, ); @@ -355,6 +358,7 @@ A0BFBA9A290D551F008340E3 /* Localizable.strings in Resources */, A038DB5C29D452880032E312 /* OpenAI.xcconfig in Resources */, A074F6992A16D40500061398 /* OpenAI.prod.xcconfig in Resources */, + A082CB002A9A68D80055D6D6 /* Settings.bundle in Resources */, A0D3C65028984A10000838D7 /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -607,7 +611,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_ASSET_PATHS = "\"PlantUML/Preview Content\""; DEVELOPMENT_TEAM = 48J595L9BX; ENABLE_PREVIEWS = YES; @@ -644,7 +648,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_ASSET_PATHS = "\"PlantUML/Preview Content\""; DEVELOPMENT_TEAM = 48J595L9BX; ENABLE_PREVIEWS = YES; diff --git a/PlantUMLEditor/Example/CodeViewerExample-iOS/ContentView.swift b/PlantUMLEditor/Example/CodeViewerExample-iOS/ContentView.swift index 428a0c6..169ba80 100644 --- a/PlantUMLEditor/Example/CodeViewerExample-iOS/ContentView.swift +++ b/PlantUMLEditor/Example/CodeViewerExample-iOS/ContentView.swift @@ -13,7 +13,59 @@ struct ContentView: View { @State private var text = """ + @startuml diagram + title mydiagram + + participant Alice as a + participant Bob as b + participant Participant as Foo + actor Actor as Foo1 + boundary Boundary as Foo2 + control Control as Foo3 + entity Entity as Foo4 + database Database as Foo5 + collections Collections as Foo6 + queue Queue as Foo7 + + Foo -> Foo1 : To actor + Foo -> Foo2 : To boundary + Foo -> Foo3 : To control + Foo -> Foo4 : To entity + Foo -> Foo5 : To database + Foo -> Foo6 : To collections + Foo -> Foo7: To queue + + a -> b : ""-> "" + note left: this is a first note + a ->> b : ""->> "" + note right: this is another note + a -\\ b : ""-\\ "" + a -\\\\ b : ""-\\\\"" + a -/ b : ""-/ "" + a -// b : ""-// "" + a ->x b : ""->x "" + a x-> b : ""x-> "" + a o-> b : ""o-> "" + a ->o b : ""->o "" + a o->o b : ""o->o "" + a <-> b : ""<-> "" + a o<->o b : ""o<->o"" + a x<->x b : ""x<->x"" + a ->>o b : ""->>o "" + a -\\o b : ""-\\o "" + a -\\o b : ""-\\\\o"" + a -/o b : ""-/o "" + a -//o b : ""-//o "" + a x->o b : ""x->o "" + note left + a note + can also be defined + on several lines + end note + + + @enduml """ var body: some View {