Skip to content

Commit

Permalink
Merge pull request #3 from iWalletTeam/1.1.6
Browse files Browse the repository at this point in the history
1.1.6
  • Loading branch information
idevnva authored Jun 13, 2023
2 parents d5cbe08 + 22af701 commit acee9fc
Show file tree
Hide file tree
Showing 15 changed files with 277 additions and 66 deletions.
12 changes: 8 additions & 4 deletions iWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
0812FA482A39085A00764C0E /* EditTransactionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0812FA472A39085A00764C0E /* EditTransactionView.swift */; };
08558B8629D35EA40047F959 /* iWalletApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08558B8529D35EA40047F959 /* iWalletApp.swift */; };
08558B8829D35EA40047F959 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08558B8729D35EA40047F959 /* HomeView.swift */; };
08558B8A29D35EA40047F959 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 08558B8929D35EA40047F959 /* Assets.xcassets */; };
Expand Down Expand Up @@ -42,6 +43,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
0812FA472A39085A00764C0E /* EditTransactionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditTransactionView.swift; sourceTree = "<group>"; };
08558B8229D35EA40047F959 /* iWallet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iWallet.app; sourceTree = BUILT_PRODUCTS_DIR; };
08558B8529D35EA40047F959 /* iWalletApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iWalletApp.swift; sourceTree = "<group>"; };
08558B8729D35EA40047F959 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -232,6 +234,7 @@
08D38C4F29D465640078C6C4 /* AddTransactionView.swift */,
08D38C5329D48FE00078C6C4 /* TransactionView.swift */,
08AE95FE29E3236600F8AFA7 /* TransactionCategoryView.swift */,
0812FA472A39085A00764C0E /* EditTransactionView.swift */,
);
path = Transaction;
sourceTree = "<group>";
Expand Down Expand Up @@ -364,6 +367,7 @@
08645FDE2A1E808E0059BDCB /* CategoryTypeModel.swift in Sources */,
0864598E2A20269C006C28AB /* CategoryItemView.swift in Sources */,
08645FE52A1E81E60059BDCB /* CurrencyModel.swift in Sources */,
0812FA482A39085A00764C0E /* EditTransactionView.swift in Sources */,
08558B9C29D37DDC0047F959 /* CategoryView.swift in Sources */,
08558BA229D388080047F959 /* IconPickerView.swift in Sources */,
08558B8629D35EA40047F959 /* iWalletApp.swift in Sources */,
Expand Down Expand Up @@ -508,7 +512,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"iWallet/Preview Content\"";
DEVELOPMENT_TEAM = 4243BL8MP3;
ENABLE_PREVIEWS = YES;
Expand All @@ -524,7 +528,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.5;
MARKETING_VERSION = 1.1.6;
PRODUCT_BUNDLE_IDENTIFIER = com.idevnva.iwallet;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand All @@ -542,7 +546,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"iWallet/Preview Content\"";
DEVELOPMENT_TEAM = 4243BL8MP3;
ENABLE_PREVIEWS = YES;
Expand All @@ -558,7 +562,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.5;
MARKETING_VERSION = 1.1.6;
PRODUCT_BUNDLE_IDENTIFIER = com.idevnva.iwallet;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down
Binary file not shown.
9 changes: 7 additions & 2 deletions iWallet/Extension/ExtensionFloat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import Foundation

