package Ġcom . github . the apache 6 4 . swipe search . ui . comp osable . tw yper . flip Ċ Ċ import Ġandroidx . compose . animation . core . Anim atable Ċ import Ġandroidx . compose . animation . core . Animation Vector 1 D Ċ import Ġandroidx . compose . animation . core . t ween Ċ import Ġandroidx . compose . runtime . Composable Ċ import Ġandroidx . compose . runtime . remember Ċ import Ġandroidx . compose . runtime . remember Coroutine Scope Ċ import Ġandroidx . compose . ui . platform . Local Configuration Ċ import Ġandroidx . compose . ui . platform . Local Density Ċ import Ġandroidx . compose . ui . unit . dp Ċ import Ġcom . github . the apache 6 4 . swipe search . ui . comp osable . tw yper . Card Controller Ċ import Ġcom . github . the apache 6 4 . swipe search . ui . comp osable . tw yper . Card Controller Impl Ċ import Ġkotlinx . coroutines . Coroutine Scope Ċ import Ġkotlinx . coroutines . launch ĊĊ Ċ /** Ċ Ġ* ĠTo Ġcontrol Ġindividual Ġcard Ċ Ġ*/ Ċ interface ĠFlip Card Controller : ĠCard Controller Ġ{ ĊĠĠĠ Ġval Ġcard Flip Rotation : ĠFloat ĊĠĠĠ Ġval Ġcard Front Alpha : ĠFloat ĊĠĠĠ Ġval Ġcard Back Alpha : ĠFloat ĊĠĠĠ Ġvar Ġstate : ĠFlip State ĊĊĠĠĠ Ġfun Ġis Card F lipped (): ĠBoolean ĊĠĠĠ Ġfun Ġset Card Flip State () ĊĠĠĠ Ġfun Ġflip To Front () ĊĠĠĠ Ġfun Ġflip To Back () Ċ } Ċ Ċ @ Composable Ċ fun Ġremember Flip Card Controller (): ĠFlip Card Controller Ġ{ ĊĠĠĠ Ġval Ġscope Ġ= Ġremember Coroutine Scope () ĊĠĠĠ Ġval Ġscreen Width Ġ= ĊĠĠĠĠĠĠĠ Ġwith ( Local Density . current ) Ġ{ ĠLocal Configuration . current . screen Width Dp . dp . to Px () Ġ} ĊĠĠĠ Ġreturn Ġremember Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġswipe X Ġ= ĠAnim atable ( 0 f ) ĊĠĠĠĠĠĠĠ Ġval Ġswipe Y Ġ= ĠAnim atable ( 0 f ) ĊĠĠĠĠĠĠĠ Ġval Ġflip Rotation Ġ= ĠAnim atable ( 0 f ) ĊĠĠĠĠĠĠĠ Ġval Ġfront Alpha Ġ= ĠAnim atable ( 1 f ) ĊĠĠĠĠĠĠĠ Ġval Ġback Alpha Ġ= ĠAnim atable ( 0 f ) ĊĠĠĠĠĠĠĠ Ġval Ġcard State Ġ= ĠFlip State . FRONT ĊĠĠĠĠĠĠĠ ĠFlip Card Controller Impl ( swipe X , Ġswipe Y , Ġflip Rotation , Ġfront Alpha , Ġback Alpha , Ġcard State , Ġscope , Ġscreen Width ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ class ĠFlip Card Controller Impl ( ĊĠĠĠ Ġswipe X : ĠAnim atable < Float , ĠAnimation Vector 1 D >, ĊĠĠĠ Ġswipe Y : ĠAnim atable < Float , ĠAnimation Vector 1 D >, ĊĠĠĠ Ġprivate Ġval Ġflip : ĠAnim atable < Float , ĠAnimation Vector 1 D >, ĊĠĠĠ Ġprivate Ġval Ġfront Alpha : ĠAnim atable < Float , ĠAnimation Vector 1 D >, ĊĠĠĠ Ġprivate Ġval Ġback Alpha : ĠAnim atable < Float , ĠAnimation Vector 1 D >, ĊĠĠĠ Ġprivate Ġvar Ġcard State : ĠFlip State , ĊĠĠĠ Ġprivate Ġval Ġscope : ĠCor outine Scope , ĊĠĠĠ Ġscreen Width : ĠFloat Ċ ) Ġ: ĠFlip Card Controller , ĠCard Controller Impl ( swipe X , Ġswipe Y , Ġscope , Ġscreen Width ) Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠF LI P _ ROT ATION _ DURATION _ IN _ M ILL IS Ġ= Ġ 5 0 0 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠC ARD _ FRONT _ ALPHA _ DURATION _ IN _ M ILL IS Ġ= Ġ 4 0 0 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠC ARD _ RE VERSE _ ALPHA _ DURATION _ IN _ M ILL IS Ġ= Ġ 2 0 0 ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠINITIAL _ FLI P _ ANGLE Ġ= Ġ 0 f ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠFIN AL _ FLI P _ ANGLE Ġ= Ġ 1 8 0 f ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġval Ġcard Flip Rotation : ĠFloat ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġflip . value ĊĊĠĠĠ Ġoverride Ġval Ġcard Front Alpha : ĠFloat ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġfront Alpha . value ĊĊĠĠĠ Ġoverride Ġval Ġcard Back Alpha : ĠFloat ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġback Alpha . value ĊĊĠĠĠ Ġoverride Ġvar Ġstate : ĠFlip State Ġ= Ġcard State ĊĊĠĠĠ Ġoverride Ġfun Ġis Card F lipped (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġcard State Ġ== ĠFlip State . BACK ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġset Card Flip State () Ġ{ ĊĠĠĠĠĠĠĠ Ġif (! is Card F lipped ()){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġflip To Back () ĊĠĠĠĠĠĠĠ Ġ} else { ĊĠĠĠĠĠĠĠĠĠĠĠ Ġflip To Front () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġflip To Front () Ġ{ ĊĠĠĠĠĠĠĠ Ġscope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcard State Ġ= ĠFlip State . FRONT ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ Ġflip . animate To ( INITIAL _ FLI P _ ANGLE , Ġt ween ( FLI P _ ROT ATION _ DURATION _ IN _ M ILL IS )) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ Ġfront Alpha . animate To ( 1 f , Ġt ween ( CARD _ FRONT _ ALPHA _ DURATION _ IN _ M ILL IS )) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ Ġback Alpha . animate To ( 0 f , Ġt ween ( CARD _ RE VERSE _ ALPHA _ DURATION _ IN _ M ILL IS )) Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġflip To Back () Ġ{ ĊĠĠĠĠĠĠĠ Ġscope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcard State Ġ= ĠFlip State . BACK ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ Ġflip . animate To ( FINAL _ FLI P _ ANGLE , Ġt ween ( FLI P _ ROT ATION _ DURATION _ IN _ M ILL IS )) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ Ġfront Alpha . animate To ( 0 f , Ġt ween ( CARD _ RE VERSE _ ALPHA _ DURATION _ IN _ M ILL IS )) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ Ġback Alpha . animate To ( 1 f , Ġt ween ( CARD _ FRONT _ ALPHA _ DURATION _ IN _ M ILL IS )) Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }