diff --git a/lib/app/app.dart b/lib/app/app.dart index df1688d21..fac3d248a 100644 --- a/lib/app/app.dart +++ b/lib/app/app.dart @@ -1,4 +1,3 @@ - import 'package:zurichat/services/centrifuge_service.dart'; import 'package:zurichat/services/localization_service.dart'; import 'package:zurichat/services/media_service.dart'; @@ -33,7 +32,6 @@ import 'package:zurichat/ui/view/forgot_password/forgot_password_email/forgot_pa import 'package:zurichat/ui/view/forgot_password/forgot_password_new_password/forgot_password_newview.dart'; import 'package:zurichat/ui/view/forgot_password/forgot_password_otp/forgot_password_otpview.dart'; import 'package:zurichat/ui/view/webview_page/webview_page.dart'; - import 'package:shared_preferences/shared_preferences.dart'; import 'package:stacked/stacked_annotations.dart'; import 'package:stacked_services/stacked_services.dart'; diff --git a/lib/app/app.locator.dart b/lib/app/app.locator.dart index 6c0bf9f6d..e87396d7f 100644 --- a/lib/app/app.locator.dart +++ b/lib/app/app.locator.dart @@ -34,12 +34,10 @@ Future setupLocator( // Register dependencies locator.registerLazySingleton(() => NavigationService()); locator.registerLazySingleton(() => SnackbarService()); - final zuriThemeService = await ZuriThemeService.getInstance(); locator.registerSingleton(zuriThemeService); locator.registerLazySingleton(() => LocalizationService()); - final sharedPreferenceLocalStorage = await SharedPreferenceLocalStorage.getInstance(); locator.registerSingleton(sharedPreferenceLocalStorage); diff --git a/lib/app/app.router.dart b/lib/app/app.router.dart index 8025a1db7..f08a8bb39 100644 --- a/lib/app/app.router.dart +++ b/lib/app/app.router.dart @@ -31,9 +31,7 @@ import '../ui/view/channel/channel_view/channel_page_view.dart'; import '../ui/view/channel/edit_channel/edit_channel_view.dart'; import '../ui/view/channel/new_channel/new_channel.dart'; import '../ui/view/channel/pinned_messages/pinned_messages_view.dart'; - import '../ui/view/channel/share_message/share_message_view.dart'; - import '../ui/view/clear_after/clear_after_view.dart'; import '../ui/view/direct_message/direct_message.dart'; import '../ui/view/dm_chat_view/dm_jump_to_view.dart'; @@ -55,10 +53,8 @@ import '../ui/view/organization/add_organization/add_organization_view.dart'; import '../ui/view/organization/create_organization/create_organization.dart'; import '../ui/view/organization/invite_to_organization/admin_permissions/create_invite_link.dart'; import '../ui/view/organization/invite_to_organization/admin_permissions/invite_via_email.dart'; - import '../ui/view/organization/invite_to_organization/invitation_sent.dart'; import '../ui/view/organization/invite_to_organization/invite_via_contact/import_contact.dart'; - import '../ui/view/organization/invite_to_organization/invite_via_email/invite_via_email.dart'; import '../ui/view/organization/organization_different_email/different_email_organization_view.dart'; import '../ui/view/organization/organization_settings/organization_logo.dart'; @@ -728,9 +724,7 @@ class StackedRouter extends RouterBase { var args = data.getArgs( orElse: () => InviteViaEmailArguments(), ); - return CupertinoPageRoute( - builder: (context) => InviteViaEmail(key: args.key), settings: data, ); @@ -1015,7 +1009,6 @@ class InviteViaEmailArguments { InviteViaEmailArguments({this.key}); } - /// ShareMessageView arguments holder class class ShareMessageViewArguments { final UserPost userPost; @@ -1043,4 +1036,3 @@ class OrganizationLogoArguments { final OrganizationModel org; OrganizationLogoArguments({this.key, required this.org}); } - diff --git a/lib/package/base/server-request/api/api.dart b/lib/package/base/server-request/api/api.dart index 84fd91bc8..3a5b96657 100644 --- a/lib/package/base/server-request/api/api.dart +++ b/lib/package/base/server-request/api/api.dart @@ -78,7 +78,7 @@ abstract class Api { }); // THE SERVICE TO UPDATE AN ORGANIZATION LOGO - Future updateOrgLogo(String orgId, File image, token); + Future updateOrgLogo(String orgId, File image, token); // THE SERVICE TO ADD A MEMBERS TO AN ORGANIZATION Future addMemberToOrganization(String orgId, String email, token); diff --git a/lib/package/base/server-request/api/zuri_api.dart b/lib/package/base/server-request/api/zuri_api.dart index bba84e5bc..c814d7a8a 100644 --- a/lib/package/base/server-request/api/zuri_api.dart +++ b/lib/package/base/server-request/api/zuri_api.dart @@ -396,6 +396,7 @@ class ZuriApi implements Api { } on DioError catch (e) { log.w(e.toString()); handleApiError(e); + throw e.response!.data['message']; } } @@ -415,32 +416,36 @@ class ZuriApi implements Api { } on DioError catch (e) { log.w(e.toString()); handleApiError(e); + throw e.response!.data['message']; } } /// Updates an organization's logo. The organization's id `orgId` must not be /// null or empty @override - Future updateOrgLogo(String orgId, File image, token) async { + Future updateOrgLogo(String orgId, File image, token) async { try { var formData = FormData.fromMap({ + 'height': 300, + 'width': 300, "image": await MultipartFile.fromFile( image.path, filename: image.path.split(Platform.pathSeparator).last, contentType: MediaType('image', 'jpeg'), ), }); - final res = await dio.patch( + await dio.patch( '${coreBaseUrl}organizations/$orgId/logo', options: Options( headers: {'Authorization': 'Bearer $token'}, ), data: formData, ); - return res.data['message']; + return true; } on DioError catch (e) { log.w(e.toString()); handleApiError(e); + throw e.response?.data['message']; } } diff --git a/lib/ui/shared/text_styles.dart b/lib/ui/shared/text_styles.dart index a9b0ecea7..f11ed4e08 100644 --- a/lib/ui/shared/text_styles.dart +++ b/lib/ui/shared/text_styles.dart @@ -55,9 +55,15 @@ class AppTextStyle { static TextStyle darkGreySize18Bold = _base(_size18, _boldWeight, AppColors.textDark10); + static TextStyle blackSize20Bold = + _base(_size20, _boldWeight, AppColors.textDark10); + static TextStyle blackSize18Bold = _base(_size18, _boldWeight, AppColors.textDark10); + static TextStyle blackSize16Bold = + _base(_size16, _boldWeight, AppColors.textDark10); + static TextStyle darkGreySize20Bold = _base(_size20, _boldWeight, AppColors.textDark10); diff --git a/lib/ui/view/organization/invite_to_organization/admin_permissions/create_invite_link.dart b/lib/ui/view/organization/invite_to_organization/admin_permissions/create_invite_link.dart index 7d07cd8fe..1734b338b 100644 --- a/lib/ui/view/organization/invite_to_organization/admin_permissions/create_invite_link.dart +++ b/lib/ui/view/organization/invite_to_organization/admin_permissions/create_invite_link.dart @@ -1,11 +1,9 @@ import 'package:flutter/material.dart'; - import 'package:zurichat/ui/shared/shared.dart'; import 'package:zurichat/ui/shared/text_styles.dart'; import 'package:zurichat/ui/shared/zuri_appbar.dart'; import 'package:zurichat/ui/view/organization/invite_to_organization/invite_via_email/invite_viewmodel.dart'; import 'package:zurichat/utilities/internalization/localization/app_localization.dart'; - import 'package:stacked/stacked.dart'; class CreateInviteLink extends StatelessWidget { diff --git a/lib/ui/view/organization/invite_to_organization/admin_permissions/invite_via_email.dart b/lib/ui/view/organization/invite_to_organization/admin_permissions/invite_via_email.dart index 52614dba9..c5dec363e 100644 --- a/lib/ui/view/organization/invite_to_organization/admin_permissions/invite_via_email.dart +++ b/lib/ui/view/organization/invite_to_organization/admin_permissions/invite_via_email.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; - import 'package:zurichat/ui/shared/shared.dart'; import 'package:zurichat/ui/shared/text_styles.dart'; import 'package:zurichat/ui/shared/zuri_appbar.dart'; diff --git a/lib/ui/view/organization/invite_to_organization/invitation_sent.dart b/lib/ui/view/organization/invite_to_organization/invitation_sent.dart index 16a42489b..a3f19b812 100644 --- a/lib/ui/view/organization/invite_to_organization/invitation_sent.dart +++ b/lib/ui/view/organization/invite_to_organization/invitation_sent.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; - import 'package:zurichat/ui/shared/long_button.dart'; import 'package:zurichat/ui/shared/shared.dart'; import 'package:zurichat/ui/shared/text_styles.dart'; @@ -8,7 +7,6 @@ import 'package:zurichat/ui/shared/ui_helpers.dart'; import 'package:zurichat/ui/shared/zuri_appbar.dart'; import 'package:zurichat/ui/view/organization/invite_to_organization/invite_via_email/invite_viewmodel.dart'; import 'package:zurichat/utilities/internalization/localization/app_localization.dart'; - import 'package:stacked/stacked.dart'; class InvitationSent extends StatelessWidget { diff --git a/lib/ui/view/organization/invite_to_organization/invite_via_contact/import_contact.dart b/lib/ui/view/organization/invite_to_organization/invite_via_contact/import_contact.dart index 8a77355a0..5fd786e43 100644 --- a/lib/ui/view/organization/invite_to_organization/invite_via_contact/import_contact.dart +++ b/lib/ui/view/organization/invite_to_organization/invite_via_contact/import_contact.dart @@ -1,10 +1,8 @@ import 'package:flutter/material.dart'; - import 'package:zurichat/ui/nav_pages/plugin_page/widgets/custom_search_field.dart'; import 'package:zurichat/ui/shared/text_styles.dart'; import 'package:zurichat/ui/shared/zuri_appbar.dart'; import 'package:zurichat/utilities/internalization/localization/app_localization.dart'; - import 'package:stacked/stacked.dart'; import '../invite_via_email/invite_viewmodel.dart'; diff --git a/lib/ui/view/organization/invite_to_organization/invite_via_email/invite_via_email.dart b/lib/ui/view/organization/invite_to_organization/invite_via_email/invite_via_email.dart index f1cc5f95d..4133c3aeb 100644 --- a/lib/ui/view/organization/invite_to_organization/invite_via_email/invite_via_email.dart +++ b/lib/ui/view/organization/invite_to_organization/invite_via_email/invite_via_email.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; - import 'package:zurichat/ui/shared/shared.dart'; import 'package:zurichat/ui/shared/text_styles.dart'; import 'package:zurichat/ui/shared/zuri_appbar.dart'; diff --git a/lib/ui/view/organization/invite_to_organization/invite_via_email/invite_viewmodel.dart b/lib/ui/view/organization/invite_to_organization/invite_via_email/invite_viewmodel.dart index 9bd6d637f..ff9970135 100644 --- a/lib/ui/view/organization/invite_to_organization/invite_via_email/invite_viewmodel.dart +++ b/lib/ui/view/organization/invite_to_organization/invite_via_email/invite_viewmodel.dart @@ -9,7 +9,6 @@ import 'package:zurichat/services/user_service.dart'; import 'package:zurichat/utilities/constants.dart'; import 'package:zurichat/utilities/mixins/validators_mixin.dart'; import 'package:zurichat/utilities/storage_keys.dart'; - import '../../../../../../app/app.logger.dart'; import 'package:stacked_services/stacked_services.dart'; diff --git a/lib/ui/view/organization/organization_different_email/different_email_organization_view.dart b/lib/ui/view/organization/organization_different_email/different_email_organization_view.dart index a5c3fe3c0..8266df434 100644 --- a/lib/ui/view/organization/organization_different_email/different_email_organization_view.dart +++ b/lib/ui/view/organization/organization_different_email/different_email_organization_view.dart @@ -1,13 +1,11 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; - import 'package:zurichat/constants/app_strings.dart'; import 'package:zurichat/ui/shared/text_styles.dart'; import 'package:zurichat/ui/shared/text_field.dart'; import 'package:zurichat/utilities/enums.dart'; import 'package:zurichat/utilities/internalization/localization/app_localization.dart'; - import 'package:stacked/stacked.dart'; import '../../../shared/shared.dart'; diff --git a/lib/ui/view/organization/organization_different_email/different_email_organization_viewmodel.dart b/lib/ui/view/organization/organization_different_email/different_email_organization_viewmodel.dart index 972c5a4e7..94657c1bf 100644 --- a/lib/ui/view/organization/organization_different_email/different_email_organization_viewmodel.dart +++ b/lib/ui/view/organization/organization_different_email/different_email_organization_viewmodel.dart @@ -1,10 +1,8 @@ - import 'package:zurichat/app/app.locator.dart'; import 'package:zurichat/app/app.router.dart'; import 'package:zurichat/ui/shared/colors.dart'; import 'package:zurichat/utilities/enums.dart'; import 'package:zurichat/utilities/mixins/validators_mixin.dart'; - import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; diff --git a/lib/ui/view/organization/organization_settings/organization_logo.dart b/lib/ui/view/organization/organization_settings/organization_logo.dart index 328937ca1..8011eac59 100644 --- a/lib/ui/view/organization/organization_settings/organization_logo.dart +++ b/lib/ui/view/organization/organization_settings/organization_logo.dart @@ -3,7 +3,6 @@ import 'package:zurichat/ui/shared/text_styles.dart'; import 'package:stacked/stacked.dart'; import 'package:zurichat/constants/app_strings.dart'; import 'package:zurichat/models/organization_model.dart'; -import 'package:zurichat/ui/shared/colors.dart'; import 'package:zurichat/ui/shared/long_button.dart'; import 'package:zurichat/ui/shared/zuri_appbar.dart'; import 'package:zurichat/ui/shared/zuri_loader.dart'; @@ -16,7 +15,6 @@ class OrganizationLogo extends StatelessWidget { @override Widget build(BuildContext context) { final bool _dark = Theme.of(context).brightness == Brightness.dark; - return ViewModelBuilder.reactive( viewModelBuilder: () => OrganizationSettingsViewModel(), builder: (context, model, child) { @@ -24,20 +22,22 @@ class OrganizationLogo extends StatelessWidget { appBar: ZuriAppBar( isDarkMode: _dark, whiteBackground: true, - leading: Icons.chevron_left, + leading: Icons.close, leadingPress: () => model.back(), orgTitle: Text( OrgIcon, - style: AppTextStyle.organizationNameText, + style: _dark + ? AppTextStyle.whiteSize20Bold + : AppTextStyle.blackSize20Bold, ), actions: [ TextButton( onPressed: () => model.updateOrgLogo(org.id.toString()), child: Text( Save, - style: AppTextStyle.lightGreySize16.copyWith( - color: AppColors.zuriPrimaryColor, - ), + style: _dark + ? AppTextStyle.lightGreySize16 + : AppTextStyle.darkGreySize16, ), ), ], @@ -79,15 +79,18 @@ class OrganizationLogo extends StatelessWidget { width: 200, ), const SizedBox(height: 30), - Text(OrgIconGuide, - style: _dark - ? AppTextStyle.whiteSize18Bold - : AppTextStyle.blackSize18Bold), + Text( + OrgIconGuide, + style: _dark + ? AppTextStyle.whiteSize18Bold + : AppTextStyle.blackSize18Bold, + ), const SizedBox(height: 10), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), - child: Text(OrgIconGuideDesc, - style: AppTextStyle.lightGreySize16), + Text( + OrgIconGuideDesc, + style: _dark + ? AppTextStyle.lightGreySize16 + : AppTextStyle.darkGreySize16, ), ], ), diff --git a/lib/ui/view/organization/organization_settings/organization_name_url.dart b/lib/ui/view/organization/organization_settings/organization_name_url.dart index 22b35c77a..1bbb5807d 100644 --- a/lib/ui/view/organization/organization_settings/organization_name_url.dart +++ b/lib/ui/view/organization/organization_settings/organization_name_url.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:stacked/stacked.dart'; import 'package:zurichat/models/organization_model.dart'; import 'package:zurichat/ui/shared/text_styles.dart'; import 'package:zurichat/ui/view/organization/organization_settings/organization_settings_view_model.dart'; @@ -8,139 +9,153 @@ import 'package:zurichat/ui/shared/colors.dart'; import 'package:zurichat/ui/shared/text_field.dart'; import 'package:zurichat/ui/shared/zuri_appbar.dart'; import 'package:zurichat/ui/shared/zuri_loader.dart'; -import 'package:stacked_hooks/stacked_hooks.dart'; -class OrganizationNameUrl - extends HookViewModelWidget { +class OrganizationNameUrl extends HookWidget { final OrganizationModel org; OrganizationNameUrl({Key? key, required this.org}) : super(key: key); final _formKey = GlobalKey(); @override - Widget buildViewModelWidget( - BuildContext context, OrganizationSettingsViewModel viewModel) { + Widget build(BuildContext context) { final _orgNameController = useTextEditingController(text: org.name); final _orgUrlController = useTextEditingController(text: org.organizationUrl?.split('.').first); - return Scaffold( - appBar: ZuriAppBar( - whiteBackground: true, - title: OrgnameUrl, - subtitle: '', - leading: Icons.chevron_left, - leadingPress: () => viewModel.back(), - actions: [ - TextButton( - onPressed: () { - if (!_formKey.currentState!.validate()) return; - viewModel.updateOrgNameAndUrl(org.id.toString(), - _orgNameController.text, _orgUrlController.text); - }, - child: Text( - Save, - style: AppTextStyle.lightGreySize16.copyWith( - color: AppColors.zuriPrimaryColor, - ), + final bool _dark = Theme.of(context).brightness == Brightness.dark; + return ViewModelBuilder.reactive( + viewModelBuilder: () => OrganizationSettingsViewModel(), + onModelReady: (model) => model.init(org.name!, org.organizationUrl!), + builder: (context, viewModel, child) { + return Scaffold( + appBar: ZuriAppBar( + whiteBackground: true, + isDarkMode: _dark, + orgTitle: Text( + OrgnameUrl, + style: _dark + ? AppTextStyle.whiteSize20Bold + : AppTextStyle.blackSize20Bold, ), - ), - ], - ), - body: Stack( - fit: StackFit.expand, - children: [ - Form( - key: _formKey, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 25, vertical: 20), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - OrgName, - style: AppTextStyle.blackSize18Bold.copyWith( - color: AppColors.blackColor, fontSize: 18), - ), - const SizedBox(height: 15), - Flexible( - child: BorderTextField( - hint: CompanyNameHint, - controller: _orgNameController, - textCapitalization: TextCapitalization.words, - validator: (val) => - viewModel.validateNotEmptyField(val!), - ), - ), - const SizedBox(height: 15), - Text( - OrgNameDesc, - style: AppTextStyle.lightGreySize16 - .copyWith(fontSize: 15, color: AppColors.greyColor), - ), - ], - ), + leading: Icons.close, + leadingPress: () => viewModel.back(), + actions: [ + TextButton( + onPressed: () { + if (!_formKey.currentState!.validate()) return; + viewModel.updateOrgNameAndUrl(org.id.toString(), + _orgNameController.text, _orgUrlController.text); + }, + child: Text( + Save, + style: _dark + ? AppTextStyle.lightGreySize16 + : AppTextStyle.darkGreySize16, ), - const Divider(color: AppColors.greyColor, thickness: 1), - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 25, vertical: 20), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - OrgUrl, - style: AppTextStyle.blackSize18Bold.copyWith( - color: AppColors.blackColor, fontSize: 18), - ), - const SizedBox(height: 15), - Row( - crossAxisAlignment: CrossAxisAlignment.center, + ), + ], + ), + body: Stack( + fit: StackFit.expand, + children: [ + Form( + key: _formKey, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 25, vertical: 20), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + OrgName, + style: _dark + ? AppTextStyle.whiteSize18Bold + : AppTextStyle.blackSize18Bold, + ), + const SizedBox(height: 15), Flexible( child: BorderTextField( - hint: "hng_i8", - controller: _orgUrlController, - textCapitalization: TextCapitalization.none, - validator: viewModel.vaidateOrgUrl, - textAlign: TextAlign.end, + hint: CompanyNameHint, + controller: _orgNameController, + textCapitalization: TextCapitalization.words, + validator: (val) => + viewModel.validateNotEmptyField(val!), ), ), - const SizedBox(width: 10), + const SizedBox(height: 15), Text( - '.zurichat.com', - style: AppTextStyle.lightGreySize16 - .copyWith(fontSize: 15), + OrgNameDesc, + style: _dark + ? AppTextStyle.lightGreySize16 + : AppTextStyle.darkGreySize16, ), ], ), - const SizedBox(height: 15), - Text( - OrgUrlDesc, - style: AppTextStyle.lightGreySize16 - .copyWith(fontSize: 15, color: AppColors.greyColor), + ), + const Divider(color: AppColors.greyColor, thickness: 1), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 25, vertical: 20), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + OrgUrl, + style: _dark + ? AppTextStyle.whiteSize18Bold + : AppTextStyle.blackSize18Bold, + ), + const SizedBox(height: 15), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Flexible( + child: BorderTextField( + hint: "hng_i8", + controller: _orgUrlController, + textCapitalization: TextCapitalization.none, + validator: viewModel.vaidateOrgUrl, + textAlign: TextAlign.end, + ), + ), + const SizedBox(width: 10), + Text( + '.zurichat.com', + style: _dark + ? AppTextStyle.lightGreySize16 + : AppTextStyle.darkGreySize16, + ), + ], + ), + const SizedBox(height: 15), + Text( + OrgUrlDesc, + style: _dark + ? AppTextStyle.lightGreySize16 + : AppTextStyle.darkGreySize16, + ), + ], ), - ], - ), + ), + ], ), - ], - ), - ), - Visibility( - visible: viewModel.isBusy, - child: Container( - alignment: Alignment.center, - height: 100, - child: const ZuriLoader(isTransparent: true), - ), + ), + Visibility( + visible: viewModel.isBusy, + child: Container( + alignment: Alignment.center, + height: 100, + child: const ZuriLoader(isTransparent: true), + ), + ), + ], ), - ], - ), + ); + }, ); } } diff --git a/lib/ui/view/organization/organization_settings/organization_settings_view.dart b/lib/ui/view/organization/organization_settings/organization_settings_view.dart index 6bd47c190..e523be1e4 100644 --- a/lib/ui/view/organization/organization_settings/organization_settings_view.dart +++ b/lib/ui/view/organization/organization_settings/organization_settings_view.dart @@ -16,27 +16,27 @@ class OrganizationSettingsView extends StatelessWidget { @override Widget build(BuildContext context) { final bool _dark = Theme.of(context).brightness == Brightness.dark; - return ViewModelBuilder.reactive( viewModelBuilder: () => OrganizationSettingsViewModel(), - onModelReady: (model) => model.init(org.name!, org.organizationUrl!), builder: (context, model, child) { return Scaffold( appBar: ZuriAppBar( title: OrgSettings, subtitle: org.name, whiteBackground: true, - leading: Icons.chevron_left, - leadingPress: () => model.back(), isDarkMode: _dark, + leading: Icons.arrow_back_ios_new, + leadingPress: () => model.back(), ), body: Container( - margin: const EdgeInsets.all(20), - decoration: const BoxDecoration( - boxShadow: [ + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 20), + decoration: BoxDecoration( + color: _dark ? AppColors.blackColor : AppColors.whiteColor, + boxShadow: const [ BoxShadow( color: AppColors.shadowColor, - spreadRadius: 10, + spreadRadius: 5, + blurRadius: 10, ), ], ), @@ -51,15 +51,19 @@ class OrganizationSettingsView extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(EditOrgIcon, - style: _dark - ? AppTextStyle.whiteSize18Bold - : AppTextStyle.darkGreySize18Bold), + Text( + EditOrgIcon, + style: _dark + ? AppTextStyle.whiteSize18Bold + : AppTextStyle.blackSize18Bold, + ), const SizedBox(height: 10), - Text(EditOrgIconDesc, - style: _dark - ? AppTextStyle.whiteSize14 - : AppTextStyle.lightGreySize14), + Text( + EditOrgIconDesc, + style: _dark + ? AppTextStyle.lightGreySize16 + : AppTextStyle.darkGreySize16, + ), ], ), ), @@ -85,24 +89,27 @@ class OrganizationSettingsView extends StatelessWidget { TextSpan( text: EditOrgNameUrlDesc1, style: _dark - ? AppTextStyle.whiteSize14 - : AppTextStyle.darkGreySize14, + ? AppTextStyle.lightGreySize16 + : AppTextStyle.darkGreySize16, ), TextSpan( - text: org.name, - style: _dark - ? AppTextStyle.whiteSize14Bold - : AppTextStyle.darkGreySize14Bold), + text: org.name, + style: _dark + ? AppTextStyle.whiteSize16Bold + : AppTextStyle.blackSize16Bold, + ), TextSpan( - text: EditOrgNameUrlDesc2, - style: _dark - ? AppTextStyle.whiteSize14 - : AppTextStyle.darkGreySize14), + text: EditOrgNameUrlDesc2, + style: _dark + ? AppTextStyle.lightGreySize16 + : AppTextStyle.darkGreySize16, + ), TextSpan( - text: org.organizationUrl ?? '', - style: _dark - ? AppTextStyle.whiteSize14Bold - : AppTextStyle.darkGreySize14Bold), + text: org.organizationUrl ?? '', + style: _dark + ? AppTextStyle.whiteSize16Bold + : AppTextStyle.blackSize16Bold, + ), ], ), ), diff --git a/lib/ui/view/organization/organization_settings/organization_settings_view_model.dart b/lib/ui/view/organization/organization_settings/organization_settings_view_model.dart index 7f1b7e340..87023f655 100644 --- a/lib/ui/view/organization/organization_settings/organization_settings_view_model.dart +++ b/lib/ui/view/organization/organization_settings/organization_settings_view_model.dart @@ -35,11 +35,10 @@ class OrganizationSettingsViewModel extends BaseViewModel with ValidatorMixin { } void navigateToWorkspaceName(OrganizationModel org) { - //TODO: getting ready - // navigation.navigateTo( - // Routes.organizationNameUrl, - // arguments: OrganizationNameUrlArguments(org: org), - // ); + navigation.navigateTo( + Routes.organizationNameUrl, + arguments: OrganizationNameUrlArguments(org: org), + ); } void navigateToWorkspaceLogo(OrganizationModel org) { @@ -53,18 +52,23 @@ class OrganizationSettingsViewModel extends BaseViewModel with ValidatorMixin { try { setBusy(true); if (tempImage == null) return; - await _zuriApi.updateOrgLogo(orgId, tempImage!, token); + final res = await _zuriApi.updateOrgLogo(orgId, tempImage!, token); setBusy(false); - navigation - .popUntil((route) => route.settings.name == Routes.organizationView); - snackbar.showCustomSnackBar( - variant: SnackbarType.success, message: 'Update Successful'); + if (res) { + navigation.popUntil( + (route) => route.settings.name == Routes.organizationView); + snackbar.showCustomSnackBar( + variant: SnackbarType.success, message: 'Update Successful'); + } else { + snackbar.showCustomSnackBar( + variant: SnackbarType.failure, + message: 'Error Updating Workspace logo'); + } } catch (e) { setBusy(false); log.e(e.toString()); snackbar.showCustomSnackBar( - variant: SnackbarType.failure, - message: 'Error Updating Workspace logo'); + variant: SnackbarType.failure, message: e.toString()); } } @@ -80,10 +84,11 @@ class OrganizationSettingsViewModel extends BaseViewModel with ValidatorMixin { String orgId, String orgName, String orgUrl) async { try { final parsedUrl = '$orgUrl.zurichat.com'; - setBusy(true); if (orgName != name) await _zuriApi.updateOrgName(orgId, orgName, token); - if (orgUrl != url) await _zuriApi.updateOrgUrl(orgId, parsedUrl, token); + if (parsedUrl != url) { + await _zuriApi.updateOrgUrl(orgId, parsedUrl, token); + } setBusy(false); navigation .popUntil((route) => route.settings.name == Routes.organizationView); @@ -93,7 +98,7 @@ class OrganizationSettingsViewModel extends BaseViewModel with ValidatorMixin { setBusy(false); log.e(e.toString()); snackbar.showCustomSnackBar( - variant: SnackbarType.failure, message: 'Update not successful'); + variant: SnackbarType.failure, message: 'Update not successful: $e'); } } diff --git a/lib/ui/view/organization/organization_view/organization_view.dart b/lib/ui/view/organization/organization_view/organization_view.dart index d24caa663..3db5afbc2 100644 --- a/lib/ui/view/organization/organization_view/organization_view.dart +++ b/lib/ui/view/organization/organization_view/organization_view.dart @@ -153,8 +153,8 @@ class OrganizationTile extends ViewModelWidget { return ListTile( onTap: () => viewModel.onTap(org), leading: Container( - height: MediaQuery.of(context).size.height * 0.06, - width: MediaQuery.of(context).size.height * 0.06, + height: 40, + width: 40, padding: const EdgeInsets.all(2), decoration: BoxDecoration( color: viewModel.currentOrgId == org.id diff --git a/test/helpers/test_helpers.mocks.dart b/test/helpers/test_helpers.mocks.dart index d753a2f8c..4eeb08453 100644 --- a/test/helpers/test_helpers.mocks.dart +++ b/test/helpers/test_helpers.mocks.dart @@ -3,7 +3,6 @@ // Do not manually edit this file. import 'dart:async' as _i2; - import 'dart:io' as _i24; import 'dart:ui' as _i15; @@ -39,11 +38,6 @@ import 'package:zurichat/services/user_service.dart' as _i8; import 'package:zurichat/utilities/enums.dart' as _i27; import 'package:zurichat/utilities/failures.dart' as _i4; -import 'package:mockito/mockito.dart' as _i1; -import 'package:stacked_services/stacked_services.dart' as _i11; -import 'package:stacked_themes/src/theme_manager.dart' as _i14; -import 'package:stacked_themes/src/theme_service.dart' as _i13; - // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references @@ -771,14 +765,12 @@ class MockChannelsApiService extends _i1.Mock returnValue: Future>.value([])) as _i2.Future>); @override - _i2.Future> getChannelPinnedMessages( String? channelId) => (super.noSuchMethod( Invocation.method(#getChannelPinnedMessages, [channelId]), returnValue: Future>.value( <_i18.PinnedMessage>[])) as _i2.Future>); - @override _i2.Future changeChannelMessagePinnedState( String? channelId, String? messageId, String? userId, bool? pinned) => @@ -795,13 +787,11 @@ class MockChannelsApiService extends _i1.Mock #sendChannelMessages, [channelId, userId, message, media]), returnValue: Future.value()) as _i2.Future); @override - _i2.Future> fetchChannel() => (super.noSuchMethod(Invocation.method(#fetchChannel, []), returnValue: Future>.value(<_i19.ChannelModel>[])) as _i2.Future>); - @override _i2.Future createChannels( {String? name, @@ -823,12 +813,10 @@ class MockChannelsApiService extends _i1.Mock (super.noSuchMethod(Invocation.method(#deleteChannel, [orgId, channelId]), returnValue: Future.value(false)) as _i2.Future); @override - _i2.Future?> getChannelMembers(dynamic id) => (super.noSuchMethod(Invocation.method(#getChannelMembers, [id]), returnValue: Future?>.value()) as _i2.Future?>); - @override _i2.Future? dispose() => (super.noSuchMethod( Invocation.method(#dispose, []), @@ -840,9 +828,7 @@ class MockChannelsApiService extends _i1.Mock /// A class which mocks [CentrifugeService]. /// /// See the documentation for Mockito's code generation for more information. - class MockCentrifugeService extends _i1.Mock implements _i21.CentrifugeService { - @override _i2.StreamController get messageStreamController => (super.noSuchMethod(Invocation.getter(#messageStreamController), @@ -855,14 +841,12 @@ class MockCentrifugeService extends _i1.Mock implements _i21.CentrifugeService { Invocation.setter(#messageStreamController, _messageStreamController), returnValueForMissingStub: null); @override - Map get subList => (super.noSuchMethod(Invocation.getter(#subList), returnValue: {}) as Map); @override set subList(Map? _subList) => - super.noSuchMethod(Invocation.setter(#subList, _subList), returnValueForMissingStub: null); @override @@ -926,9 +910,7 @@ class MockCentrifugeService extends _i1.Mock implements _i21.CentrifugeService { /// A class which mocks [ZuriApi]. /// /// See the documentation for Mockito's code generation for more information. - class MockZuriApi extends _i1.Mock implements _i5.ZuriApi { - @override _i3.Dio get dio => (super.noSuchMethod(Invocation.getter(#dio), returnValue: _FakeDio_2()) @@ -1047,11 +1029,11 @@ class MockZuriApi extends _i1.Mock implements _i5.ZuriApi { Invocation.method(#updateOrgName, [orgId, name, token]), returnValue: Future.value()) as _i2.Future); @override - _i2.Future updateOrgLogo( + _i2.Future updateOrgLogo( String? orgId, _i24.File? image, dynamic token) => (super.noSuchMethod( Invocation.method(#updateOrgLogo, [orgId, image, token]), - returnValue: Future.value()) as _i2.Future); + returnValue: Future.value(false)) as _i2.Future); @override _i2.Future addMemberToChannel( String? channelId, String? orgId, String? userId, dynamic token) => @@ -1067,17 +1049,13 @@ class MockZuriApi extends _i1.Mock implements _i5.ZuriApi { Invocation.method(#addMemberToOrganization, [orgId, email, token]), returnValue: Future.value()) as _i2.Future); @override - _i2.Future> fetchMembersInOrganization( - String? orgId, dynamic token) => (super.noSuchMethod( Invocation.method(#fetchMembersInOrganization, [orgId, token]), returnValue: - Future>.value(<_i25.UserSearch>[])) as _i2.Future>); - @override _i2.Future getChannelSocketId( String? channelId, String? orgId, dynamic token) => @@ -1133,14 +1111,12 @@ class MockZuriApi extends _i1.Mock implements _i5.ZuriApi { [channelMessageId, content, files, orgId, userId, channelId]), returnValue: Future.value(false)) as _i2.Future); @override - _i2.Future> fetchChannel( String? orgId, dynamic token) => (super.noSuchMethod(Invocation.method(#fetchChannel, [orgId, token]), returnValue: Future>.value(<_i19.ChannelModel>[])) as _i2.Future>); - @override _i2.Future createChannels( {String? name, @@ -1173,9 +1149,7 @@ class MockZuriApi extends _i1.Mock implements _i5.ZuriApi { super.noSuchMethod(Invocation.method( #inviteToOrganizationWithNormalMail, [organizationId, body, token])); @override - List<_i12.ThemeData> getThemes() => - (super.noSuchMethod(Invocation.method(#getThemes, []), returnValue: <_i12.ThemeData>[]) as List<_i12.ThemeData>); @override @@ -1216,10 +1190,8 @@ class MockZuriApi extends _i1.Mock implements _i5.ZuriApi { (super.noSuchMethod(Invocation.method(#handleApiError, [e]), returnValue: _FakeFailure_3()) as _i4.Failure); @override - _i2.Future uploadImage(_i24.File? image, {String? token, String? pluginId}) => - (super.noSuchMethod( Invocation.method( #uploadImage, [image], {#token: token, #pluginId: pluginId}), @@ -1335,7 +1307,6 @@ class MockJumpToApi extends _i1.Mock implements _i28.JumpToApi { <_i29.ChannelsSearch>[])) as _i2.Future>); @override - _i2.Future> fetchListOfMembers() => (super.noSuchMethod( Invocation.method(#fetchListOfMembers, []), returnValue: Future>.value(<_i25.UserSearch>[])) @@ -1345,7 +1316,6 @@ class MockJumpToApi extends _i1.Mock implements _i28.JumpToApi { (super.noSuchMethod(Invocation.method(#fetchList, []), returnValue: Future>.value(<_i25.NewUser>[])) as _i2.Future>); - @override String toString() => super.toString(); } @@ -1366,10 +1336,8 @@ class MockMediaService extends _i1.Mock implements _i30.MediaService { Invocation.method(#getVideo, [], {#fromGallery: fromGallery}), returnValue: Future<_i24.File?>.value()) as _i2.Future<_i24.File?>); @override - _i2.Future uploadImage(_i24.File? file, String? pluginId) => (super.noSuchMethod(Invocation.method(#uploadImage, [file, pluginId]), - returnValue: Future.value()) as _i2.Future); @override String toString() => super.toString(); @@ -1434,14 +1402,12 @@ class MockOrganizationApiService extends _i1.Mock returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i2.Future); @override - _i2.Future> fetchMembersInOrganization(String? orgId) => (super.noSuchMethod( Invocation.method(#fetchMembersInOrganization, [orgId]), returnValue: Future>.value(<_i25.UserSearch>[])) as _i2.Future>); - @override _i2.Future<_i7.OrganizationMemberModelList> getOrganizationMemberList( String? orgId) =>