@@ -100,12 +100,14 @@ class _SettingPageState extends State<SettingPage> {
100100 listener: (context, state) {
101101 if (state is SuccessLoadUserSettingState ) {
102102 userSetting = state.response;
103+ setState (() {});
103104 } else if (state is SuccessUpdateUserSettingState ) {
104105 final newUserSetting = UserSettingResponse (
105106 id: userSetting! .id! ,
106107 isEnableBlurScreenshot: ! (userSetting! .isEnableBlurScreenshot! ),
107108 userId: userSetting! .userId,
108109 name: userSetting! .name,
110+ isOverrideBlurScreenshot: userSetting? .isOverrideBlurScreenshot ?? false ,
109111 );
110112 userSetting = newUserSetting;
111113 } else if (state is FailureSettingState ) {
@@ -1461,6 +1463,11 @@ class _SettingPageState extends State<SettingPage> {
14611463 }
14621464
14631465 Widget buildWidgetUserSetting () {
1466+ final isOverrideBlurScreenshot = userSetting? .isOverrideBlurScreenshot ?? false ;
1467+ var description = 'description_screenshot_blur_user' .tr ();
1468+ if (isOverrideBlurScreenshot && (userRole == UserRole .admin || userRole == UserRole .employee)) {
1469+ description += ' ${'this_setting_is_override_by_super_admin' .tr ()}' ;
1470+ }
14641471 return Row (
14651472 crossAxisAlignment: CrossAxisAlignment .start,
14661473 children: [
@@ -1473,7 +1480,7 @@ class _SettingPageState extends State<SettingPage> {
14731480 style: Theme .of (context).textTheme.bodyLarge,
14741481 ),
14751482 Text (
1476- 'description_screenshot_blur_user' . tr () ,
1483+ description ,
14771484 style: Theme .of (context).textTheme.bodyMedium? .copyWith (
14781485 color: Colors .grey,
14791486 ),
@@ -1482,54 +1489,62 @@ class _SettingPageState extends State<SettingPage> {
14821489 ),
14831490 ),
14841491 const SizedBox (width: 16 ),
1485- BlocBuilder <SettingBloc , SettingState >(
1486- builder: (context, state) {
1487- if (state is LoadingCenterSettingState || state is LoadingButtonSettingState ) {
1488- return const Padding (
1489- padding: EdgeInsets .all (8.0 ),
1490- child: WidgetCustomCircularProgressIndicator (),
1491- );
1492- } else if ((state is FailureSettingState || state is FailureSnackBarSettingState ) && userSetting == null ) {
1493- return TextButton (
1494- onPressed: doLoadUserSetting,
1495- child: Text ('refresh' .tr ()),
1496- );
1497- }
1492+ SizedBox (
1493+ width: 76 ,
1494+ child: Align (
1495+ alignment: Alignment .centerRight,
1496+ child: BlocBuilder <SettingBloc , SettingState >(
1497+ builder: (context, state) {
1498+ if (state is LoadingCenterSettingState || state is LoadingButtonSettingState ) {
1499+ return const SizedBox (
1500+ width: 32 ,
1501+ height: 32 ,
1502+ child: WidgetCustomCircularProgressIndicator (),
1503+ );
1504+ } else if ((state is FailureSettingState || state is FailureSnackBarSettingState ) &&
1505+ userSetting == null ) {
1506+ return TextButton (
1507+ onPressed: doLoadUserSetting,
1508+ child: Text ('refresh' .tr ()),
1509+ );
1510+ }
14981511
1499- if (userSetting == null ) {
1500- return Container ();
1501- }
1512+ if (userSetting == null ) {
1513+ return Container ();
1514+ }
15021515
1503- return Switch .adaptive (
1504- value: userSetting? .isEnableBlurScreenshot ?? false ,
1505- activeColor: Theme .of (context).colorScheme.primary,
1506- onChanged: userRole == UserRole .superAdmin
1507- ? (value) {
1508- final id = userSetting? .id;
1509- final userId = userSetting? .userId;
1510- if (id == null || userId == null ) {
1511- widgetHelper.showSnackBar (context, 'invalid_id_or_user_id' .tr ());
1512- return ;
1513- }
1516+ return Switch .adaptive (
1517+ value: userSetting? .isEnableBlurScreenshot ?? false ,
1518+ activeColor: Theme .of (context).colorScheme.primary,
1519+ onChanged: isOverrideBlurScreenshot && (userRole == UserRole .admin || userRole == UserRole .employee)
1520+ ? null
1521+ : (value) {
1522+ final id = userSetting? .id;
1523+ final userId = userSetting? .userId;
1524+ if (id == null || userId == null ) {
1525+ widgetHelper.showSnackBar (context, 'invalid_id_or_user_id' .tr ());
1526+ return ;
1527+ }
15141528
1515- final body = UserSettingBody (
1516- data: [
1517- ItemUserSettingBody (
1518- id: userSetting! .id! ,
1519- isEnableBlurScreenshot: value,
1520- userId: userSetting! .userId! ,
1521- ),
1522- ],
1523- );
1524- settingBloc.add (
1525- UpdateUserSettingEvent (
1526- body: body,
1527- ),
1528- );
1529- }
1530- : null ,
1531- );
1532- },
1529+ final body = UserSettingBody (
1530+ data: [
1531+ ItemUserSettingBody (
1532+ id: userSetting! .id! ,
1533+ isEnableBlurScreenshot: value,
1534+ userId: userSetting! .userId! ,
1535+ ),
1536+ ],
1537+ );
1538+ settingBloc.add (
1539+ UpdateUserSettingEvent (
1540+ body: body,
1541+ ),
1542+ );
1543+ },
1544+ );
1545+ },
1546+ ),
1547+ ),
15331548 ),
15341549 ],
15351550 );
0 commit comments