// Path: src/main/java/com/github/wasiqb/coteafs/appium/config/device/DelaySetting.java
// @Data
// public class DelaySetting {
//     private long afterSwipe;
//     private long afterTap;
//     private long beforeSwipe;
//     private long beforeTap;
//     private int  explicit = 30;
//     private int  implicit = 30;
// }
// 
// Path: src/main/java/com/github/wasiqb/coteafs/appium/config/enums/SwipeDirection.java
// public enum SwipeDirection {
//     /**
//      * Swipe up.
//      */
//     DOWN(0, 1),
//     /**
//      * Swipe left.
//      */
//     LEFT(-1, 0),
//     /**
//      * Swipe right.
//      */
//     RIGHT(1, 0),
//     /**
//      * Swipe up.
//      */
//     UP(0, -1);
// 
//     private final int x;
//     private final int y;
// 
//     /**
//      * @author wasiq.bhamla
//      * @since Oct 20, 2017 7:56:06 PM
//      */
//     SwipeDirection(final int x, final int y) {
//         this.x = x;
//         this.y = y;
//     }
// 
//     /**
//      * @return the x
//      * @author wasiq.bhamla
//      * @since Oct 20, 2017 7:57:09 PM
//      */
//     public int getX() {
//         return this.x;
//     }
// 
//     /**
//      * @return the y
//      * @author wasiq.bhamla
//      * @since Oct 20, 2017 7:57:09 PM
//      */
//     public int getY() {
//         return this.y;
//     }
// }
// 
// Path: src/main/java/com/github/wasiqb/coteafs/appium/config/enums/SwipeStartPosition.java
// public enum SwipeStartPosition {
//     /**
//      * Start from bottom border.
//      */
//     BOTTOM,
//     /**
//      * Start from center.
//      */
//     CENTER,
//     /**
//      * Start from left border.
//      */
//     LEFT,
//     /**
//      * Start from right border
//      */
//     RIGHT,
//     /**
//      * Start from top border.
//      */
//     TOP
// }
// 
// Path: src/main/java/com/github/wasiqb/coteafs/appium/error/DeviceElementNotDisplayedError.java
// public class DeviceElementNotDisplayedError extends CoteafsAppiumError {
//     private static final long serialVersionUID = -2632375399231145369L;
// 
//     /**
//      * @param message
//      * @author wasiq.bhamla
//      * @since 04-May-2017 11:05:48 PM
//      */
//     public DeviceElementNotDisplayedError(final String message) {
//         super(message);
//     }
// 
//     /**
//      * @param message
//      * @param cause
//      * @author wasiq.bhamla
//      * @since 04-May-2017 10:11:47 PM
//      */
//     public DeviceElementNotDisplayedError(final String message, final Throwable cause) {
//         super(message, cause);
//     }
// }


import static com.github.wasiqb.coteafs.error.util.ErrorUtil.fail;
import static io.appium.java_client.touch.WaitOptions.waitOptions;
import static io.appium.java_client.touch.offset.PointOption.point;
import static java.text.MessageFormat.format;
import static java.time.Duration.ofMillis;
import com.github.wasiqb.coteafs.appium.config.device.DelaySetting;
import com.github.wasiqb.coteafs.appium.config.enums.SwipeDirection;
import com.github.wasiqb.coteafs.appium.config.enums.SwipeStartPosition;
import com.github.wasiqb.coteafs.appium.error.DeviceElementNotDisplayedError;
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
import lombok.Builder;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
/*
 * Copyright (c) 2017, Wasiq Bhamla.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.wasiqb.coteafs.appium.utils;



/**
 * @author wasiq.bhamla
 * @since 21-Mar-2021
 */