// метод возвращает сумму с точками после каждых трех символов
extension Float {
func formattedWithSeparatorAndCurrency() -> String {
func formattedWithSeparatorAndCurrency(roundingNumbers: Bool) -> String {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
formatter.groupingSize = 3
formatter.groupingSeparator = "."
formatter.maximumFractionDigits = 0

if roundingNumbers == true {
formatter.maximumFractionDigits = 0
} else {
formatter.maximumFractionDigits = 2
}

let formattedNumber = formatter.string(from: NSNumber(value: self)) ?? "\(self)"
return formattedNumber
Expand Down
5 changes: 5 additions & 0 deletions iWallet/Localizable/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"https://idevnva.com/" = "https://idevnva.com/iwallet";
"https://t.me/idevnva" = "https://t.me/idevnva";
"App version: 1.1.5" = "App version: 1.1.5";
"Rounding numbers" = "Rounding numbers";

//PreviewCard
"Welcome" = "Welcome!";
Expand Down Expand Up @@ -119,3 +120,7 @@
// PickerCategoryView
"Categories" = "Categories";
"Create category" = "Create category";

// EditTransactionView
"Editing" = "Editing";
"Edit" = "Edit";
5 changes: 5 additions & 0 deletions iWallet/Localizable/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"https://idevnva.com/" = "https://idevnva.com/iwallet";
"https://t.me/idevnva" = "https://t.me/idevnva";
"App version: 1.1.5" = "Версия приложения: 1.1.5";
"Rounding numbers" = "Округление чисел";

//PreviewCard
"Welcome" = "Добро пожаловать!";
Expand Down Expand Up @@ -119,3 +120,7 @@
// PickerCategoryView
"Categories" = "Категории";
"Create category" = "Создать категорию";

// EditTransactionView
"Editing" = "Редактирование";
"Edit" = "Изменить";
4 changes: 3 additions & 1 deletion iWallet/View/Category/CategoryItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import SwiftUI

struct CategoryItemView: View {

@EnvironmentObject var appVM: AppViewModel

let categoryColor: String
let categoryIcon: String
let categoryName: String
Expand Down Expand Up @@ -40,7 +42,7 @@ struct CategoryItemView: View {

Spacer()

Text("\(totalAmount.formattedWithSeparatorAndCurrency()) \(currencySymbol)")
Text("\(totalAmount.formattedWithSeparatorAndCurrency(roundingNumbers: appVM.roundingNumbers)) \(currencySymbol)")
.font(.headline).bold()
.foregroundColor(Color(Colors.mainText))

Expand Down
2 changes: 1 addition & 1 deletion iWallet/View/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct HomeView: View {

ForEach(filteredCategoriesArray, id: \.self) { category in
let totalAmount = category.categoryAmount(type: selectedCategoryType)
NavigationLink(destination: TransactionCategoryView(selectedCategory: .constant(category))) {
NavigationLink(destination: TransactionCategoryView(selectedCategory: category)) {

CategoryItemView(categoryColor: category.color, categoryIcon: category.icon, categoryName: category.name, totalAmount: totalAmount, currencySymbol: appVM.currencySymbol)
}
Expand Down
11 changes: 10 additions & 1 deletion iWallet/View/Setting/SettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ struct SettingView: View {
.cornerRadius(7.5)
Toggle("Vibration", isOn: $appVM.selectedFeedbackHaptic)
}

HStack {
Text(appVM.roundingNumbers ? "0" : "0.0")
.foregroundColor(Color("colorBlack"))
.frame(width: 30, height: 30)
.background(Color(Colors.colorGreen))
.cornerRadius(7.5)
Toggle("Rounding numbers", isOn: $appVM.roundingNumbers)
}
}

Section {
Expand Down Expand Up @@ -125,7 +134,7 @@ struct SettingView: View {
}
VStack {
Image(systemName: "exclamationmark.shield")
Text("App version: 1.1.5")
Text("App version: 1.1.6")
}
.font(.caption2).bold()
.padding()
Expand Down
3 changes: 2 additions & 1 deletion iWallet/View/Templates/BalanceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import SwiftUI

struct BalanceView: View {
@EnvironmentObject var appVM: AppViewModel

let amount: Float
let curren: String
Expand All @@ -20,7 +21,7 @@ struct BalanceView: View {
.background(iconBG)
.cornerRadius(7.5)
Spacer()
Text("\(amount.formattedWithSeparatorAndCurrency()) \(curren)")
Text("\(amount.formattedWithSeparatorAndCurrency(roundingNumbers: appVM.roundingNumbers)) \(curren)")
.font(.headline)
.fontWeight(.bold)
.foregroundColor(Color(Colors.mainText))
Expand Down
6 changes: 2 additions & 4 deletions iWallet/View/Transaction/AddTransactionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct AddTransactionView: View {
Section {
TextField(selectedType == .expense ? "-100 \(appVM.currencySymbol)" : "+100 \(appVM.currencySymbol)", text: $amount)
.font(.title3)
.keyboardType(.numberPad)
.keyboardType(appVM.roundingNumbers ? .numberPad : .decimalPad)
.padding()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color("colorBalanceBG"))
Expand Down Expand Up @@ -170,11 +170,9 @@ struct AddTransactionView: View {
.padding(.top, 20)

}
.navigationTitle("Addendum")
.navigationBarTitleDisplayMode(.inline)
.scrollDismissesKeyboard(.immediately)
.background(Color("colorBG"))
.navigationBarTitle("", displayMode: .inline)
.navigationBarTitle("Addendum", displayMode: .inline)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button {
Expand Down
155 changes: 155 additions & 0 deletions iWallet/View/Transaction/EditTransactionView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
//
// EditTransactionView.swift
// iWallet
//
// Created by Vladislav Novoshinskiy on 13.06.2023.
//

import SwiftUI
import RealmSwift

struct EditTransactionView: View {
@EnvironmentObject private var appVM: AppViewModel
@EnvironmentObject private var transactionVM: TransactionViewModel
@EnvironmentObject private var categoryVM: CategoryViewModel
@Environment(\.dismiss) private var dismiss

@State var selectedTransaction: TransactionItem
@State private var alertAmount: Bool = false

@FocusState private var amountIsFocused: Bool
@FocusState private var noteIsFocused: Bool

let formatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
return formatter
}()

var body: some View {
ScrollView(.vertical, showsIndicators: false) {
VStack(alignment: .leading) {
Section {
TextField(selectedTransaction.type == .expense ? "-100 \(appVM.currencySymbol)" : "+100 \(appVM.currencySymbol)", value: $selectedTransaction.amount, formatter: formatter)
.font(.title3)
.keyboardType(appVM.roundingNumbers ? .numberPad : .decimalPad)
.padding()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color("colorBalanceBG"))
.cornerRadius(10)
.padding(.bottom, 15)
.focused($amountIsFocused)
} header: {
Text("Enter amount:")
.font(.caption).textCase(.uppercase)
.padding(.leading, 10)
}
.onTapGesture {
amountIsFocused.toggle()
}

Section {
TextField("Note", text: $selectedTransaction.note)
.padding()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color("colorBalanceBG"))
.cornerRadius(10)
.focused($noteIsFocused)

ScrollView(.horizontal, showsIndicators: false) {
HStack {
// находит категорию в которую была записана транзакция
let categoryResult = categorySearch(categories: categoryVM.categories)

// находит все заметки в той категории в которую была записанна транзакция
let filterTransaction = transactionVM.filterTransactionsNote(category: categoryResult, transactions: transactionVM.transactions)

ForEach(filterTransaction.reversed(), id: \.self) { notes in
Button {
selectedTransaction.note = notes.note
} label: {
Text(String(notes.note.prefix(20)))
.font(Font.caption)
.foregroundColor(Color(.systemGray2))
.padding(.vertical, 5)
.padding(.horizontal, 10)
.background(
RoundedRectangle(cornerRadius: 7, style: .continuous)
.strokeBorder(Color(.systemGray2))
)
.padding(.bottom, 10)
}
}
}
.padding(.horizontal, 10)
}
} header: {
Text("Enter note:")
.font(.caption).textCase(.uppercase)
.padding(.leading, 10)
}
.onTapGesture {
noteIsFocused.toggle()
}

Section {
HStack {
DatePicker("Date", selection: $selectedTransaction.date, displayedComponents: .date)
}
.pickerStyle(SegmentedPickerStyle())
.padding()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color("colorBalanceBG"))
.cornerRadius(10)
} header: {
Text("Enter date:")
.font(.caption).textCase(.uppercase)
.padding(.leading, 10)
.padding(.top, 10)
}
}
.padding(.horizontal, 15)
.padding(.top, 20)
}
.navigationBarTitle("Editing", displayMode: .inline)
.scrollDismissesKeyboard(.immediately)
.background(Color("colorBG"))
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button {
if selectedTransaction.amount.formattedWithSeparatorAndCurrency(roundingNumbers: appVM.roundingNumbers).count == 0 {
alertAmount = true
} else {
playFeedbackHaptic(appVM.selectedFeedbackHaptic)
dismiss()
}
} label: {
Text("Edit")
}
}
}
.alert("Please enter amount", isPresented: $alertAmount) {
Button("Okay", role: .cancel) { }
}
}

// находит категорию в которую была записана транзакция
func categorySearch(categories: [Category]) -> Category {
var result = Category()

for category in categories {
if category.id == selectedTransaction.categoryId {
if category.hasTransactions(type: selectedTransaction.type) {
result = category
}
}
}
return result
}
}

struct EditTransactionView_Previews: PreviewProvider {
static var previews: some View {
EditTransactionView(selectedTransaction: TransactionItem())
}
}
Loading

0 comments on commit acee9fc

Please sign in to comment.