setBeautyStyle method

Future<void> setBeautyStyle(
  1. TRTCBeautyStyle style,
  2. int beautyLevel,
  3. int whitenessLevel,
  4. int ruddinessLevel,
)

Implementation

Future<void> setBeautyStyle(
  TRTCBeautyStyle style,
  int beautyLevel,
  int whitenessLevel,
  int ruddinessLevel,
) async {
  final viewId = _trtcStreamInfoObs.trtcLocalPreviewViewId.value;
  final rememberBeautyConfig =
      getConfig().basicConfig?.rememberBeautyConfig ?? false;
  if (viewId != -1) {
    await TRTC.setBeautyStyle(
      style,
      beautyLevel,
      whitenessLevel,
      ruddinessLevel,
    );
    _trtcStreamInfoObs.updateTRTCBeautyLevel(beautyLevel);
    _trtcStreamInfoObs.updateTRTCWhitenessLevel(whitenessLevel);
    _trtcStreamInfoObs.updateTRTCRuddinessLevel(ruddinessLevel);
    await TRTC.updateLocalView(viewId);
    if (rememberBeautyConfig) {
      final beautyConfig = {
        "beautyLevel": beautyLevel,
        "whitenessLevel": whitenessLevel,
        "ruddinessLevel": ruddinessLevel,
      };
      final beautyConfigJson = jsonEncode(beautyConfig);
      final beautyConfigKey = "beautyConfig-${_config.userId}";
      sharedPreferences.setString(beautyConfigKey, beautyConfigJson);
      TCICLog.info(
        "save beautyConfig to sharedPreferences: $beautyConfigKey: $beautyConfigJson",
        actionModule: ActionModule.tcicController.name,
        actionName: ActionName.setBeautyStyle.name,
      );
    } else {
      TCICLog.info(
        "not save beautyConfig to sharedPreferences",
        actionModule: ActionModule.tcicController.name,
        actionName: ActionName.setBeautyStyle.name,
      );
    }
  } else {
    TCICLog.error(
      'viewId is -1',
      actionModule: ActionModule.tcicController.name,
      actionName: ActionName.setBeautyStyle.name,
    );
  }
}