diff --git a/source/EduCATS/Data/DataAccess.cs b/source/EduCATS/Data/DataAccess.cs index e8ed2538..d74a723e 100644 --- a/source/EduCATS/Data/DataAccess.cs +++ b/source/EduCATS/Data/DataAccess.cs @@ -125,15 +125,27 @@ public async static Task GetSchedule(string date) var dataAccess = new DataAccess( "today_calendar_error", getScheduleCallback(date), GlobalConsts.DataGetCalendarKey); return await GetDataObject(dataAccess, false) as CalendarSubjectModelTest; - } - + } + + /// + /// Fetch schedule calendar data. + /// + /// Username. + /// Calendar data. + public async static Task GetEvent(string date) + { + var dataAccess = new DataAccess( + "today_calendar_error", getEventCallback(date), GlobalConsts.DataGetCalendarKey); + return await GetDataObject(dataAccess, false) as CalendarEventModelTest; + } + /// /// Fetch statistics. /// /// Subject ID. /// Group ID. /// Statistics data. - public async static Task GetStatistics(int subjectId, int groupId) + public async static Task GetStatistics(int subjectId, int groupId) { var dataAccess = new DataAccess( "stats_marks_error", getStatsCallback(subjectId, groupId), diff --git a/source/EduCATS/Data/DataAccessCallbacks.cs b/source/EduCATS/Data/DataAccessCallbacks.cs index f97f8d03..dc612be6 100644 --- a/source/EduCATS/Data/DataAccessCallbacks.cs +++ b/source/EduCATS/Data/DataAccessCallbacks.cs @@ -71,6 +71,14 @@ public static partial class DataAccess static async Task getScheduleCallback( string date) => await AppServices.GetSchedule(date); + /// + /// Schedule callback. + /// + /// Username. + /// Calendar data. + static async Task getEventCallback( + string date) => await AppServices.GetEvent(date); + /// /// Statistics callback. /// diff --git a/source/EduCATS/Data/DataAccessTools.cs b/source/EduCATS/Data/DataAccessTools.cs index 17ef0586..35e0bd59 100644 --- a/source/EduCATS/Data/DataAccessTools.cs +++ b/source/EduCATS/Data/DataAccessTools.cs @@ -43,7 +43,7 @@ public static void ResetData() public async static Task GetDataObject(IDataAccess dataAccess, bool isList) { object objectToGet; - + var x = dataAccess; if (isList) { objectToGet = await dataAccess.GetList(); } else { diff --git a/source/EduCATS/Data/Models/Calendar/CalendarEventModel.cs b/source/EduCATS/Data/Models/Calendar/CalendarEventModel.cs new file mode 100644 index 00000000..dc8c0144 --- /dev/null +++ b/source/EduCATS/Data/Models/Calendar/CalendarEventModel.cs @@ -0,0 +1,39 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace EduCATS.Data.Models.Calendar +{ + public class CalendarEventModelTest + { + [JsonProperty("Notes")] + public List Event { get; set; } + + public CalendarEventModelTest() + { + Event = new List(); + } + } + + public class Event + { + [JsonProperty("Color")] + public string Color { get; set; } + + [JsonProperty("EndTime")] + public string End { get; set; } + + [JsonProperty("Text")] + public string Name { get; set; } + + [JsonProperty("StartTime")] + public string Start { get; set; } + + /* + [JsonProperty("Notes")] + public string[] Notes { get; set; } + */ + } + +} diff --git a/source/EduCATS/Data/Models/Calendar/CalendarSubjectModelTest.cs b/source/EduCATS/Data/Models/Calendar/CalendarSubjectModelTest.cs index b5830bcf..5d47a795 100644 --- a/source/EduCATS/Data/Models/Calendar/CalendarSubjectModelTest.cs +++ b/source/EduCATS/Data/Models/Calendar/CalendarSubjectModelTest.cs @@ -41,6 +41,9 @@ public class Schedule [JsonProperty("Type")] public int Type { get; set; } + + [JsonProperty("Notes")] + public string[] Notes { get; set; } } diff --git a/source/EduCATS/EduCATS.csproj b/source/EduCATS/EduCATS.csproj index f369ad26..0d51326e 100644 --- a/source/EduCATS/EduCATS.csproj +++ b/source/EduCATS/EduCATS.csproj @@ -57,7 +57,6 @@ - @@ -119,7 +118,6 @@ - diff --git a/source/EduCATS/Helpers/Forms/Pages/AppPages.cs b/source/EduCATS/Helpers/Forms/Pages/AppPages.cs index 1ad3981b..7ed02049 100644 --- a/source/EduCATS/Helpers/Forms/Pages/AppPages.cs +++ b/source/EduCATS/Helpers/Forms/Pages/AppPages.cs @@ -18,6 +18,7 @@ using EduCATS.Pages.SaveLabsAndPracticeMarks.Views; using EduCATS.Pages.SaveMarks.Views; using EduCATS.Pages.Settings.About.Views; +using EduCATS.Pages.Settings.Profile.Views; using EduCATS.Pages.Settings.Base.Views; using EduCATS.Pages.Settings.Fonts.Views; using EduCATS.Pages.Settings.Language.Views; @@ -229,6 +230,13 @@ public async Task ClosePage(bool modal, bool animated = true) public async Task OpenSettingsAbout(string title) => await pushPage(new AboutPageView(), title); + /// + /// Change Application's main page without animation. + /// + /// Page to set. + public async Task OpenProfileAbout(string title) => + await pushPage(new ProfilePageView(), title); + /// /// Change Application's main page without animation. /// diff --git a/source/EduCATS/Helpers/Forms/Pages/Interfaces/IPages.cs b/source/EduCATS/Helpers/Forms/Pages/Interfaces/IPages.cs index e613c9d8..855d6fcb 100644 --- a/source/EduCATS/Helpers/Forms/Pages/Interfaces/IPages.cs +++ b/source/EduCATS/Helpers/Forms/Pages/Interfaces/IPages.cs @@ -180,5 +180,12 @@ public interface IPages /// Title. /// Task. Task OpenSettingsAbout(string title); + + /// + /// Open Settings About application page. + /// + /// Title. + /// Task. + Task OpenProfileAbout(string title); } } diff --git a/source/EduCATS/Localization/be.json b/source/EduCATS/Localization/be.json index 5ab66ed7..878e6a9b 100644 --- a/source/EduCATS/Localization/be.json +++ b/source/EduCATS/Localization/be.json @@ -50,7 +50,7 @@ "main_statistics": "Статыстыка", "main_settings": "Налады", - "today_subjects": "Прадметы", + "today_subjects": "Расклад", "today_news": "Навіны", "today_news_load_error": "Здарылася памылка падчас атрымання спісу навін. Калі ласка абнавіце старонку альбо звярніцеся ў службу падтрымкі.", "today_subjects_error": "Здарылася памылка падчас атрымання спісу прадметаў. Калі ласка абнавіце старонку альбо звярніцеся ў службу падтрымкі.", @@ -126,6 +126,7 @@ "settings_font": "Тэкст & Шрыфт", "settings_delete": "Выдаліць акаўнт", "settings_about": "Пра дадатак", + "settings_about_profile": "Аб акаўнце", "settings_logout": "Выйсці", "settings_logout_message": "Вы насамрэч жадаеце выйсці?", @@ -173,6 +174,11 @@ "name": "Імя", "surname": "Прозвішча", "patronymic": "Імя па бацьку", + "login": "Лагін", + "email": "Пошта", + "phone": "Тэлефон", + "accountinfo": "Skype, Viber, Telegram і др.", + "about": "Пра сябе", "confirm_password": "Пацверджанне пароля", "select_secret_question": "Серкретный пытанне", "choose_group": "Группа", diff --git a/source/EduCATS/Localization/de.json b/source/EduCATS/Localization/de.json index 87e7db75..46c8eb14 100644 --- a/source/EduCATS/Localization/de.json +++ b/source/EduCATS/Localization/de.json @@ -50,7 +50,7 @@ "main_statistics": "Statistik", "main_settings": "Einstellungen", - "today_subjects": "Studienfächer", + "today_subjects": "Zeitplan", "today_news": "Nachrichten", "today_news_load_error": "Fehler beim abrufen der Nachrichtenliste. Bitte aktualisieren Sie die Seite oder Kontaktieren Sie den Support.", "today_subjects_error": "Fehler beim abrufen der Artikelliste. Bitte aktualisieren Sie die Seite oder Kontaktieren Sie den Support.", @@ -128,6 +128,7 @@ "settings_font": "Text & Schriftart", "settings_delete": "Konto löschen", "settings_about": "Über die App ", + "settings_about_profile": "Über das Konto", "settings_logout": "Abmelden", "settings_logout_message": "Möchten Sie wirklich abmelden?", @@ -175,6 +176,11 @@ "name": "Name", "surname": "Vorname", "patronymic": "Patronym", + "login": "Anmeldung", + "email": "Post", + "phone": "Telefon", + "accountinfo": "Skype, Viber, Telegram und andere", + "about": "Über mich", "confirm_password": "Confirm password", "select_secret_question": "Spezifische Frage", "select_group": "Group", diff --git a/source/EduCATS/Localization/en.json b/source/EduCATS/Localization/en.json index ca7d6fa0..2b3d7be1 100644 --- a/source/EduCATS/Localization/en.json +++ b/source/EduCATS/Localization/en.json @@ -50,7 +50,7 @@ "main_statistics": "Statistics", "main_settings": "Settings", - "today_subjects": "Subjects", + "today_subjects": "Schedule", "today_news": "News", "today_news_load_error": "Error occurred during retrieving news. Please try to refresh page or contact support.", "today_subjects_error": "Error occurred during retrieving subjects. Please try to refresh page or contact support.", @@ -128,6 +128,7 @@ "settings_font": "Text & Font", "settings_delete": "Delete account", "settings_about": "About application", + "settings_about_profile": "About the account", "settings_logout": "Logout", "settings_logout_message": "Are you sure you want to logout?", @@ -175,6 +176,11 @@ "name": "Name", "surname": "Last name", "patronymic": "Patronymic", + "login": "Login", + "email": "Email", + "phone": "Telephone", + "accountinfo": "Skype, Viber, Telegram and other", + "about": "About", "confirm_password": "Confirm password", "select_secret_question": "Specific question", "choose_group": "Group", diff --git a/source/EduCATS/Localization/lt.json b/source/EduCATS/Localization/lt.json index 3fc631e9..2d76de39 100644 --- a/source/EduCATS/Localization/lt.json +++ b/source/EduCATS/Localization/lt.json @@ -51,7 +51,7 @@ "main_statistics": "Statistika", "main_settings": "Nustatymai", - "today_subjects": "Dalykai", + "today_subjects": "Tvarkaraštį", "today_news": "Naujienos", "today_news_load_error": "Gaunant naujienų sąrašą įvyko klaida. Atnaujinkite puslapį arba susisiekite su palaikymo tarnyba.", "today_subjects_error": "Gaunant elementų sąrašą įvyko klaida. Atnaujinkite puslapį arba susisiekite su palaikymo tarnyba.", @@ -129,6 +129,7 @@ "settings_font": "Tekstas ir šriftas", "settings_delete": "Eliminare l'account", "settings_about": "Apie programą", + "settings_about_profile": "Apie paskyrą", "settings_logout": "Atsijungti", "settings_logout_message": "Ar tikrai norite atsijungti ?", @@ -176,6 +177,11 @@ "name": "Vardas", "surname": "Pavardė", "patronymic": "Tėvavardis", + "login": "Prisijungti", + "email": "Paštas", + "phone": "Telefonas", + "accountinfo": "Skype, Viber, Telegram ir kita", + "about": "Apie mane", "confirm_password": "Patvirtinti slaptažodį", "select_secret_question": "Konkretus klausimas", "select_group": "Grupė", diff --git a/source/EduCATS/Localization/pl.json b/source/EduCATS/Localization/pl.json index e36752ee..e13d8e14 100644 --- a/source/EduCATS/Localization/pl.json +++ b/source/EduCATS/Localization/pl.json @@ -49,7 +49,7 @@ "main_statistics": "Statystyk", "main_settings": "Konfiguracja", - "today_subjects": "Dyscypliny", + "today_subjects": "harmonogram", "today_news": "Wiadomości", "today_news_load_error": "Wystąpił błąd podczas pobierania listy wiadomości. Proszę odświeżyć stronę lub skontaktować się z obsługą klienta.", "today_subjects_error": "Wystąpił błąd podczas pobierania listy dyscyplin. Proszę odświeżyć stronę lub skontaktować się z obsługą klienta.", @@ -127,6 +127,7 @@ "settings_font": "Tekst & Czcionka", "settings_delete": "Usuń konto", "settings_about": "Informacje o aplikacji", + "settings_about_profile": "O koncie", "settings_logout": "Wyjść", "settings_logout_message": "Czy na pewno chcesz wyjść?", @@ -174,6 +175,11 @@ "name": "Nazwa", "surname": "Nazwisko", "patronymic": "Patronimiczny", + "login": "Zaloguj sie", + "email": "Poczta", + "phone": "Telefon", + "accountinfo": "Skype, Viber, Telegram i inne.", + "about": "O mnie", "confirm_password": "Potwierdź hasło", "select_secret_question": "Konkretne pytanie", "choose_group": "Grupa", diff --git a/source/EduCATS/Localization/ru.json b/source/EduCATS/Localization/ru.json index 7be6d170..cd2fdae4 100644 --- a/source/EduCATS/Localization/ru.json +++ b/source/EduCATS/Localization/ru.json @@ -53,7 +53,7 @@ "main_settings": "Настройки", - "today_subjects": "Предметы", + "today_subjects": "Расписание", "today_news": "Новости", "today_news_load_error": "Произошла ошибка во время получения списка новостей. Пожалуйста, обновите страницу или обратитесь в службу поддержки.", "today_subjects_error": "Произошла ошибка во время получения списка предметов. Пожалуйста, обновите страницу или обратитесь в службу поддержки.", @@ -131,6 +131,7 @@ "settings_font": "Текст & Шрифт", "settings_delete": "Удалить аккаунт", "settings_about": "О приложении", + "settings_about_profile": "Об аккаунте", "settings_logout": "Выйти", "settings_logout_message": "Вы действительно хотите выйти?", @@ -178,6 +179,11 @@ "name": "Имя", "surname": "Фамилия", "patronymic": "Отчество", + "login": "Логин", + "email": "Почта", + "phone": "Телефон", + "accountinfo": "Skype, Viber, Telegram и др.", + "about": "О себе", "confirm_password": "Подтверждение пароля", "select_secret_question": "Секретный вопрос", "choose_group": "Группа", diff --git a/source/EduCATS/Networking/AppServices/AppServices.cs b/source/EduCATS/Networking/AppServices/AppServices.cs index 4a0c4562..f2554492 100644 --- a/source/EduCATS/Networking/AppServices/AppServices.cs +++ b/source/EduCATS/Networking/AppServices/AppServices.cs @@ -118,6 +118,16 @@ public static async Task GetSchedule(string date) return await AppServicesController.Request(Links.GetSchedule + $"dateStart={date}&dateEnd={date}", AppDemoType.Schedule); } + /// + /// Fetch calendar data request. + /// + /// Username. + /// Calendar data. + public static async Task GetEvent(string date) + { + return await AppServicesController.Request(Links.GetEvent + $"dateStart={date}&dateEnd={date}", AppDemoType.Schedule); + } + /// /// Fetch statistics request. /// diff --git a/source/EduCATS/Networking/Links.cs b/source/EduCATS/Networking/Links.cs index f9b77be5..1a373eb8 100644 --- a/source/EduCATS/Networking/Links.cs +++ b/source/EduCATS/Networking/Links.cs @@ -51,7 +51,12 @@ public static class Links /// Get schedule calendar data URL. /// public static string GetSchedule => $"{Servers.Current}/Services/Schedule/ScheduleService.svc/GetSchedule?"; - + + /// + /// Get schedule calendar data URL. + /// + public static string GetEvent => $"{Servers.Current}/Services/Notes/NotesService.svc/GetPersonalNotesBetweenDates?"; + /// /// Get laboratory works statistics URL. /// diff --git a/source/EduCATS/Pages/SaveLabsAndPracticeMarks/ViewModels/SavePracticeAndLabsPageView.cs b/source/EduCATS/Pages/SaveLabsAndPracticeMarks/ViewModels/SavePracticeAndLabsPageView.cs index 5610985b..4d92223a 100644 --- a/source/EduCATS/Pages/SaveLabsAndPracticeMarks/ViewModels/SavePracticeAndLabsPageView.cs +++ b/source/EduCATS/Pages/SaveLabsAndPracticeMarks/ViewModels/SavePracticeAndLabsPageView.cs @@ -30,6 +30,7 @@ public class SavePracticeAndLabsPageView : ContentPage { static Thickness _padding = new Thickness(10, 1); static Thickness _headerPadding = new Thickness(0, 10, 0, 10); + const double _controlHeight = 55; private string _groupName; @@ -137,7 +138,7 @@ Picker subGroupPicker() var subGroupPicker = new Picker { BackgroundColor = Color.White, - HeightRequest = 70, + HeightRequest = _controlHeight, }; subGroupPicker.SetBinding(Picker.ItemsSourceProperty, "SubGroup"); subGroupPicker.SetBinding(Picker.SelectedItemProperty, new Binding("SelectedSubGroup")); diff --git a/source/EduCATS/Pages/Settings/About/Views/AboutPageView.cs b/source/EduCATS/Pages/Settings/About/Views/AboutPageView.cs index 8fe88cf4..b6107886 100644 --- a/source/EduCATS/Pages/Settings/About/Views/AboutPageView.cs +++ b/source/EduCATS/Pages/Settings/About/Views/AboutPageView.cs @@ -1,10 +1,12 @@ using EduCATS.Constants; +using EduCATS.Data.Models; using EduCATS.Helpers.Forms; using EduCATS.Helpers.Forms.Styles; using EduCATS.Pages.Settings.About.ViewModels; using EduCATS.Themes; using FFImageLoading.Forms; using Nyxbull.Plugins.CrossLocalization; +using System.Collections.Generic; using Xamarin.Forms; namespace EduCATS.Pages.Settings.About.Views @@ -13,7 +15,6 @@ public class AboutPageView : ContentPage { static Thickness _padding = new Thickness(20); static Thickness _buttonsPadding = new Thickness(0, 0, 0, 10); - const double _spacing = 20; const double _buttonHeight = 50; diff --git a/source/EduCATS/Pages/Settings/Base/ViewModels/SettingsPageViewModel.cs b/source/EduCATS/Pages/Settings/Base/ViewModels/SettingsPageViewModel.cs index 94fca362..fdd3e84d 100644 --- a/source/EduCATS/Pages/Settings/Base/ViewModels/SettingsPageViewModel.cs +++ b/source/EduCATS/Pages/Settings/Base/ViewModels/SettingsPageViewModel.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using EduCATS.Constants; using EduCATS.Data; using EduCATS.Data.User; using EduCATS.Demo; @@ -99,7 +100,7 @@ void setSettings() createItem(Theme.Current.SettingsLanguageIcon, "settings_language"), createItem(Theme.Current.SettingsThemeIcon, "settings_theme"), createItem(Theme.Current.SettingsFontIcon, "settings_font"), - createItem(Theme.Current.SettingsAboutIcon, "settings_about") + createItem(Theme.Current.SettingsAboutIcon, "settings_about"), }; if (_services.Preferences.Server == Servers.EduCatsAddress && IsLoggedIn && !string.IsNullOrEmpty(_services.Preferences.GroupName)) @@ -144,6 +145,8 @@ async Task openPage(string title) var deleteTitle = CrossLocalization.Translate("settings_delete"); var aboutTitle = CrossLocalization.Translate("settings_about"); var logoutTitle = CrossLocalization.Translate("settings_logout"); + var profileTitle = CrossLocalization.Translate("settings_about_profile"); + if (title.Equals(serverTitle)) { await _services.Navigation.OpenSettingsServer(serverTitle); @@ -157,6 +160,8 @@ async Task openPage(string title) await deleteAccount(); } else if (title.Equals(aboutTitle)) { await _services.Navigation.OpenSettingsAbout(aboutTitle); + } else if (title.Equals(profileTitle)) { + await _services.Navigation.OpenProfileAbout(profileTitle); } else if (title.Equals(logoutTitle)) { await logout(); } diff --git a/source/EduCATS/Pages/Settings/Base/Views/SettingsPageView.cs b/source/EduCATS/Pages/Settings/Base/Views/SettingsPageView.cs index 1302883a..352472fd 100644 --- a/source/EduCATS/Pages/Settings/Base/Views/SettingsPageView.cs +++ b/source/EduCATS/Pages/Settings/Base/Views/SettingsPageView.cs @@ -3,10 +3,12 @@ using EduCATS.Helpers.Forms.Converters; using EduCATS.Helpers.Forms.Styles; using EduCATS.Pages.Settings.Base.ViewModels; +using EduCATS.Pages.Settings.Profile.Views; using EduCATS.Pages.Settings.Views.Base.ViewCells; using EduCATS.Themes; using FFImageLoading.Forms; using FFImageLoading.Transformations; +using Nyxbull.Plugins.CrossLocalization; using Xamarin.Forms; namespace EduCATS.Pages.Settings.Base.Views @@ -14,15 +16,20 @@ namespace EduCATS.Pages.Settings.Base.Views public class SettingsPageView : ContentPage { const double _avatarHeight = 60; - const double _userLayoutSpacing = 15; + const double _userLayoutSpacing = 15; + const double _forwardIcon = 20; static Thickness _listMargin = new(10, 0, 10, 0); - static Thickness _userFrameMargin = new(0, 0, 0, 10); + static Thickness _userFrameMargin = new(0, 0, 0, 10); + const double _buttonHeight = 10; + readonly IPlatformServices _services; public SettingsPageView() { NavigationPage.SetHasNavigationBar(this, false); BackgroundColor = Color.FromHex(Theme.Current.AppBackgroundColor); - BindingContext = new SettingsPageViewModel(new PlatformServices()); + _services = new PlatformServices(); + BindingContext = new SettingsPageViewModel(_services); + createViews(); } @@ -36,7 +43,7 @@ void createViews() Children = { settingsListView } - }; + }; } Frame createUserLayout() @@ -48,13 +55,21 @@ Frame createUserLayout() userRoleLabel.SetBinding(Label.TextProperty, "Role"); var userGroupLabel = createSubtitleLabel(); - userGroupLabel.SetBinding(Label.TextProperty, "Group"); + userGroupLabel.SetBinding(Label.TextProperty, "Group"); + + var forwardIcon = new CachedImage + { + HeightRequest = _forwardIcon, + HorizontalOptions = LayoutOptions.EndAndExpand, + VerticalOptions = LayoutOptions.CenterAndExpand, + Source = ImageSource.FromFile(Theme.Current.BaseArrowForwardIcon) + }; - var usernameLayout = new StackLayout { + var usernameLayout = new StackLayout { Children = { userLabel, userRoleLabel, - userGroupLabel + userGroupLabel, } }; @@ -64,7 +79,8 @@ Frame createUserLayout() HorizontalOptions = LayoutOptions.FillAndExpand, Children = { avatar, - usernameLayout + usernameLayout, + forwardIcon, } }; @@ -73,9 +89,17 @@ Frame createUserLayout() Margin = _userFrameMargin, BackgroundColor = Color.FromHex(Theme.Current.BaseBlockColor), Content = userLayout - }; - + }; + + var profileTitle = CrossLocalization.Translate("settings_about_profile"); userFrame.SetBinding(IsVisibleProperty, "IsLoggedIn"); + var tapGestureRecognizer = new TapGestureRecognizer(); + tapGestureRecognizer.Tapped += async (s, e) => + { + await _services.Navigation.OpenProfileAbout(profileTitle); + }; + userFrame.GestureRecognizers.Add(tapGestureRecognizer); + return userFrame; } @@ -94,6 +118,7 @@ CachedImage createAvatar() return avatarImage; } + Label createUserLabel() { var userLabel = new Label { @@ -124,7 +149,7 @@ RoundedListView createList(View header) Margin = _listMargin }; - settingsListView.ItemTapped += (sender, e) => ((ListView)sender).SelectedItem = null; + settingsListView.ItemTapped += (sender, e) => ((ListView)sender).SelectedItem = null; settingsListView.SetBinding(ListView.SelectedItemProperty, "SelectedItem"); settingsListView.SetBinding(ItemsView.ItemsSourceProperty, "SettingsList"); return settingsListView; diff --git a/source/EduCATS/Pages/Settings/Profile/ViewModels/ProfilePageViewModel.cs b/source/EduCATS/Pages/Settings/Profile/ViewModels/ProfilePageViewModel.cs new file mode 100644 index 00000000..11e6dea0 --- /dev/null +++ b/source/EduCATS/Pages/Settings/Profile/ViewModels/ProfilePageViewModel.cs @@ -0,0 +1,159 @@ +using System; +using System.Threading.Tasks; +using EduCATS.Constants; +using EduCATS.Data; +using EduCATS.Helpers.Forms; +using EduCATS.Helpers.Logs; +using EduCATS.Networking; +using EduCATS.Pages.Statistics.Students.Models; +using Nyxbull.Plugins.CrossLocalization; +using Xamarin.Forms; +using static System.Net.Mime.MediaTypeNames; + +namespace EduCATS.Pages.Settings.Profile.ViewModels +{ + public class ProfilePageViewModel : ViewModel + { + readonly IPlatformServices _services; + + public ProfilePageViewModel(IPlatformServices services) + { + try + { + _services = services; + Build = _services.Device.GetBuild(); + Version = _services.Device.GetVersion(); + setInitData(); + } + catch (Exception ex) + { + AppLogs.Log(ex, nameof(ProfilePageViewModel)); + } + } + string _version; + public string Version + { + get { return _version; } + set { SetProperty(ref _version, value); } + } + + string _build; + public string Build + { + get { return _build; } + set { SetProperty(ref _build, value); } + } + + bool _isLoggedIn; + public bool IsLoggedIn + { + get { return _isLoggedIn; } + set { SetProperty(ref _isLoggedIn, value); } + } + + string _username; + public string Username + { + get { return _username; } + set { SetProperty(ref _username, value); } + } + + string _group; + public string Group + { + get { return _group; } + set { SetProperty(ref _group, value); } + } + + string _groupLabel; + public string GroupLabel + { + get { return _groupLabel; } + set { SetProperty(ref _groupLabel, value); } + } + + string _role; + public string Role + { + get { return _role; } + set { SetProperty(ref _role, value); } + } + + string _name; + public string Name + { + get { return _name; } + set { SetProperty(ref _name, value); } + } + + string _surname; + public string SecondName + { + get { return _surname; } + set { SetProperty(ref _surname, value); } + } + + string _patronymic; + public string Patronymic + { + get { return _patronymic; } + set { SetProperty(ref _patronymic, value); } + } + + string _avatar; + public string Avatar + { + get { return _avatar; } + set { SetProperty(ref _avatar, value); } + } + + string _email; + public string Email + { + get { return _email; } + set { SetProperty(ref _email, value); } + } + + string _phone; + public string Phone + { + get { return _phone; } + set { SetProperty(ref _phone, value); } + } + + string _accountinfo; + public string AccountInfo + { + get { return _accountinfo; } + set { SetProperty(ref _accountinfo, value); } + } + + string _about; + public string About + { + get { return _about; } + set { SetProperty(ref _about, value); } + } + + async void setInitData() + { + Username = _services.Preferences.UserLogin; + // IsLoggedIn = AppDemo.Instance.IsDemoAccount ? true : _services.Preferences.IsLoggedIn; + Avatar = _services.Preferences.Avatar; + var isProfessor = string.IsNullOrEmpty(_services.Preferences.GroupName); + Group = isProfessor ? null : _services.Preferences.GroupName; + GroupLabel = isProfessor ? null : CrossLocalization.Translate("choose_group"); + Role = CrossLocalization.Translate(isProfessor ? "role_professor" : "role_student"); + var profile = await DataAccess.GetProfileInfo(_username); + var fio = profile.Name.Split(' '); + SecondName = fio[0]; + Name = fio[1]; + Patronymic = fio[2]; + Email = profile.Email; + Phone = profile.Phone; + AccountInfo = profile.SkypeContact; + About = profile.About; + + } + } +} diff --git a/source/EduCATS/Pages/Settings/Profile/Views/ProfilePageView.cs b/source/EduCATS/Pages/Settings/Profile/Views/ProfilePageView.cs new file mode 100644 index 00000000..30ea59ee --- /dev/null +++ b/source/EduCATS/Pages/Settings/Profile/Views/ProfilePageView.cs @@ -0,0 +1,206 @@ +using EduCATS.Constants; +using EduCATS.Data.Models; +using EduCATS.Helpers.Forms; +using EduCATS.Helpers.Forms.Styles; +using EduCATS.Pages.Settings.Profile.ViewModels; +using EduCATS.Themes; +using FFImageLoading.Forms; +using Nyxbull.Plugins.CrossLocalization; +using System.Collections.Generic; +using Xamarin.Forms; +using EduCATS.Data.Models; +using EduCATS.Helpers.Forms.Converters; +using FFImageLoading.Transformations; + + +namespace EduCATS.Pages.Settings.Profile.Views +{ + public class ProfilePageView : ContentPage + { + static Thickness _padding = new Thickness(20); + static Thickness _buttonsPadding = new Thickness(0, 0, 0, 10); + + const double _spacing = 20; + const double _buttonHeight = 50; + const double _avatarHeight = 200; + const double _photoBlockHeight = 400; + + + public ProfilePageView() + { + NavigationPage.SetHasNavigationBar(this, false); + Padding = _padding; + BackgroundColor = Color.FromHex(Theme.Current.AppBackgroundColor); + BindingContext = new ProfilePageViewModel(new PlatformServices()); + createViews(); + } + void createViews() + { + Content = new ScrollView + { + Content = new StackLayout + { + Spacing = _spacing, + Padding = _buttonsPadding, + Children = { + createPhotoBlock(), + createMainInfoBlock(), + createSecondInfoBlock() + } + } + }; + + } + + StackLayout createPhotoBlock() + { + var avatar = createAvatar(); + + return new StackLayout + { + BackgroundColor = Color.FromHex(Theme.Current.SettingsProfileColor), + Children = + { + avatar + } + }; + + } + StackLayout createSecondInfoBlock() + { + var emailLabel = createLabel("email"); + var email = createUnderLabel(); + email.SetBinding(Label.TextProperty, "Email"); + + var phoneLabel = createLabel("phone"); + var phone = createUnderLabel(); + phone.SetBinding(Label.TextProperty, "Phone"); + + var accountinfoLabel = createLabel("accountinfo"); + var accountinfo = createUnderLabel(); + accountinfo.SetBinding(Label.TextProperty, "AccountInfo"); + + var aboutLabel = createLabel("about"); + var about = createUnderLabel(); + about.SetBinding(Label.TextProperty, "About"); + + return new StackLayout + { + + BackgroundColor = Color.FromHex(Theme.Current.SettingsProfileColor), + Children = + { + emailLabel, + email, + phoneLabel, + phone, + accountinfoLabel, + accountinfo, + aboutLabel, + about + } + }; + } + + + StackLayout createMainInfoBlock() + { + var surnameLabel = createLabel("surname"); + var surname = createUnderLabel(); + surname.SetBinding(Label.TextProperty, "SecondName"); + + var nameLabel = createLabel("name"); + var name = createUnderLabel(); + name.SetBinding(Label.TextProperty, "Name"); + + var patronymicLabel = createLabel("patronymic"); + var patronymic = createUnderLabel(); + patronymic.SetBinding(Label.TextProperty, "Patronymic"); + + var usernameLabel = createLabel("login"); + var login = createUnderLabel(); + login.SetBinding(Label.TextProperty, "Username"); + + var groupLabel = createGroupLabel(); + groupLabel.SetBinding(Label.TextProperty, "GroupLabel"); + var groupName = createUnderLabel(); + groupName.SetBinding(Label.TextProperty, "Group"); + var x = groupName; + if (groupName != null) + { + return new StackLayout + { + BackgroundColor = Color.FromHex(Theme.Current.SettingsProfileColor), + Children = { + surnameLabel, + surname, + nameLabel, + name, + patronymicLabel, + patronymic, + usernameLabel, + login, + groupLabel, + groupName, + } + }; + } + else + { + return new StackLayout + { + BackgroundColor = Color.FromHex(Theme.Current.SettingsProfileColor), + Children = { + surnameLabel, + surname, + nameLabel, + name, + patronymicLabel, + patronymic, + usernameLabel, + login, + } + }; + } + } + Label createLabel(string text) + { + return new Label + { + TextColor = Color.FromHex(Theme.Current.SettingsGroupUserColor), + Style = AppStyles.GetLabelStyle(), + Text = CrossLocalization.Translate(text), + }; + } + Label createUnderLabel() + { + return new Label + { + TextColor = Color.FromHex(Theme.Current.SettingsTitleColor), + Style = AppStyles.GetLabelStyle(), + TextDecorations = TextDecorations.Underline + }; + + } + Label createGroupLabel() + { + return new Label + { + TextColor = Color.FromHex(Theme.Current.SettingsTitleColor), + Style = AppStyles.GetLabelStyle(), + }; + } + CachedImage createAvatar() + { + var avatarImage = new CachedImage + { + HeightRequest = _avatarHeight, + VerticalOptions = LayoutOptions.CenterAndExpand, + }; + + avatarImage.SetBinding(CachedImage.SourceProperty, "Avatar", + converter: new Base64ToImageSourceConverter()); + return avatarImage; + } + } +} diff --git a/source/EduCATS/Pages/Statistics/Marks/Views/ViewCells/VisitingPageViewCell.cs b/source/EduCATS/Pages/Statistics/Marks/Views/ViewCells/VisitingPageViewCell.cs index 08d7ad69..aa003e9c 100644 --- a/source/EduCATS/Pages/Statistics/Marks/Views/ViewCells/VisitingPageViewCell.cs +++ b/source/EduCATS/Pages/Statistics/Marks/Views/ViewCells/VisitingPageViewCell.cs @@ -26,7 +26,6 @@ public VisitingPageViewCell() { VerticalOptions = LayoutOptions.CenterAndExpand, TextColor = Color.FromHex(Theme.Current.StatisticsDetailsTitleColor), - //Font = Font.SystemFontOfSize(NamedSize.Large).WithAttributes(FontAttributes.Bold), Style = AppStyles.GetLabelStyle() }; diff --git a/source/EduCATS/Pages/Today/Base/Models/EventPageModel.cs b/source/EduCATS/Pages/Today/Base/Models/EventPageModel.cs new file mode 100644 index 00000000..5c2b022c --- /dev/null +++ b/source/EduCATS/Pages/Today/Base/Models/EventPageModel.cs @@ -0,0 +1,45 @@ +using EduCATS.Controls.RoundedListView.Enums; +using EduCATS.Controls.RoundedListView.Interfaces; +using EduCATS.Data.Models.Calendar; +using Nyxbull.Plugins.CrossLocalization; + +namespace EduCATS.Pages.Today.Base.Models +{ + public class EventPageModel : IRoundedListType + { + public string Address { get; set; } + public string Color { get; set; } + public string Name { get; set; } + + public string Note { get; set; } + + public string Date { get; set; } + public string Type { get; set; } + + public EventPageModel(Event @event) + { + setDefaultProps(@event); + } + + void setDefaultProps(Event @event) + { + if (@event != null) + { + Color = "#FFA500"; + Date = @event.Start + "-" + @event.End; + Name = @event.Name; + /*for (int i = 0; i < schedule.Notes.Length; i++) + { + Note += schedule.Notes[i]; + }*/ + + } + } + + + public RoundedListTypeEnum GetListType() + { + return RoundedListTypeEnum.Navigation; + } + } +} diff --git a/source/EduCATS/Pages/Today/Base/Models/SubjectPageModel.cs b/source/EduCATS/Pages/Today/Base/Models/SubjectPageModel.cs index c24d7e60..128c6d69 100644 --- a/source/EduCATS/Pages/Today/Base/Models/SubjectPageModel.cs +++ b/source/EduCATS/Pages/Today/Base/Models/SubjectPageModel.cs @@ -11,6 +11,8 @@ public class SubjectPageModel : IRoundedListType public string Color { get; set; } public string Name { get; set; } + public string Note { get; set; } + string _teacherFullName; public string TeacherFullName { @@ -94,7 +96,10 @@ void setDefaultProps(Schedule schedule) Address = $"{CrossLocalization.Translate("address_building")} {schedule.Building}, {CrossLocalization.Translate("address_room")} {schedule.Audience}"; Date = schedule.Start + "-" + schedule.End; Name = schedule.Name; - + for(int i = 0; i < schedule.Notes.Length; i++) + { + Note += schedule.Notes[i]; + } switch (schedule.Type) { @@ -114,6 +119,7 @@ void setDefaultProps(Schedule schedule) Type = CrossLocalization.Translate("type_activity_dconsultation"); break; default: + Type = ""; break; } diff --git a/source/EduCATS/Pages/Today/Base/ViewModels/TodayPageViewModel.cs b/source/EduCATS/Pages/Today/Base/ViewModels/TodayPageViewModel.cs index 819a6cee..403a3735 100644 --- a/source/EduCATS/Pages/Today/Base/ViewModels/TodayPageViewModel.cs +++ b/source/EduCATS/Pages/Today/Base/ViewModels/TodayPageViewModel.cs @@ -79,6 +79,13 @@ public List NewsSubjectList set { SetProperty(ref _newsSubjectList, value); } } + List _newsEventList; + public List NewsEventList + { + get { return _newsEventList; } + set { SetProperty(ref _newsEventList, value); } + } + List _calendarSubjects; public List CalendarSubjects { get { return _calendarSubjects; } @@ -91,6 +98,13 @@ public List NewsSubjectList set { SetProperty(ref _calendarSubjectsHeight, value); } } + double _calendarEventHeight; + public double CalendarEventHeight + { + get { return _calendarEventHeight; } + set { SetProperty(ref _calendarEventHeight, value); } + } + string _month; public string Month { get { return _month; } @@ -231,6 +245,7 @@ async Task getAndSetCalendarNotes() } await setNewSubjectList(date); + await setNewEventList(date); } } @@ -446,6 +461,7 @@ public void ExecuteCalendarSelectionChangedEvent(DateTime date) { _services.Device.MainThread(async () => { await setNewSubjectList(date); + await setNewEventList(date); }); } @@ -466,6 +482,17 @@ async Task setNewSubjectList(DateTime dateTime) setupNewsSubjectsHeight(); } + async Task setNewEventList(DateTime dateTime) + { + var subjects = await DataAccess.GetEvent(dateTime.ToString(DateHelper.DateTime.Replace('.', '-'))); + + List temp = subjects.Event.Select(n => { + return new EventPageModel(n); + }).ToList().OrderBy(l => l.Date).ToList(); + + NewsEventList = temp.OrderBy(x => x.Date).ToList(); + setupEventSubjectsHeight(); + } void setFilteredSubjectsList() { @@ -517,6 +544,27 @@ void setupNewsSubjectsHeight() { AppLogs.Log(ex); } + + + } + void setupEventSubjectsHeight() + { + try + { + if (NewsEventList.Count == 0) + { + CalendarEventHeight = _emptySubjectsHeight; + return; + } + + CalendarEventHeight = + (_subjectHeight * (NewsEventList.Count) /** 2*/) + + _subjectsHeaderHeight + _subjectsFooterHeight + _subjectsHeightToAdd; + } + catch (Exception ex) + { + AppLogs.Log(ex); + } } } } diff --git a/source/EduCATS/Pages/Today/Base/Views/TodayPageView.cs b/source/EduCATS/Pages/Today/Base/Views/TodayPageView.cs index 1afc9a8c..cd1e5c66 100644 --- a/source/EduCATS/Pages/Today/Base/Views/TodayPageView.cs +++ b/source/EduCATS/Pages/Today/Base/Views/TodayPageView.cs @@ -21,7 +21,7 @@ public class TodayPageView : ContentPage const string _calendarCollectionDataBinding = "."; double _subjectRowHeight = 80; - double _subjectDetailedRowHeight = 80; + double _subjectDetailedRowHeight = 90; static Thickness _newsLabelMagin = new Thickness(10); static Thickness _subjectsMargin = new Thickness(10, 5, 10, 0); diff --git a/source/EduCATS/Pages/Today/Base/Views/ViewCells/SubjectPageViewCell.cs b/source/EduCATS/Pages/Today/Base/Views/ViewCells/SubjectPageViewCell.cs index 821efe5a..9333c4a1 100644 --- a/source/EduCATS/Pages/Today/Base/Views/ViewCells/SubjectPageViewCell.cs +++ b/source/EduCATS/Pages/Today/Base/Views/ViewCells/SubjectPageViewCell.cs @@ -6,6 +6,7 @@ using FFImageLoading.Work; using System.Collections.Generic; using Xamarin.Forms; +using Xamarin.Forms.Shapes; namespace EduCATS.Pages.Today.Base.Views.ViewCells { @@ -14,7 +15,11 @@ class SubjectPageViewCell : ViewCell const double _boxViewSize = 10; const double _boxViewLayoutSize = 20; const double _clockIconSize = 20; - static Thickness _paddingTeacher = new Thickness(10, 0); + double _boxViewSizeAngle = _boxViewSize / 2; + double _boxViewSizeRotate = 0; + + static Thickness _paddingTeacher = new Thickness(10 , 0); + static Thickness _paddingNote = new Thickness(20, 0); static Thickness _framePadding = new Thickness(10, 5, 10, 10); static Thickness _paddingItem = new Thickness(25, 0); @@ -61,16 +66,14 @@ public SubjectPageViewCell() address } }; - var subjectBoxView = new BoxView { HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, HeightRequest = _boxViewSize, WidthRequest = _boxViewSize, - CornerRadius = _boxViewSize / 2 + CornerRadius = _boxViewSizeAngle, }; - subjectBoxView.SetBinding( BoxView.ColorProperty, "Color", converter: new StringToColorConverter()); @@ -130,15 +133,26 @@ public SubjectPageViewCell() type, teacher } + }; + var note = new Label + { + Padding = _paddingItem, + VerticalOptions = LayoutOptions.CenterAndExpand, + TextColor = Color.FromHex(Theme.Current.TodayNewsDateColor), + Style = AppStyles.GetLabelStyle(NamedSize.Micro) }; + note.SetBinding(Label.TextProperty, "Note"); + View = new StackLayout { Padding = _framePadding, BackgroundColor = Color.FromHex(Theme.Current.TodayNewsItemBackgroundColor), Children = { dateLayout, - subjectLayout, - informationLayout + subjectLayout, + informationLayout, + note, + } }; } diff --git a/source/EduCATS/Themes/Interfaces/ITheme.cs b/source/EduCATS/Themes/Interfaces/ITheme.cs index 9a6d7562..35175337 100644 --- a/source/EduCATS/Themes/Interfaces/ITheme.cs +++ b/source/EduCATS/Themes/Interfaces/ITheme.cs @@ -136,7 +136,7 @@ public interface ITheme string SettingsLogoutIcon { get; } string SettingsGroupUserColor { get; } string SettingsTitleColor { get; } - + string SettingsProfileColor{ get;} string CheckboxIcon { get; } string CheckboxDescriptionColor { get; } diff --git a/source/EduCATS/Themes/Templates/DefaultTheme.cs b/source/EduCATS/Themes/Templates/DefaultTheme.cs index c5543dd4..ea8cb487 100644 --- a/source/EduCATS/Themes/Templates/DefaultTheme.cs +++ b/source/EduCATS/Themes/Templates/DefaultTheme.cs @@ -145,6 +145,7 @@ public class DefaultTheme : ITheme virtual public string SettingsLogoutIcon => "icon_settings_logout"; virtual public string SettingsGroupUserColor => _greyColor; virtual public string SettingsTitleColor => _blackColor; + virtual public string SettingsProfileColor => _whiteColor; virtual public string CheckboxIcon => "icon_checkmark"; virtual public string CheckboxDescriptionColor => _greyColor;