1605595920
A performant interactive bottom sheet with fully configurable options 🚀
Initially, this project was a cloned of
react-native-scroll-bottom-sheet
by @rgommezz ❤️. However, it is been fully re-written to add extra functionalities and simplify the approach.
FlatList
, SectionList
, ScrollView
& View
scrolling interactions.React Navigation
Integration.Reanimated
v1 & v2.Expo
.TypeScript
.This version is written with Reanimated v1
yarn add @gorhom/bottom-sheet
# or
npm install @gorhom/bottom-sheet
⚠️ You need to install react-native-reanimated & react-native-gesture-handler and follow their installation instructions.
this version is written with Reanimated v2
, although this version is still in alpha phase, yet it provides all version 1 functionalities with the huge performance boost, thanks to Reanimated v2
❤️
yarn add @gorhom/bottom-sheet@2.0.0-alpha.0
# or
npm install @gorhom/bottom-sheet@2.0.0-alpha.0
⚠️ You need to install react-native-reanimated v2 & react-native-gesture-handler and follow their installation instructions.
import React, { useCallback, useMemo, useRef } from 'react';
import { View, StyleSheet } from 'react-native';
import BottomSheet from '@gorhom/bottom-sheet';
const App = () => {
// hooks
const bottomSheetRef = useRef<BottomSheet>(null);
// variables
const snapPoints = useMemo(() => ['25%', '50%', '90%'], []);
// callbacks
const handleSheetChanges = useCallback((index: number) => {
console.log('handleSheetChanges', index);
}, []);
// renders
return (
<View style={styles.container}>
<BottomSheet
ref={bottomSheetRef}
initialSnapIndex={1}
snapPoints={snapPoints}
onChange={handleSheetChanges}
>
{/* INSERT A SCROLLABLE HERE */}
</BottomSheet>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 24,
},
});
export default App;
initialSnapIndex
Initial snap index. You also could provide {-1
} to initiate bottom sheet in closed state.
required:
NO |type:
number |default:
0
snapPoints
Points for the bottom sheet to snap to, points should be sorted from bottom to top
. It accepts array of number, string or mix. String values should be a percentage.
required:
YES |type:
Array<string | number>
example:
[100, ‘50%’, ‘90%’]
topInset
Top inset value helps to calculate percentage snap points values. usually comes from @react-navigation/stack
hook useHeaderHeight
or from react-native-safe-area-context
hook useSafeArea
.
required:
NO |type:
number |default:
0
enabled
To enable or disable user interaction with the sheet.
required:
NO |type:
boolean |default:
true
animationDuration
Snapping animation duration.
required:
NO |type:
number |default:
500
animationEasing
Snapping animation easing function.
required:
NO |type:
Animated.EasingFunction |default:
Easing.out(Easing.back(0.75))
animatedPosition
Animated value to be used as a callback for the position node internally.
required:
NO |type:
Animated.Value
animatedPositionIndex
Animated value to be used as a callback for the position index node internally.
required:
NO |type:
Animated.Value
handleComponent
Component to be placed as a sheet handle.
required:
NO |type:
React.FC<BottomSheetHandleProps>
backgroundComponent
Component to be placed as a background.
required:
NO |type:
React.FC
onChange
Callback when sheet position changed to a provided point.
required:
NO |type:
(index: number) => void
children
A scrollable node or normal view.
required:
YES |type:
() => React.ReactNode | React.ReactNode[] | React.ReactNode
snapTo
Snap to one of the provided points from snapPoints
.
type:
(index: number) => void
expand
Snap to the maximum provided point from snapPoints
.
type:
() => void
collapse
Snap to the minimum provided point from snapPoints
.
type:
() => void
close
Close the bottom sheet.
type:
() => void
useBottomSheet
The library provide useBottomSheet
hook to provide the bottom sheet methods, anywhere inside the sheet content.
type:
BottomSheetMethods
This library provides a pre-integrated views that utilise an internal functionalities with the bottom sheet to allow smooth interactions. These views i called them Scrollables
and they are:
reanimated-bottom-sheet
or react-native-scroll-bottom-sheet
?This library was built to provide the most native-like experience and could fit any use-case that developers wants it to be.
While both libraries providing similar experience, but they still missing the following:
reanimated-bottom-sheet
- Seamless gesture interaction between the sheet and the content.
react-native-scroll-bottom-sheet
- Extracting scrollable content to allow developers customize the sheet content, like integrate
React Navigation
as the sheet content.Both libraries are great! and I have used both of them at my work ❤️
React Navigation
?here you go React Navigation Integration :)
Reanimated v2
?Yes 🎉
Author: gorhom
Source Code: https://github.com/gorhom/react-native-bottom-sheet
#react #react-native #mobile-apps
1598839687
If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?
In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.
Let’s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.
React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.
Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.
Although relatively new, React Native has acquired a high degree of popularity. The “Stack Overflow Developer Survey 2019” report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.
The popularity of React Native comes from its advantages. Some of its advantages are as follows:
Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? It’s not! React Native is fundamentally different from these earlier hybrid frameworks.
React Native is very close to native. Consider the following aspects as described on the React Native website:
Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.
#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native
1593420654
Have you ever thought of having your own app that runs smoothly over multiple platforms?
React Native is an open-source cross-platform mobile application framework which is a great option to create mobile apps for both Android and iOS. Hire Dedicated React Native Developer from top React Native development company, HourlyDeveloper.io to design a spectacular React Native application for your business.
Consult with experts:- https://bit.ly/2A8L4vz
#hire dedicated react native developer #react native development company #react native development services #react native development #react native developer #react native
1650521873
In this guide you’ll learn how to create the Custom Radio Buttons using only HTML & CSS.
To create the custom radio buttons using only HTML & CSS. First, you need to create two Files one HTML File and another one is CSS File.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Custom Radio Buttons | Codequs</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wrapper">
<input type="radio" name="select" id="option-1" checked>
<input type="radio" name="select" id="option-2">
<label for="option-1" class="option option-1">
<div class="dot"></div>
<span>Student</span>
</label>
<label for="option-2" class="option option-2">
<div class="dot"></div>
<span>Teacher</span>
</label>
</div>
</body>
</html>
@import url('https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
html,body{
display: grid;
height: 100%;
place-items: center;
background: #0069d9;
}
.wrapper{
display: inline-flex;
background: #fff;
height: 100px;
width: 400px;
align-items: center;
justify-content: space-evenly;
border-radius: 5px;
padding: 20px 15px;
box-shadow: 5px 5px 30px rgba(0,0,0,0.2);
}
.wrapper .option{
background: #fff;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: space-evenly;
margin: 0 10px;
border-radius: 5px;
cursor: pointer;
padding: 0 10px;
border: 2px solid lightgrey;
transition: all 0.3s ease;
}
.wrapper .option .dot{
height: 20px;
width: 20px;
background: #d9d9d9;
border-radius: 50%;
position: relative;
}
.wrapper .option .dot::before{
position: absolute;
content: "";
top: 4px;
left: 4px;
width: 12px;
height: 12px;
background: #0069d9;
border-radius: 50%;
opacity: 0;
transform: scale(1.5);
transition: all 0.3s ease;
}
input[type="radio"]{
display: none;
}
#option-1:checked:checked ~ .option-1,
#option-2:checked:checked ~ .option-2{
border-color: #0069d9;
background: #0069d9;
}
#option-1:checked:checked ~ .option-1 .dot,
#option-2:checked:checked ~ .option-2 .dot{
background: #fff;
}
#option-1:checked:checked ~ .option-1 .dot::before,
#option-2:checked:checked ~ .option-2 .dot::before{
opacity: 1;
transform: scale(1);
}
.wrapper .option span{
font-size: 20px;
color: #808080;
}
#option-1:checked:checked ~ .option-1 span,
#option-2:checked:checked ~ .option-2 span{
color: #fff;
}
Now you’ve successfully created Custom Radio Buttons using only HTML & CSS.
1647998803
Module to enable rate limit per service in Netflix Zuul.
There are five built-in rate limit approaches:
Note | It is possible to combine Authenticated User, Request Origin, URL, ROLE and Request Method just adding multiple values to the list |
Note | Latest version: |
Note | If you are using Spring Boot version 1.5.x you MUST use Spring Cloud Zuul RateLimit version 1.7.x . Please take a look at the Maven Central and pick the latest artifact in this version line. |
Add the dependency on pom.xml
<dependency>
<groupId>com.marcosbarbero.cloud</groupId>
<artifactId>spring-cloud-zuul-ratelimit</artifactId>
<version>${latest-version}</version>
</dependency>
Add the following dependency accordingly to the chosen data storage:
Redis
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
Consul
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul</artifactId>
</dependency>
Spring Data JPA
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
This implementation also requires a database table, bellow here you can find a sample script:
CREATE TABLE rate (
rate_key VARCHAR(255) NOT NULL,
remaining BIGINT,
remaining_quota BIGINT,
reset BIGINT,
expiration TIMESTAMP,
PRIMARY KEY(rate_key)
);
Bucket4j JCache
<dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-core</artifactId>
</dependency>
<dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-jcache</artifactId>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
</dependency>
Bucket4j Hazelcast (depends on Bucket4j JCache)
<dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-hazelcast</artifactId>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
</dependency>
Bucket4j Infinispan (depends on Bucket4j JCache)
<dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-infinispan</artifactId>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
</dependency>
Bucket4j Ignite (depends on Bucket4j JCache)
<dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-ignite</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-core</artifactId>
</dependency>
Sample YAML configuration
zuul:
ratelimit:
key-prefix: your-prefix
enabled: true
repository: REDIS
behind-proxy: true
add-response-headers: true
deny-request:
response-status-code: 404 #default value is 403 (FORBIDDEN)
origins:
- 200.187.10.25
- somedomain.com
default-policy-list: #optional - will apply unless specific policy exists
- limit: 10 #optional - request number limit per refresh interval window
quota: 1000 #optional - request time limit per refresh interval window (in seconds)
refresh-interval: 60 #default value (in seconds)
type: #optional
- user
- origin
- url
- http_method
policy-list:
myServiceId:
- limit: 10 #optional - request number limit per refresh interval window
quota: 1000 #optional - request time limit per refresh interval window (in seconds)
refresh-interval: 60 #default value (in seconds)
type: #optional
- user
- origin
- url
- type: #optional value for each type
- user=anonymous
- origin=somemachine.com
- url=/api #url prefix
- role=user
- http_method=get #case insensitive
- http_header=customHeader
- type:
- url_pattern=/api/*/payment
Sample Properties configuration
zuul.ratelimit.enabled=true
zuul.ratelimit.key-prefix=your-prefix
zuul.ratelimit.repository=REDIS
zuul.ratelimit.behind-proxy=true
zuul.ratelimit.add-response-headers=true
zuul.ratelimit.deny-request.response-status-code=404
zuul.ratelimit.deny-request.origins[0]=200.187.10.25
zuul.ratelimit.deny-request.origins[1]=somedomain.com
zuul.ratelimit.default-policy-list[0].limit=10
zuul.ratelimit.default-policy-list[0].quota=1000
zuul.ratelimit.default-policy-list[0].refresh-interval=60
# Adding multiple rate limit type
zuul.ratelimit.default-policy-list[0].type[0]=user
zuul.ratelimit.default-policy-list[0].type[1]=origin
zuul.ratelimit.default-policy-list[0].type[2]=url
zuul.ratelimit.default-policy-list[0].type[3]=http_method
# Adding the first rate limit policy to "myServiceId"
zuul.ratelimit.policy-list.myServiceId[0].limit=10
zuul.ratelimit.policy-list.myServiceId[0].quota=1000
zuul.ratelimit.policy-list.myServiceId[0].refresh-interval=60
zuul.ratelimit.policy-list.myServiceId[0].type[0]=user
zuul.ratelimit.policy-list.myServiceId[0].type[1]=origin
zuul.ratelimit.policy-list.myServiceId[0].type[2]=url
# Adding the second rate limit policy to "myServiceId"
zuul.ratelimit.policy-list.myServiceId[1].type[0]=user=anonymous
zuul.ratelimit.policy-list.myServiceId[1].type[1]=origin=somemachine.com
zuul.ratelimit.policy-list.myServiceId[1].type[2]=url_pattern=/api/*/payment
zuul.ratelimit.policy-list.myServiceId[1].type[3]=role=user
zuul.ratelimit.policy-list.myServiceId[1].type[4]=http_method=get
zuul.ratelimit.policy-list.myServiceId[1].type[5]=http_header=customHeader
Both 'quota' and 'refresh-interval', can be expressed with Spring Boot’s duration formats:
A regular long representation (using seconds as the default unit)
The standard ISO-8601 format used by java.time.Duration (e.g. PT30M means 30 minutes)
A more readable format where the value and the unit are coupled (e.g. 10s means 10 seconds)
There are eight implementations provided:
Implementation | Data Storage |
---|---|
ConsulRateLimiter | Consul |
RedisRateLimiter | Redis |
SpringDataRateLimiter | Spring Data |
Bucket4jJCacheRateLimiter | Bucket4j |
Bucket4jHazelcastRateLimiter | |
Bucket4jIgniteRateLimiter | |
Bucket4jInfinispanRateLimiter |
Bucket4j implementations require the relevant bean with @Qualifier("RateLimit")
:
JCache
- javax.cache.Cache
Hazelcast
- com.hazelcast.map.IMap
Ignite
- org.apache.ignite.IgniteCache
Infinispan
- org.infinispan.functional.ReadWriteMap
Property namespace: zuul.ratelimit
Property name | Values | Default Value |
---|---|---|
enabled | true/false | false |
behind-proxy | true/false | false |
response-headers | NONE, STANDARD, VERBOSE | VERBOSE |
key-prefix | String | ${spring.application.name:rate-limit-application} |
repository | CONSUL, REDIS, JPA, BUCKET4J_JCACHE, BUCKET4J_HAZELCAST, BUCKET4J_INFINISPAN, BUCKET4J_IGNITE | - |
deny-request | DenyRequest | - |
default-policy-list | List of Policy | - |
policy-list | Map of Lists of Policy | - |
postFilterOrder | int | FilterConstants.SEND_RESPONSE_FILTER_ORDER - 10 |
preFilterOrder | int | FilterConstants.FORM_BODY_WRAPPER_FILTER_ORDER |
Deny Request properties
Property name | Values | Default Value |
---|---|---|
origins | list of origins to have the access denied | - |
response-status-code | the http status code to be returned on a denied request | 403 (FORBIDDEN) |
Policy properties:
Property name | Values | Default Value |
---|---|---|
limit | number of requests | - |
quota | time of requests | - |
refresh-interval | seconds | 60 |
type | [ORIGIN, USER, URL, URL_PATTERN, ROLE, HTTP_METHOD, HTTP_HEADER] | [] |
breakOnMatch | true/false | false |
This section details how to add custom implementations
If the application needs to control the key strategy beyond the options offered by the type property then it can be done just by creating a custom RateLimitKeyGenerator
bean[1] implementation adding further qualifiers or something entirely different:
@Bean
public RateLimitKeyGenerator ratelimitKeyGenerator(RateLimitProperties properties, RateLimitUtils rateLimitUtils) {
return new DefaultRateLimitKeyGenerator(properties, rateLimitUtils) {
@Override
public String key(HttpServletRequest request, Route route, RateLimitProperties.Policy policy) {
return super.key(request, route, policy) + ":" + request.getMethod();
}
};
}
This framework uses 3rd party applications to control the rate limit access and these libraries are out of control of this framework. If one of the 3rd party applications fails, the framework will handle this failure in the DefaultRateLimiterErrorHandler
class which will log the error upon failure.
If there is a need to handle the errors differently, it can be achieved by defining a custom RateLimiterErrorHandler
bean[2], e.g:
@Bean
public RateLimiterErrorHandler rateLimitErrorHandler() {
return new DefaultRateLimiterErrorHandler() {
@Override
public void handleSaveError(String key, Exception e) {
// custom code
}
@Override
public void handleFetchError(String key, Exception e) {
// custom code
}
@Override
public void handleError(String msg, Exception e) {
// custom code
}
}
}
If the application needs to be notified when a rate limit access was exceeded then it can be done by listening to RateLimitExceededEvent
event:
@EventListener
public void observe(RateLimitExceededEvent event) {
// custom code
}
Spring Cloud Zuul Rate Limit is released under the non-restrictive Apache 2.0 license, and follows a very standard Github development process, using Github tracker for issues and merging pull requests into master. If you want to contribute even something trivial please do not hesitate, but follow the guidelines below.
Download Details:
Author: marcosbarbero
Source Code: https://github.com/marcosbarbero/spring-cloud-zuul-ratelimit
License: Apache-2.0 License
1616494982
Being one of the emerging frameworks for app development the need to develop react native apps has increased over the years.
Looking for a react native developer?
Worry not! WebClues infotech offers services to Hire React Native Developers for your app development needs. We at WebClues Infotech offer a wide range of Web & Mobile App Development services based o your business or Startup requirement for Android and iOS apps.
WebClues Infotech also has a flexible method of cost calculation for hiring react native developers such as Hourly, Weekly, or Project Basis.
Want to get your app idea into reality with a react native framework?
Get in touch with us.
Hire React Native Developer Now: https://www.webcluesinfotech.com/hire-react-native-app-developer/
For inquiry: https://www.webcluesinfotech.com/contact-us/
Email: sales@webcluesinfotech.com
#hire react native developers #hire dedicated react native developers #hire react native developer #hiring a react native developer #hire freelance react native developers #hire react native developers in 1 hour