-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
321 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// LinguaApp.swift | ||
// Lingua | ||
// | ||
// Created by Egzon Arifi on 17/08/2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
@main | ||
struct LinguaApp: App { | ||
@StateObject var viewModel = ProjectsViewModel() | ||
var commands: LinguaAppCommands { | ||
LinguaAppCommands(viewModel: viewModel) | ||
} | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
ContentView() | ||
.environmentObject(viewModel) | ||
} | ||
.commands { | ||
commands.aboutApp() | ||
commands.projectCommands | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// | ||
// LinguaAppCommands.swift | ||
// Lingua | ||
// | ||
// Created by Egzon Arifi on 16/10/2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct LinguaAppCommands { | ||
@ObservedObject var viewModel: ProjectsViewModel | ||
|
||
var projectCommands: some Commands { | ||
CommandMenu(Lingua.ProjectMenu.title) { | ||
newProjectButton() | ||
localizeProjectButton() | ||
duplicateProjectButton() | ||
deleteProjectButton() | ||
} | ||
} | ||
} | ||
|
||
// MARK: - AboutApp | ||
extension LinguaAppCommands { | ||
func aboutApp() -> CommandGroup<Button<Text>> { | ||
CommandGroup(replacing: .appInfo) { | ||
Button(Lingua.App.about) { | ||
NSApplication.shared.orderFrontStandardAboutPanel( | ||
options: [ | ||
NSApplication.AboutPanelOptionKey.credits: NSAttributedString( | ||
string: Lingua.App.description, | ||
attributes: [ | ||
NSAttributedString.Key.font: NSFont.boldSystemFont( | ||
ofSize: NSFont.smallSystemFontSize) | ||
] | ||
), | ||
NSApplication.AboutPanelOptionKey( | ||
rawValue: Lingua.App.copyright | ||
): Lingua.App.copyrightYear | ||
] | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Project Menu | ||
private extension LinguaAppCommands { | ||
func newProjectButton() -> some View { | ||
Button(action: { | ||
withAnimation { | ||
viewModel.createNewProject() | ||
} | ||
}) { | ||
Text(Lingua.ProjectMenu.new) | ||
} | ||
.keyboardShortcut("n", modifiers: [.command, .shift]) | ||
} | ||
|
||
func localizeProjectButton() -> some View { | ||
Button(action: { | ||
guard let selectedProject = viewModel.selectedProject else { return } | ||
Task { await viewModel.localizeProject(selectedProject) } | ||
}) { | ||
Text(Lingua.ProjectMenu.localize) | ||
} | ||
.keyboardShortcut("l", modifiers: [.command, .shift]) | ||
.disabled(!(viewModel.selectedProject?.isValid() ?? false)) | ||
} | ||
|
||
func duplicateProjectButton() -> some View { | ||
Button(action: { | ||
guard let selectedProject = viewModel.selectedProject else { return } | ||
viewModel.duplicate(selectedProject) | ||
}) { | ||
Text(Lingua.ProjectMenu.duplicate) | ||
} | ||
.keyboardShortcut("d", modifiers: [.command, .shift]) | ||
.disabled(viewModel.selectedProject == nil) | ||
} | ||
|
||
func deleteProjectButton() -> some View { | ||
Button(action: { | ||
viewModel.projectToDelete = viewModel.selectedProject | ||
viewModel.showDeleteAlert = true | ||
}) { | ||
Text(Lingua.ProjectMenu.delete) | ||
} | ||
.keyboardShortcut(.delete, modifiers: [.command]) | ||
.disabled(viewModel.selectedProject == nil) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
Lingua-App/Lingua/Lingua/Resources/Localization/en.lproj/ProjectMenu.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// This file was generated with Lingua command line tool. Please do not change it! | ||
// Source: https://github.com/poviolabs/Lingua | ||
|
||
"title" = "Project"; | ||
"localize" = "Localize"; | ||
"new" = "New"; | ||
"duplicate" = "Duplicate"; | ||
"delete" = "Delete"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.