Skip to content

Commit 906307a

Browse files
fix: share tag (#71)
1 parent d0a33c1 commit 906307a

File tree

5 files changed

+48
-11
lines changed

5 files changed

+48
-11
lines changed

GoMoney/Common/RealmConverter/RealmConverter.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ class RealmConverter {
3434
// Loop through each object in the table
3535
for object in objects {
3636
let row = objectSchema.properties.map { property in
37-
let value = object[property.name] as AnyObject
37+
var value = object[property.name] as AnyObject
38+
if property.name == "tag" {
39+
value = object.tag?.name as AnyObject
40+
}
3841
return sanitizedValue(value.description!)
3942
}
4043
let rowString: String = row.joined(separator: delimiter) + "\n"
@@ -61,7 +64,7 @@ class RealmConverter {
6164
let objects = realm.objects(Expense.self)
6265

6366
for object in objects {
64-
let rowString = "\(object)\n"
67+
let rowString = "\(object.toRemoteTransaction())\n"
6568
fileHandle?.write(rowString.data(using: .utf8)!)
6669
}
6770
fileHandle?.closeFile()
@@ -97,7 +100,10 @@ class RealmConverter {
97100
for object in objects {
98101
var jsonObject = [AnyHashable: Any]()
99102
objectSchema.properties.forEach { property in
100-
let value = object[property.name] as AnyObject
103+
var value = object[property.name] as AnyObject
104+
if property.name == "tag" {
105+
value = object.tag?.name as AnyObject
106+
}
101107
jsonObject[property.name] = value.description!
102108
}
103109
arrayJson.append(jsonObject)

GoMoney/Extensions/Expense+Extension.swift

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,36 @@ extension Expense {
2121
func createShareText() -> String {
2222
return """
2323
~~~~~~~~~~~~~~~~~
24-
Transaction type: \(type)
25-
Category: \(tag)
26-
Amount: \(String(amount))
27-
Date: \(DateFormatter.date.string(from: occuredOn))
28-
Note: \(note)
24+
Transaction type:
25+
\(type.capitalized)
26+
27+
Category
28+
\(tag?.name ?? "")
29+
30+
Amount
31+
\(String(amount))
32+
33+
Date
34+
\(DateFormatter.date.string(from: occuredOn))
35+
36+
Note:
37+
\(note)
2938
~~~~~~~~~~~~~~~~~
3039
Shared from GoMoney with ❤️
3140
"""
3241
}
42+
43+
func toRemoteTransaction() -> RemoteTransaction {
44+
return RemoteTransaction(
45+
_id: _id.stringValue,
46+
type: type,
47+
tag: tag?.name ?? "",
48+
amount: amount,
49+
note: note,
50+
occuredOn: occuredOn,
51+
createdAt: createdAt,
52+
updatedAt: updatedAt)
53+
}
3354
}
3455

3556
extension [Expense] {

GoMoney/Scences/Home/View/MonthlyExpenseView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import UIKit
22

33
class MonthlyExpenseView: UIView {
4-
lazy var label = GMLabel(style: .small)
5-
lazy var amount = GMLabel(style: .largeBold) {
4+
lazy var label = GMLabel(style: .small, isCenter: true)
5+
lazy var amount = GMLabel(style: .regularBold) {
66
$0.textAlignment = .right
77
}
88

GoMoney/Scences/Setting/SettingsManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ enum Setting: String, Equatable {
2525
case .enablePassword: return false
2626
case .syncOnWifi: return false
2727
case .lastSync: return 0
28-
case .currencyUnit: return CurrencyUnit.dollar.rawValue
28+
case .currencyUnit: return CurrencyUnit.dong.rawValue
2929
case .dateFormat: return DateFormat.dmy.rawValue
3030
case .intervalSync: return SyncInterval.min1.rawValue
3131
}

readme.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ A Simple Expense Tracker App 📱 built to demonstrate the use of AutoLayout, Re
111111

112112
<br />
113113

114+
115+
## Resources 🥖
116+
117+
- https://icons8.com/
118+
- https://lottiefiles.com/
119+
- https://www.canva.com/
120+
121+
<br />
122+
123+
114124
## License
115125

116126
```

0 commit comments

Comments
 (0)