-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
352dddf
commit de29520
Showing
13 changed files
with
481 additions
and
25 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
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,20 @@ | ||
// | ||
// Info.swift | ||
// MMEX | ||
// | ||
// Created by Lisheng Guan on 2024/9/18. | ||
// | ||
|
||
import Foundation | ||
|
||
struct Info: Identifiable, Codable { | ||
var id: Int64 // ID will be auto-incremented | ||
var name: String // Corresponds to INFONAME | ||
var value: String // Corresponds to INFOVALUE | ||
|
||
init(id: Int64 = 0, name: String, value: String) { | ||
self.id = id | ||
self.name = name | ||
self.value = value | ||
} | ||
} |
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,55 @@ | ||
// | ||
// InfoRepository.swift | ||
// MMEX | ||
// | ||
// Created by Lisheng Guan on 2024/9/18. | ||
// | ||
|
||
import Foundation | ||
import SQLite | ||
|
||
class InfoRepository { | ||
private let db: Connection | ||
|
||
init(db: Connection) { | ||
self.db = db | ||
} | ||
|
||
func createTable() throws { | ||
let infoTable = Table("INFOTABLE_V1") | ||
let id = Expression<Int64>("ID") | ||
let name = Expression<String>("INFONAME") | ||
let value = Expression<String>("INFOVALUE") | ||
|
||
try db.run(infoTable.create(ifNotExists: true) { t in | ||
t.column(id, primaryKey: .autoincrement) | ||
t.column(name, unique: true) | ||
t.column(value) | ||
}) | ||
} | ||
|
||
func fetchInfo(by name: String) -> Info? { | ||
let infoTable = Table("INFOTABLE_V1") | ||
let nameExp = Expression<String>("INFONAME") | ||
let valueExp = Expression<String>("INFOVALUE") | ||
|
||
if let row = try? db.pluck(infoTable.filter(nameExp == name)) { | ||
let id = try row.get(Expression<Int64>("ID")) | ||
let value = try row.get(valueExp) | ||
return Info(id: id, name: name, value: value) | ||
} | ||
return nil | ||
} | ||
|
||
func insertOrUpdate(info: Info) throws { | ||
let infoTable = Table("INFOTABLE_V1") | ||
let nameExp = Expression<String>("INFONAME") | ||
let valueExp = Expression<String>("INFOVALUE") | ||
|
||
if let existing = fetchInfo(by: info.name) { | ||
try db.run(infoTable.filter(nameExp == info.name).update(valueExp <- info.value)) | ||
} else { | ||
try db.run(infoTable.insert(nameExp <- info.name, valueExp <- info.value)) | ||
} | ||
} | ||
} |
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,54 @@ | ||
// | ||
// ManagementView.swift | ||
// MMEX | ||
// | ||
// Created by Lisheng Guan on 2024/9/18. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ManagementView: View { | ||
let databaseURL: URL | ||
@Binding var isDocumentPickerPresented: Bool | ||
|
||
var body: some View { | ||
List { | ||
Section(header: Text("Manage Data")) { | ||
NavigationLink(destination: AccountListView(databaseURL: databaseURL)) { | ||
Text("Manage Accounts") | ||
} | ||
NavigationLink(destination: PayeeListView(databaseURL: databaseURL)) { | ||
Text("Manage Payees") | ||
} | ||
NavigationLink(destination: CategoryListView(databaseURL: databaseURL)) { | ||
Text("Manage Categories") | ||
} | ||
NavigationLink(destination: TransactionListView(databaseURL: databaseURL)) { | ||
Text("Manage Transactions") | ||
} | ||
NavigationLink(destination: CurrencyListView(databaseURL: databaseURL)) { | ||
Text("Manage Currencies") | ||
} | ||
} | ||
|
||
Section(header: Text("Database")) { | ||
Button("Re-open Database") { | ||
isDocumentPickerPresented = true | ||
} | ||
.padding() | ||
.background(Color.blue) | ||
.foregroundColor(.white) | ||
.cornerRadius(10) | ||
} | ||
} | ||
.navigationTitle("Management") | ||
} | ||
} | ||
|
||
#Preview { | ||
ManagementView(databaseURL: URL(string: "path/to/database")!, isDocumentPickerPresented: .constant(false)) | ||
} | ||
|
||
#Preview { | ||
ManagementView(databaseURL: URL(string: "path/to/database")!, isDocumentPickerPresented: .constant(true)) | ||
} |
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,34 @@ | ||
// | ||
// AboutView.swift | ||
// MMEX | ||
// | ||
// Created by Lisheng Guan on 2024/9/18. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct AboutView: View { | ||
var body: some View { | ||
VStack(alignment: .leading, spacing: 20) { | ||
Text("About This App") | ||
.font(.largeTitle) | ||
.fontWeight(.bold) | ||
|
||
Text("This app helps you manage your finances efficiently by tracking transactions, accounts, and generating insights.") | ||
|
||
Text("Credits") | ||
.font(.headline) | ||
|
||
Text("Developed by XYZ Developer") | ||
Text("Special thanks to all open-source contributors!") | ||
|
||
Spacer() | ||
} | ||
.padding() | ||
.navigationTitle("About") | ||
} | ||
} | ||
|
||
#Preview { | ||
AboutView() | ||
} |
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,78 @@ | ||
// | ||
// ContactSupportView.swift | ||
// MMEX | ||
// | ||
// Created by Lisheng Guan on 2024/9/18. | ||
// | ||
|
||
import SwiftUI | ||
|
||
import SwiftUI | ||
|
||
struct ContactSupportView: View { | ||
var body: some View { | ||
List { | ||
Section(header: Text("Contact Support")) { | ||
// Link to the official website | ||
Link(destination: URL(string: "https://moneymanagerex.org/")!) { | ||
HStack { | ||
Image(systemName: "globe") | ||
.foregroundColor(.blue) | ||
Text("Visit Official Website") | ||
} | ||
} | ||
|
||
// Link to email support | ||
Link(destination: URL(string: "mailto:[email protected]")!) { | ||
HStack { | ||
Image(systemName: "envelope") | ||
.foregroundColor(.green) | ||
Text("Email Support") | ||
} | ||
} | ||
|
||
// Link to the forum | ||
Link(destination: URL(string: "https://forum.moneymanagerex.org/")!) { | ||
HStack { | ||
Image(systemName: "person.2.fill") | ||
.foregroundColor(.orange) | ||
Text("User Forum") | ||
} | ||
} | ||
|
||
// Option to report an issue | ||
Link(destination: URL(string: "https://github.com/moneymanagerex/moneymanagerex/issues")!) { | ||
HStack { | ||
Image(systemName: "exclamationmark.triangle") | ||
.foregroundColor(.red) | ||
Text("Report an Issue") | ||
} | ||
} | ||
} | ||
|
||
Section(header: Text("Social Media")) { | ||
// Social media links | ||
Link(destination: URL(string: "https://www.facebook.com/moneymanagerex/")!) { | ||
HStack { | ||
Image(systemName: "logo.facebook") | ||
.foregroundColor(.blue) | ||
Text("Facebook") | ||
} | ||
} | ||
|
||
Link(destination: URL(string: "https://twitter.com/moneymanagerex")!) { | ||
HStack { | ||
Image(systemName: "logo.twitter") | ||
.foregroundColor(.blue) | ||
Text("Twitter") | ||
} | ||
} | ||
} | ||
} | ||
.navigationTitle("Contact Support") | ||
} | ||
} | ||
|
||
#Preview { | ||
ContactSupportView() | ||
} |
Oops, something went wrong.