Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add show expense or income sign option #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dime/Views/BudgetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1688,14 +1688,16 @@ struct FilteredCategoryDayBudgetView: View {
@EnvironmentObject var dataController: DataController
@AppStorage("showCents", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime")) var showCents: Bool = true
@AppStorage("swapTimeLabel", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime")) var swapTimeLabel: Bool = false
@AppStorage("showExpenseOrIncomeSign", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime"))
var showExpenseOrIncomeSign: Bool = true

var body: some View {
VStack(spacing: 0) {
if transactions.count == 0 {
NoResultsView(fullscreen: false)
} else {
ForEach(transactions, id: \.id) { transaction in
SingleTransactionView(transaction: transaction, showCents: showCents, currencySymbol: currencySymbol, currency: currency, swapTimeLabel: swapTimeLabel, future: false)
SingleTransactionView(transaction: transaction, showCents: showCents, currencySymbol: currencySymbol, currency: currency, swapTimeLabel: swapTimeLabel, future: false, showExpenseOrIncomeSign: showExpenseOrIncomeSign)
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion dime/Views/InsightsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,18 @@ struct FilteredDateInsightsView: View {

@AppStorage("swapTimeLabel", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime")) var swapTimeLabel: Bool = false
@AppStorage("showCents", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime")) var showCents: Bool = true

@AppStorage("showExpenseOrIncomeSign", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime"))
var showExpenseOrIncomeSign: Bool = true


var body: some View {
VStack(spacing: 0) {
if transactions.count == 0 {
NoResultsView(fullscreen: false)
}
ForEach(transactions) { transaction in
SingleTransactionView(transaction: transaction, showCents: showCents, currencySymbol: currencySymbol, currency: currency, swapTimeLabel: swapTimeLabel, future: false)
SingleTransactionView(transaction: transaction, showCents: showCents, currencySymbol: currencySymbol, currency: currency, swapTimeLabel: swapTimeLabel, future: false, showExpenseOrIncomeSign: showExpenseOrIncomeSign)
}
}
.frame(maxHeight: .infinity)
Expand Down
20 changes: 15 additions & 5 deletions dime/Views/LogView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,9 @@ struct ListView: View {
var currencySymbol: String {
return Locale.current.localizedCurrencySymbol(forCurrencyCode: currency)!
}

@AppStorage("showExpenseOrIncomeSign", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime"))
var showExpenseOrIncomeSign: Bool = true

@AppStorage("swapTimeLabel", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime")) var swapTimeLabel: Bool = false

Expand Down Expand Up @@ -995,7 +998,7 @@ struct ListView: View {
.padding(.top, 10)

ForEach(filtered.transactions, id: \.id) { transaction in
SingleTransactionView(transaction: transaction, showCents: showCents, currencySymbol: currencySymbol, currency: currency, swapTimeLabel: swapTimeLabel, future: false)
SingleTransactionView(transaction: transaction, showCents: showCents, currencySymbol: currencySymbol, currency: currency, swapTimeLabel: swapTimeLabel, future: false, showExpenseOrIncomeSign: showExpenseOrIncomeSign)
}
}
.contentShape(RoundedRectangle(cornerRadius: 10))
Expand Down Expand Up @@ -1097,6 +1100,9 @@ struct FutureListView: View {
var currencySymbol: String {
return Locale.current.localizedCurrencySymbol(forCurrencyCode: currency)!
}

@AppStorage("showExpenseOrIncomeSign", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime"))
var showExpenseOrIncomeSign: Bool = true

@AppStorage("swapTimeLabel", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime")) var swapTimeLabel: Bool = false

Expand Down Expand Up @@ -1150,7 +1156,7 @@ struct FutureListView: View {
.padding(.horizontal, 10)

ForEach(transactions) { transaction in
SingleTransactionView(transaction: transaction, showCents: showCents, currencySymbol: currencySymbol, currency: currency, swapTimeLabel: swapTimeLabel, future: true)
SingleTransactionView(transaction: transaction, showCents: showCents, currencySymbol: currencySymbol, currency: currency, swapTimeLabel: swapTimeLabel, future: true, showExpenseOrIncomeSign: showExpenseOrIncomeSign)
}
}
.padding(.bottom, 18)
Expand Down Expand Up @@ -1181,6 +1187,7 @@ struct SingleTransactionView: View {
let currency: String
let swapTimeLabel: Bool
let future: Bool
let showExpenseOrIncomeSign: Bool

@State var refreshID = UUID()

Expand Down Expand Up @@ -1278,7 +1285,7 @@ struct SingleTransactionView: View {
.frame(maxWidth: .infinity, alignment: .leading)

if transaction.income {
Text("+\(transactionAmountString)")
Text(showExpenseOrIncomeSign ? "+\(transactionAmountString)" : transactionAmountString)
.font(.system(.title3, design: .rounded).weight(.medium))
.dynamicTypeSize(...DynamicTypeSize.xxxLarge)
.foregroundColor(future ? Color.SubtitleText : Color.IncomeGreen)
Expand All @@ -1287,7 +1294,7 @@ struct SingleTransactionView: View {
.layoutPriority(1)

} else {
Text("-\(transactionAmountString)")
Text(showExpenseOrIncomeSign ? "-\(transactionAmountString)" : transactionAmountString)
.font(.system(.title3, design: .rounded).weight(.medium))
.dynamicTypeSize(...DynamicTypeSize.xxxLarge)
.foregroundColor(future ? Color.SubtitleText : Color.PrimaryText)
Expand Down Expand Up @@ -1706,14 +1713,17 @@ struct FilteredDateView: View {
@AppStorage("swapTimeLabel", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime")) var swapTimeLabel: Bool = false

@AppStorage("showCents", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime")) var showCents: Bool = true

@AppStorage("showExpenseOrIncomeSign", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime"))
var showExpenseOrIncomeSign: Bool = true

var body: some View {
VStack(spacing: 0) {
if transactions.count == 0 {
NoResultsView(fullscreen: true)
}
ForEach(transactions) { transaction in
SingleTransactionView(transaction: transaction, showCents: showCents, currencySymbol: currencySymbol, currency: currency, swapTimeLabel: swapTimeLabel, future: false)
SingleTransactionView(transaction: transaction, showCents: showCents, currencySymbol: currencySymbol, currency: currency, swapTimeLabel: swapTimeLabel, future: false, showExpenseOrIncomeSign: showExpenseOrIncomeSign)
}
}
.frame(maxHeight: .infinity)
Expand Down
9 changes: 9 additions & 0 deletions dime/Views/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ struct SettingsView: View {

@AppStorage("incomeTracking", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime"))
var incomeTracking: Bool = true

@AppStorage("showExpenseOrIncomeSign", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime"))
var showExpenseOrIncomeSign: Bool = true

@AppStorage(
"showUpcomingTransactions", store: UserDefaults(suiteName: "group.com.rafaelsoh.dime"))
Expand Down Expand Up @@ -247,6 +250,12 @@ struct SettingsView: View {
NavigationLink(destination: SettingsWeekStartView()) {
SettingsRowView(systemImage: "calendar", title: "Time Frames", colour: 109)
}

ToggleRow(
icon: "plus.forwardslash.minus", color: "123", text: "Display Expense/income sign", bool: showExpenseOrIncomeSign,
onTap: {
showExpenseOrIncomeSign.toggle()
})
}
.padding(10)
.background(Color.SettingsBackground, in: RoundedRectangle(cornerRadius: 9))
Expand Down