File

src/app/components/popups/new-experience-popup/new-experience-popup.component.ts

Implements

OnInit

Metadata

Index

Properties
Methods

Constructor

constructor(preference: SharedPreferences, popoverCtrl: PopoverController, navParams: NavParams, events: Events, telemetryGeneratorService: TelemetryGeneratorService, commonUtilService: CommonUtilService)
Parameters :
Name Type Optional
preference SharedPreferences No
popoverCtrl PopoverController No
navParams NavParams No
events Events No
telemetryGeneratorService TelemetryGeneratorService No
commonUtilService CommonUtilService No

Methods

Async closePopover
closePopover()
Returns : any
ngOnInit
ngOnInit()
Returns : void
Async switchToHomeTabs
switchToHomeTabs()
Returns : any
Async switchToNewTheme
switchToNewTheme()
Returns : any

Properties

appName
Type : string
Default value : ''
appTheme
Default value : AppThemes.DEFAULT
isPopoverPresent
Default value : false
import { Component, Inject, OnInit } from '@angular/core';
import { NavParams, PopoverController } from '@ionic/angular';
import { AppThemes, PreferenceKey, SwitchableTabsConfig } from '@app/app/app.constant';
import { SharedPreferences } from 'sunbird-sdk';
import { Events } from '@app/util/events';
import { TelemetryGeneratorService, PageId, InteractSubtype, CommonUtilService } from '@app/services';


@Component({
    selector: 'app-new-experience-popup',
    templateUrl: './new-experience-popup.component.html',
    styleUrls: ['./new-experience-popup.component.scss']
})
export class NewExperiencePopupComponent implements OnInit {
    appName = '';
    appTheme = AppThemes.DEFAULT;
    isPopoverPresent = false;
    constructor(
        @Inject('SHARED_PREFERENCES') private preference: SharedPreferences,
        private popoverCtrl: PopoverController,
        private navParams: NavParams,
        private events: Events,
        private telemetryGeneratorService: TelemetryGeneratorService,
        private commonUtilService: CommonUtilService
    ) {
    }

    ngOnInit() {
        this.appTheme = document.querySelector('html').getAttribute('data-theme');
        this.appName = this.navParams.get('appLabel').toUpperCase();
        setTimeout(() => {
            this.isPopoverPresent = true;
        }, 2000);
    }

    async closePopover() {
        const userType = await this.preference.getString(PreferenceKey.SELECTED_USER_TYPE).toPromise();
        const isNewUser = await this.preference.getBoolean(PreferenceKey.IS_NEW_USER).toPromise();
        this.telemetryGeneratorService.generateNewExprienceSwitchTelemetry(
            PageId.NEW_EXPERIENCE_POPUP,
            InteractSubtype.CANCEL_CLICKED,
            {
                userType,
                isNewUser
            }
        );
        this.preference.putString(PreferenceKey.SELECTED_SWITCHABLE_TABS_CONFIG,
            SwitchableTabsConfig.RESOURCE_COURSE_TABS_CONFIG).toPromise();
        this.popoverCtrl.dismiss();
    }

    async switchToNewTheme() {
        const userType = await this.preference.getString(PreferenceKey.SELECTED_USER_TYPE).toPromise();
        const isNewUser = await this.preference.getBoolean(PreferenceKey.IS_NEW_USER).toPromise();
        this.telemetryGeneratorService.generateNewExprienceSwitchTelemetry(
            PageId.NEW_EXPERIENCE_POPUP,
            InteractSubtype.OPTED_IN,
            {
                userType,
                isNewUser
            }
        );
        await this.switchToHomeTabs();
        this.preference.putBoolean(PreferenceKey.IS_NEW_USER, false);
        this.commonUtilService.populateGlobalCData();
        this.popoverCtrl.dismiss();
    }

    async switchToHomeTabs() {
        this.preference.putString(PreferenceKey.SELECTED_SWITCHABLE_TABS_CONFIG,
            SwitchableTabsConfig.HOME_DISCOVER_TABS_CONFIG).toPromise();
        this.events.publish('UPDATE_TABS');
    }
}
<div>
    <div class="header-info">
        <div class="close-icon-info">
            <img src="assets/imgs/close.png" alt="close-icon" (click)="closePopover()">
        </div>
        <h4 class="theme-header-info">{{'FRMELEMNTS_LBL_NEW_EXPERIENCE_POPUP_HEADING' | translate: {'app_name': appName} }}</h4>
        <p class="learning-info">{{'FRMELEMNTS_LBL_NEW_EXPERIENCE_TEXT' | translate}}</p>
        <div class="newExperience" >
            <img src="./assets/imgs/ic_switchNewExperience.svg" alt="">
        </div>
    </div>
    <div>
        <div>
            <p class="chng-theme-text"><span class="sb-color-warning">*</span>{{'FRMELEMNTS_LBL_NEW_EXPERIENCE_WARNING_TEXT' | translate: {'app_name': appName} }}</p>
        </div>
            <div class="btn-info">
                <button class="cancel_info" (click)="closePopover()"><span>{{'CANCEL' | translate}}</span></button>
                <button class="letsgo-info" (click)="switchToNewTheme()"><span>{{'FRMELEMNTS_LBL_SWITCH_TO_NEW_EXPERIENCE' | translate | uppercase}}</span>
                </button>
            </div>
    </div>
</div>

./new-experience-popup.component.scss

@import "src/assets/styles/_variables.scss";
.header-info {
  background-color: $blue;
}
.btn-info{
  padding: 12px;
  text-align: center;
}

.letsgo-info{
  color: white;
  background-color: $blue;
  font-size: 1rem;
  padding: 12px 0;
  margin-left: 18px;
  border: 2px solid $blue;
  width: 57vw;
  float: right;
  border-radius: 20px !important;
}

.theme-header-info {
  margin-top: 0px;
  color: map-get($colors, white); 
  padding: 1rem 0.5rem 0 1rem;
}

.close-icon-info {
  float: right;
  background-color: aliceblue;
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  margin-right: 6px;
  margin-top: 5px;
  padding: 5px;
}
.learning-info{
  color: white;
  padding: 8px 8px 0px 16px
}
.chng-theme-text{
  padding: 8px
}
img.arrow-icon{
  display: inline-block;
  width: 1.125rem;
  margin-top: -3px;
  margin-left: 10px;
  &.animate {
    position: relative;
    animation: dropDown 5s linear infinite;
    animation-duration: 0.9s;
  }
}

.cancel_info{
  color: $blue !important;
  background-color: white;
  font-size: 1rem;
  padding: 14px 0;
  width: 21vw;
}
.btn-text{
  padding: 12px
}

.newExperience {
  display: flex;
  justify-content: center;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""