-
Notifications
You must be signed in to change notification settings - Fork 0
Develop #9
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
Merged
Merged
Develop #9
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
00700cc
docs(README): Rewrite and update README in English with new details
EnesEfeTokta 2e8c1f9
feat(*.xaml, *.cs): Add feedback form with type selection and file up…
EnesEfeTokta 2e62f8f
feat(*.xaml, *.cs): Add notification system with view model and UI up…
EnesEfeTokta f7c7c51
refactor(*.cs): Refactor property and organize usings in view models
EnesEfeTokta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,19 @@ | ||
| using System.ComponentModel; | ||
|
|
||
| namespace FinTrack.Enums | ||
| { | ||
| public enum FeedbackTypes | ||
| { | ||
| [Description("Bug Report")] | ||
| BugReport, | ||
|
|
||
| [Description("Feature Request")] | ||
| FeatureRequest, | ||
|
|
||
| [Description("General Feedback")] | ||
| GeneralFeedback, | ||
|
|
||
| [Description("Other")] | ||
| Other | ||
| } | ||
| } |
This file contains hidden or 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,10 @@ | ||
| namespace FinTrack.Enums | ||
| { | ||
| public enum NotificationType | ||
| { | ||
| Suggestion, | ||
| GoalAchieved, | ||
| Warning, | ||
| General | ||
| } | ||
| } |
This file contains hidden or 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,44 @@ | ||
| using System.ComponentModel; | ||
| using System.Globalization; | ||
| using System.Windows; | ||
| using System.Windows.Data; | ||
|
|
||
| namespace FinTrack.Helpers | ||
| { | ||
| public class EnumToDescriptionConverter : IValueConverter | ||
| { | ||
| public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| if (value is not Enum enumValue) | ||
| return value; | ||
|
|
||
| return GetEnumDescription(enumValue); | ||
| } | ||
|
|
||
| public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| if (value is string description) | ||
| { | ||
| foreach (Enum enumValue in Enum.GetValues(targetType)) | ||
| { | ||
| if (GetEnumDescription(enumValue) == description) | ||
| { | ||
| return enumValue; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return DependencyProperty.UnsetValue; | ||
| } | ||
|
|
||
| private string GetEnumDescription(Enum enumObj) | ||
| { | ||
| var fieldInfo = enumObj.GetType().GetField(enumObj.ToString()); | ||
| if (fieldInfo == null) return enumObj.ToString(); | ||
|
|
||
| var attributes = (DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false); | ||
|
|
||
| return attributes.Length > 0 ? attributes[0].Description : enumObj.ToString(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,35 @@ | ||
| using CommunityToolkit.Mvvm.ComponentModel; | ||
| using FinTrack.Enums; | ||
|
|
||
| namespace FinTrack.Models.Notification | ||
| { | ||
| public partial class NotificationModel : ObservableObject | ||
| { | ||
| [ObservableProperty] | ||
| private string title = string.Empty; | ||
|
|
||
| [ObservableProperty] | ||
| private string message = string.Empty; | ||
|
|
||
| [ObservableProperty] | ||
| private string timestamp = string.Empty; | ||
|
|
||
| [ObservableProperty] | ||
| private NotificationType type; | ||
|
|
||
| [ObservableProperty] | ||
| [NotifyPropertyChangedFor(nameof(isUnread))] | ||
| private bool isRead = false; | ||
|
|
||
| public bool isUnread => !IsRead; | ||
|
|
||
| public NotificationModel(string title, string message, string? timestamp, NotificationType type, bool _isRead = false) | ||
| { | ||
| Title = title; | ||
| Message = message; | ||
| Type = type; | ||
| Timestamp = timestamp ?? DateTime.Now.ToString(); | ||
| isRead = _isRead; | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,8 +1,108 @@ | ||
| using CommunityToolkit.Mvvm.ComponentModel; | ||
| using CommunityToolkit.Mvvm.Input; | ||
| using FinTrack.Enums; | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Win32; | ||
| using System.Diagnostics; | ||
| using System.Windows; | ||
|
|
||
| namespace FinTrack.ViewModels | ||
| { | ||
| public partial class FeedbackViewModel : ObservableObject | ||
| { | ||
| [ObservableProperty] | ||
| private string? inputSubject; | ||
|
|
||
| [ObservableProperty] | ||
| private FeedbackTypes selectedFeedbackType; | ||
|
|
||
| [ObservableProperty] | ||
| private string? inputDescription; | ||
|
|
||
| [ObservableProperty] | ||
| private string? selectedFilePath; | ||
|
|
||
| public IEnumerable<FeedbackTypes> FeedbackTypes { get; } | ||
|
|
||
| private readonly ILogger<FeedbackViewModel> _logger; | ||
|
|
||
| public FeedbackViewModel(ILogger<FeedbackViewModel> logger) | ||
| { | ||
| _logger = logger; | ||
|
|
||
| FeedbackTypes = Enum.GetValues(typeof(FeedbackTypes)).Cast<FeedbackTypes>(); | ||
| SelectedFeedbackType = FeedbackTypes.FirstOrDefault(); | ||
| } | ||
|
|
||
| [RelayCommand(CanExecute = nameof(CanSendFeedback))] | ||
| private void SendFeedback() | ||
| { | ||
| string subject = InputSubject ?? "The title has been left blank."; | ||
| string description = InputDescription ?? "The description has been left blank."; | ||
| string filePath = SelectedFilePath ?? "No file selected."; | ||
| string feedbackType = SelectedFeedbackType.ToString(); | ||
|
|
||
| string feedbackMessage = $"Subject: {subject}\n" + | ||
| $"Type: {feedbackType}\n" + | ||
| $"Description: {description}\n" + | ||
| $"File Path: {filePath}"; | ||
|
|
||
| // TODO: feedbackMessage should be sent to a server or an email... | ||
|
|
||
| MessageBox.Show(feedbackMessage, "Feedback Submitted", MessageBoxButton.OK, MessageBoxImage.Information); | ||
| _logger.LogInformation("Feedback submitted: Subject: {Subject}, Type: {Type}, Description: {Description}, File Path: {FilePath}", | ||
| subject, feedbackType, description, filePath); | ||
|
|
||
| ClearForm(); | ||
| } | ||
|
|
||
| [RelayCommand] | ||
| private void BrowseFile() | ||
| { | ||
| var openFileDialog = new OpenFileDialog | ||
| { | ||
| Title = "Select a file to attach", | ||
| Filter = "Image Files (*.png;*.jpg;*.jpeg)|*.png;*.jpg;*.jpeg|All Files (*.*)|*.*" | ||
| }; | ||
|
|
||
| if (openFileDialog.ShowDialog() == true) | ||
| { | ||
| SelectedFilePath = openFileDialog.FileName; | ||
| _logger.LogInformation("Seçilen dosya: {FilePath}", SelectedFilePath); | ||
| } | ||
| } | ||
|
|
||
| [RelayCommand] | ||
| private void OpenLink(string? url) | ||
| { | ||
| if (string.IsNullOrEmpty(url) || url == "#") return; | ||
|
|
||
| try | ||
| { | ||
| Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| MessageBox.Show($"Link açılamadı: {ex.Message}", "Hata", MessageBoxButton.OK, MessageBoxImage.Error); | ||
| _logger.LogError(ex, "Link açma hatası: {Url}", url); | ||
| } | ||
| } | ||
|
|
||
| private bool CanSendFeedback() | ||
| { | ||
| return !string.IsNullOrWhiteSpace(InputSubject) && | ||
| !string.IsNullOrWhiteSpace(InputDescription); | ||
| } | ||
|
|
||
| partial void OnInputSubjectChanged(string? value) => SendFeedbackCommand.NotifyCanExecuteChanged(); | ||
| partial void OnInputDescriptionChanged(string? value) => SendFeedbackCommand.NotifyCanExecuteChanged(); | ||
|
|
||
| private void ClearForm() | ||
| { | ||
| InputSubject = string.Empty; | ||
| InputDescription = string.Empty; | ||
| SelectedFilePath = null; | ||
| SelectedFeedbackType = FeedbackTypes.FirstOrDefault(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 | ||||
|---|---|---|---|---|---|---|
| @@ -1,8 +1,96 @@ | ||||||
| using CommunityToolkit.Mvvm.ComponentModel; | ||||||
| using CommunityToolkit.Mvvm.Input; | ||||||
| using FinTrack.Enums; | ||||||
| using FinTrack.Models.Notification; | ||||||
| using Microsoft.Extensions.Logging; | ||||||
| using System.Collections.ObjectModel; | ||||||
|
|
||||||
| namespace FinTrack.ViewModels | ||||||
| { | ||||||
| public partial class NotificationViewModel : ObservableObject | ||||||
| { | ||||||
| [ObservableProperty] | ||||||
| private ObservableCollection<NotificationModel> notifications; | ||||||
|
|
||||||
| private readonly ILogger<NotificationViewModel> _logger; | ||||||
|
|
||||||
| public NotificationViewModel(ILogger<NotificationViewModel> logger) | ||||||
| { | ||||||
| _logger = logger; | ||||||
| LoadSampleNotifications(); | ||||||
| } | ||||||
|
|
||||||
| // TODO: [TEST] | ||||||
| private void LoadSampleNotifications() | ||||||
| { | ||||||
| Notifications = new ObservableCollection<NotificationModel> | ||||||
| { | ||||||
| new NotificationModel | ||||||
| ( | ||||||
| "Yeni Bütçe Önerisi", | ||||||
| "Aylık 'Eğlence' harcamalarınız için yeni bir bütçe limiti önerimiz var. Göz atmak için tıklayın.", | ||||||
| "2 saat önce", | ||||||
| NotificationType.Suggestion, | ||||||
| false | ||||||
| ), | ||||||
| new NotificationModel | ||||||
| ( | ||||||
| "Hedefe Ulaşıldı!", | ||||||
| "'Yeni Bilgisayar' birikim hedefinize ulaştınız. Tebrikler!", | ||||||
| "1 gün önce", | ||||||
| NotificationType.GoalAchieved, | ||||||
| true | ||||||
| ), | ||||||
| new NotificationModel | ||||||
| ( | ||||||
| "Fatura Hatırlatması", | ||||||
| "İnternet faturanızın son ödeme tarihi yarın. Gecikme faizinden kaçınmak için ödeme yapın.", | ||||||
| "3 gün önce", | ||||||
| NotificationType.Warning, | ||||||
| false | ||||||
| ) | ||||||
| }; | ||||||
| } | ||||||
|
|
||||||
| [RelayCommand] | ||||||
| private void MarkAllAsRead() | ||||||
| { | ||||||
| foreach (var notification in Notifications) | ||||||
| { | ||||||
| if (notification.isUnread) | ||||||
| { | ||||||
| notification.IsRead = true; | ||||||
| _logger.LogInformation($"Notification '{notification.Title}' marked as read."); | ||||||
|
||||||
| _logger.LogInformation($"Notification '{notification.Title}' marked as read."); | |
| _logger.LogInformation("Notification '{Title}' marked as read.", notification.Title); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This log message is in Turkish. For consistency with the rest of the code and UI, translate it to English, e.g., 'Selected file: {FilePath}'.