11import React , { useState , useEffect } from "react" ;
2- import { ActivityIndicator , View , Dimensions } from "react-native" ;
2+ import { ActivityIndicator , View , StyleSheet } from "react-native" ;
3+ import { Slider } from "@miblanchard/react-native-slider" ;
34import styled from "styled-components" ;
4-
5- // import Swipeable from "react-native-swipeable-patched";
6- import Ionicons from "react-native-vector-icons/Ionicons" ;
7-
8- import SwipeButton from "rn-swipe-button" ;
5+ import { spaceBadger } from "../../themes/spaceBadger" ;
96
107import T from "../T" ;
8+ import Spacer from "../Spacer" ;
9+ import Ionicons from "react-native-vector-icons/Ionicons" ;
1110
1211const SWIPEABLE_WIDTH_PERCENT = 78 ;
1312
1413const SwipeButtonContainer = styled ( View ) `
15- overflow: hidden ;
14+ overflow: visible ;
1615 width: ${ SWIPEABLE_WIDTH_PERCENT } %;
17- height: 64px ;
16+ height: 70px ;
1817 align-self: center;
1918` ;
2019
21- const SwipeContent = styled ( View ) < { activated : boolean } > `
22- height: 64px;
23- padding-right: 10px;
24- align-items: flex-end;
25- justify-content: center;
26-
27- background-color: ${ props =>
28- props . activated ? props . theme . success500 : props . theme . pending500 } ;
20+ const SwipeContent = styled ( View ) `
21+ border-radius: 45px;
22+ background-color: ${ props => props . theme . primary500 } ;
2923` ;
3024
3125const SwipeActivity = styled ( View ) `
32- height: 64px;
3326 align-items: center;
3427 justify-content: center;
3528 align-self: center;
36- flex-direction: row;
29+ ` ;
30+
31+ const Swiper = styled ( Slider ) `
32+ flex: 1;
33+ margin-left: 10;
34+ margin-right: 10;
35+ align-items: stretch;
36+ justify-content: center;
37+ overflow: visible;
3738` ;
3839
3940type ButtonStates =
@@ -50,24 +51,55 @@ interface Props {
5051}
5152
5253const SwipeButtonAtom = ( { swipeFn, labelAction } : Props ) => {
54+ const [ visible , setVisible ] = useState ( true ) ;
55+ const [ sliderValue , setSliderValue ] = useState ( 0 ) ;
56+
57+ const sliding = ( value : any ) => {
58+ if ( value > 90 ) {
59+ swipeFn ( ) ;
60+ setVisible ( false ) ;
61+ }
62+ setSliderValue ( value ) ;
63+ } ;
64+
65+ const endSlide = ( ) => {
66+ setSliderValue ( 0 ) ;
67+ } ;
68+
5369 const forwardCircle = ( ) => (
54- < Ionicons name = "ios-arrow-forward-circle" size = { 25 } color = "#11a87e" />
70+ < Ionicons
71+ name = "ios-chevron-forward-circle"
72+ size = { 60 }
73+ color = { spaceBadger . fg100 }
74+ />
5575 ) ;
5676
5777 return (
5878 < SwipeButtonContainer >
59- < SwipeButton
60- onSwipeSuccess = { ( ) => swipeFn ( ) }
61- swipeSuccessThreshold = { 70 }
62- titleColor = "#FFFFFF"
63- railBackgroundColor = "#11a87e"
64- railBorderColor = "#11a87e"
65- railFillBackgroundColor = "#FFFFFF"
66- railFillBorderColor = "#FFFFFF"
67- thumbIconBackgroundColor = "#FFFFFF"
68- thumbIconComponent = { forwardCircle }
69- title = { `Slide ${ labelAction } ` }
79+ < ActivityIndicator
80+ animating = { ! visible }
81+ hidesWhenStopped = { true }
82+ size = { visible ? 0 : "large" }
83+ color = "#11a87e"
7084 />
85+ < T center = { true } weight = { "bold" } type = { "primary" } >
86+ { visible ? `Slide ${ labelAction } ` : "" }
87+ </ T >
88+ < Spacer tiny />
89+ { visible && (
90+ < SwipeContent >
91+ < Swiper
92+ minimumValue = { 0 }
93+ maximumValue = { 100 }
94+ minimumTrackTintColor = { spaceBadger . primary900 }
95+ maximumTrackTintColor = { spaceBadger . primary500 }
96+ renderThumbComponent = { forwardCircle }
97+ value = { sliderValue }
98+ onValueChange = { value => sliding ( value ) }
99+ onSlidingComplete = { ( ) => endSlide ( ) }
100+ />
101+ </ SwipeContent >
102+ ) }
71103 </ SwipeButtonContainer >
72104 ) ;
73105} ;
0 commit comments