Skip to content

Commit

Permalink
misc stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
guanlisheng committed Sep 18, 2024
1 parent 352dddf commit de29520
Show file tree
Hide file tree
Showing 13 changed files with 481 additions and 25 deletions.
40 changes: 40 additions & 0 deletions MMEX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
A3462F642C9426F500F79145 /* InsightsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3462F632C9426F500F79145 /* InsightsViewModel.swift */; };
A3462F662C94854800F79145 /* ExportableEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3462F652C94854800F79145 /* ExportableEntity.swift */; };
A3462F6A2C948CDB00F79145 /* ExportableEntityDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3462F692C948CDB00F79145 /* ExportableEntityDocument.swift */; };
A37E7D842C9AC14800B4ECFC /* ManagementView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A37E7D832C9AC14800B4ECFC /* ManagementView.swift */; };
A37E7D862C9AC2D000B4ECFC /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A37E7D852C9AC2D000B4ECFC /* AboutView.swift */; };
A37E7D882C9AC2E600B4ECFC /* VersionInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A37E7D872C9AC2E600B4ECFC /* VersionInfoView.swift */; };
A37E7D8A2C9AC30700B4ECFC /* HelpFAQView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A37E7D892C9AC30700B4ECFC /* HelpFAQView.swift */; };
A37E7D8C2C9AC36800B4ECFC /* LegalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A37E7D8B2C9AC36800B4ECFC /* LegalView.swift */; };
A37E7D8E2C9AC4C900B4ECFC /* PrivacyPolicyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A37E7D8D2C9AC4C900B4ECFC /* PrivacyPolicyView.swift */; };
A37E7D902C9AC4F300B4ECFC /* TermsOfServiceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A37E7D8F2C9AC4F300B4ECFC /* TermsOfServiceView.swift */; };
A37E7D922C9AC60000B4ECFC /* ContactSupportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A37E7D912C9AC60000B4ECFC /* ContactSupportView.swift */; };
A39B1B322C99A084003E5562 /* CurrencyAddView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A39B1B312C99A084003E5562 /* CurrencyAddView.swift */; };
A39B1B342C99A0A8003E5562 /* CurrencyDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A39B1B332C99A0A8003E5562 /* CurrencyDetailView.swift */; };
A39B1B362C99A0C2003E5562 /* CurrencyEditView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A39B1B352C99A0C2003E5562 /* CurrencyEditView.swift */; };
Expand Down Expand Up @@ -64,6 +72,14 @@
A3462F632C9426F500F79145 /* InsightsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InsightsViewModel.swift; sourceTree = "<group>"; };
A3462F652C94854800F79145 /* ExportableEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportableEntity.swift; sourceTree = "<group>"; };
A3462F692C948CDB00F79145 /* ExportableEntityDocument.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportableEntityDocument.swift; sourceTree = "<group>"; };
A37E7D832C9AC14800B4ECFC /* ManagementView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManagementView.swift; sourceTree = "<group>"; };
A37E7D852C9AC2D000B4ECFC /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = "<group>"; };
A37E7D872C9AC2E600B4ECFC /* VersionInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionInfoView.swift; sourceTree = "<group>"; };
A37E7D892C9AC30700B4ECFC /* HelpFAQView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HelpFAQView.swift; sourceTree = "<group>"; };
A37E7D8B2C9AC36800B4ECFC /* LegalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegalView.swift; sourceTree = "<group>"; };
A37E7D8D2C9AC4C900B4ECFC /* PrivacyPolicyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyPolicyView.swift; sourceTree = "<group>"; };
A37E7D8F2C9AC4F300B4ECFC /* TermsOfServiceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsOfServiceView.swift; sourceTree = "<group>"; };
A37E7D912C9AC60000B4ECFC /* ContactSupportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactSupportView.swift; sourceTree = "<group>"; };
A39B1B312C99A084003E5562 /* CurrencyAddView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyAddView.swift; sourceTree = "<group>"; };
A39B1B332C99A0A8003E5562 /* CurrencyDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyDetailView.swift; sourceTree = "<group>"; };
A39B1B352C99A0C2003E5562 /* CurrencyEditView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyEditView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -133,6 +149,13 @@
path = Export;
sourceTree = "<group>";
};
A37E7D7E2C9ABEA900B4ECFC /* Info */ = {
isa = PBXGroup;
children = (
);
path = Info;
sourceTree = "<group>";
};
A39B1B392C9A668F003E5562 /* Accounts */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -194,6 +217,13 @@
isa = PBXGroup;
children = (
A3C142A32C9033E300D3CEC0 /* SettingsView.swift */,
A37E7D852C9AC2D000B4ECFC /* AboutView.swift */,
A37E7D872C9AC2E600B4ECFC /* VersionInfoView.swift */,
A37E7D892C9AC30700B4ECFC /* HelpFAQView.swift */,
A37E7D8B2C9AC36800B4ECFC /* LegalView.swift */,
A37E7D8D2C9AC4C900B4ECFC /* PrivacyPolicyView.swift */,
A37E7D8F2C9AC4F300B4ECFC /* TermsOfServiceView.swift */,
A37E7D912C9AC60000B4ECFC /* ContactSupportView.swift */,
);
path = Settings;
sourceTree = "<group>";
Expand Down Expand Up @@ -267,6 +297,7 @@
A3C142452C89CB1600D3CEC0 /* Views */ = {
isa = PBXGroup;
children = (
A37E7D7E2C9ABEA900B4ECFC /* Info */,
A39B1B3E2C9A6714003E5562 /* Settings */,
A39B1B3D2C9A66F7003E5562 /* Currencies */,
A39B1B3C2C9A66E6003E5562 /* Categories */,
Expand All @@ -276,6 +307,7 @@
A3C142A72C906E0A00D3CEC0 /* CustomNumberPadView.swift */,
A3462F632C9426F500F79145 /* InsightsViewModel.swift */,
A3C142AD2C9134DD00D3CEC0 /* InsightsView.swift */,
A37E7D832C9AC14800B4ECFC /* ManagementView.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -360,12 +392,15 @@
buildActionMask = 2147483647;
files = (
A3C1424C2C8AB52600D3CEC0 /* Currency.swift in Sources */,
A37E7D8E2C9AC4C900B4ECFC /* PrivacyPolicyView.swift in Sources */,
A3C142612C8E9DBF00D3CEC0 /* PayeeAddView.swift in Sources */,
A39B1B382C99A0D8003E5562 /* CurrencyListView.swift in Sources */,
A3C1423E2C89760600D3CEC0 /* AccountListView.swift in Sources */,
A37E7D8C2C9AC36800B4ECFC /* LegalView.swift in Sources */,
A3C1425F2C8DE70300D3CEC0 /* DatabaseManager.swift in Sources */,
A3C1424E2C8B335900D3CEC0 /* Payee.swift in Sources */,
A39B1B322C99A084003E5562 /* CurrencyAddView.swift in Sources */,
A37E7D922C9AC60000B4ECFC /* ContactSupportView.swift in Sources */,
A3C142502C8B366400D3CEC0 /* PayeeListView.swift in Sources */,
A3C142672C8F2AF500D3CEC0 /* Transaction.swift in Sources */,
A3462F642C9426F500F79145 /* InsightsViewModel.swift in Sources */,
Expand All @@ -388,18 +423,23 @@
A3C142AE2C9134DD00D3CEC0 /* InsightsView.swift in Sources */,
A3C142A82C906E0A00D3CEC0 /* CustomNumberPadView.swift in Sources */,
A3363EEB2C93BF62004696C7 /* CurrencyRepository.swift in Sources */,
A37E7D882C9AC2E600B4ECFC /* VersionInfoView.swift in Sources */,
A3462F662C94854800F79145 /* ExportableEntity.swift in Sources */,
A3462F6A2C948CDB00F79145 /* ExportableEntityDocument.swift in Sources */,
A3C142982C8FE62200D3CEC0 /* TransactionListView.swift in Sources */,
A3C142542C8B381400D3CEC0 /* PayeeEditView.swift in Sources */,
A37E7D8A2C9AC30700B4ECFC /* HelpFAQView.swift in Sources */,
A3363EE32C9323A5004696C7 /* CategoryEditView.swift in Sources */,
A3C142652C8ED8EA00D3CEC0 /* AccountEditView.swift in Sources */,
A3C142632C8ED8C000D3CEC0 /* AccountAddView.swift in Sources */,
A3C142A22C90267F00D3CEC0 /* CategoryRepository.swift in Sources */,
A37E7D862C9AC2D000B4ECFC /* AboutView.swift in Sources */,
A3363EE92C9326A1004696C7 /* CategoryListView.swift in Sources */,
A3C142A02C9025D600D3CEC0 /* Category.swift in Sources */,
A3C142A42C9033E300D3CEC0 /* SettingsView.swift in Sources */,
A3363EE52C9323D2004696C7 /* CategoryDetailView.swift in Sources */,
A37E7D842C9AC14800B4ECFC /* ManagementView.swift in Sources */,
A37E7D902C9AC4F300B4ECFC /* TermsOfServiceView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
18 changes: 5 additions & 13 deletions MMEX/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,16 @@ struct ContentView: View {
}
.tag(2)

// Re-open Database Tab
// Combined Management Tab
NavigationView {
VStack {
Button("Re-open Database") {
isDocumentPickerPresented = true
}
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
}
.navigationBarTitle("Re-open Database", displayMode: .inline)
ManagementView(databaseURL: url, isDocumentPickerPresented: $isDocumentPickerPresented)
.navigationBarTitle("Management", displayMode: .inline)
}
.tabItem {
Image(systemName: "folder")
Text("Re-open")
Text("Management")
}
.tag(3) // Tag for the Re-open Database tab
.tag(3)

// Settings Tab
NavigationView {
Expand Down
20 changes: 20 additions & 0 deletions MMEX/Models/Info.swift
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
}
}
55 changes: 55 additions & 0 deletions MMEX/Repositories/InfoRepository.swift
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))
}
}
}
54 changes: 54 additions & 0 deletions MMEX/Views/ManagementView.swift
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))
}
34 changes: 34 additions & 0 deletions MMEX/Views/Settings/AboutView.swift
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()
}
78 changes: 78 additions & 0 deletions MMEX/Views/Settings/ContactSupportView.swift
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()
}
Loading

0 comments on commit de29520

Please sign in to comment.