@Builder (builderMethodName = "init", buildMethodName = "prepare")
public final class SwipeUtils<T extends TouchAction<T>> {
    private final T                  actions;
    @Builder.Default
    private final SwipeDirection     direction       = SwipeDirection.DOWN;
    @Builder.Default
    private final int                distancePercent = 20;
    private final Point              elementLocation;
    private final Dimension          elementSize;
    @Builder.Default
    private final int                maxSwipe        = 10;
    private final Dimension          screenSize;
    private final DelaySetting       setting;
    @Builder.Default
// Path: src/main/java/com/github/wasiqb/coteafs/appium/config/device/DelaySetting.java
// @Data
// public class DelaySetting {
//     private long afterSwipe;
//     private long afterTap;
//     private long beforeSwipe;
//     private long beforeTap;
//     private int  explicit = 30;
//     private int  implicit = 30;
// }
// 
// Path: src/main/java/com/github/wasiqb/coteafs/appium/config/enums/SwipeDirection.java
// public enum SwipeDirection {
//     /**
//      * Swipe up.
//      */
//     DOWN(0, 1),
//     /**
//      * Swipe left.
//      */
//     LEFT(-1, 0),
//     /**
//      * Swipe right.
//      */
//     RIGHT(1, 0),
//     /**
//      * Swipe up.
//      */
//     UP(0, -1);
// 
//     private final int x;
//     private final int y;
// 
//     /**
//      * @author wasiq.bhamla
//      * @since Oct 20, 2017 7:56:06 PM
//      */
//     SwipeDirection(final int x, final int y) {
//         this.x = x;
//         this.y = y;
//     }
// 
//     /**
//      * @return the x
//      * @author wasiq.bhamla
//      * @since Oct 20, 2017 7:57:09 PM
//      */
//     public int getX() {
//         return this.x;
//     }
// 
//     /**
//      * @return the y
//      * @author wasiq.bhamla
//      * @since Oct 20, 2017 7:57:09 PM
//      */
//     public int getY() {
//         return this.y;
//     }
// }
// 
// Path: src/main/java/com/github/wasiqb/coteafs/appium/config/enums/SwipeStartPosition.java
// public enum SwipeStartPosition {
//     /**
//      * Start from bottom border.
//      */
//     BOTTOM,
//     /**
//      * Start from center.
//      */
//     CENTER,
//     /**
//      * Start from left border.
//      */
//     LEFT,
//     /**
//      * Start from right border
//      */
//     RIGHT,
//     /**
//      * Start from top border.
//      */
//     TOP
// }
// 
// Path: src/main/java/com/github/wasiqb/coteafs/appium/error/DeviceElementNotDisplayedError.java
// public class DeviceElementNotDisplayedError extends CoteafsAppiumError {
//     private static final long serialVersionUID = -2632375399231145369L;
// 
//     /**
//      * @param message
//      * @author wasiq.bhamla
//      * @since 04-May-2017 11:05:48 PM
//      */
//     public DeviceElementNotDisplayedError(final String message) {
//         super(message);
//     }
// 
//     /**
//      * @param message
//      * @param cause
//      * @author wasiq.bhamla
//      * @since 04-May-2017 10:11:47 PM
//      */
//     public DeviceElementNotDisplayedError(final String message, final Throwable cause) {
//         super(message, cause);
//     }
// }


// Path: src/main/java/com/github/wasiqb/coteafs/appium/utils/SwipeUtils.java
import static com.github.wasiqb.coteafs.error.util.ErrorUtil.fail;
import static io.appium.java_client.touch.WaitOptions.waitOptions;
import static io.appium.java_client.touch.offset.PointOption.point;
import static java.text.MessageFormat.format;
import static java.time.Duration.ofMillis;
import com.github.wasiqb.coteafs.appium.config.device.DelaySetting;
import com.github.wasiqb.coteafs.appium.config.enums.SwipeDirection;
import com.github.wasiqb.coteafs.appium.config.enums.SwipeStartPosition;
import com.github.wasiqb.coteafs.appium.error.DeviceElementNotDisplayedError;
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
import lombok.Builder;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;

/*
 * Copyright (c) 2017, Wasiq Bhamla.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.wasiqb.coteafs.appium.utils;



/**
 * @author wasiq.bhamla
 * @since 21-Mar-2021
 */
@Builder (builderMethodName = "init", buildMethodName = "prepare")
public final class SwipeUtils<T extends TouchAction<T>> {
    private final T                  actions;
    @Builder.Default
    private final SwipeDirection     direction       = SwipeDirection.DOWN;
    @Builder.Default
    private final int                distancePercent = 20;
    private final Point              elementLocation;
    private final Dimension          elementSize;
    @Builder.Default
    private final int                maxSwipe        = 10;
    private final Dimension          screenSize;
    private final DelaySetting       setting;
    @Builder.Default
    private final SwipeStartPosition startPosition   = SwipeStartPosition.CENTER;