Skip to content

Instantly share code, notes, and snippets.

View troZee's full-sized avatar

troZee

View GitHub Profile
//Blinking Animation of Multiply Drawables in ActionBar Toolbar on Android
//You can use AnimationDrawable, if you don't want to custom blinking animation
private void initAnimationOfCustomPins() {
ActionBar actionBar = getActionBar();
if (actionBar == null || !Constant.USE_ANIMATION_OF_CUSTOM_PINS) {
return;
}
// this func show CNContactViewController for new contact and fill it using CNMutableContact
// Remember about permissions
func createContcat() {
if #available(iOS 9.0, *) {
let contact = CNMutableContact()
contact.givenName = "Jack"
contact.familyName = "Sparrow"
#import <React/RCTViewManager.h>
#import <React/RCTUIManager.h>
#import <React/RCTLog.h>
RCT_EXPORT_METHOD(goToPreviousPage:(nonnull NSNumber*) reactTag) {
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
NativeView *view = viewRegistry[reactTag];
if (!view || ![view isKindOfClass:[NativeView class]]) {
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
return;
}
class MyNativeView extends React.Component<Props> {
goToNextPage = () => {
UIManager.dispatchViewManagerCommand(
ReactNative.findNodeHandle(this),
UIManager.getViewManagerConfig('RNCMyNativeView').Commands.goToNextPage,
[]
);
};
goToPreviousPage = () => {
class MyNativeView extends React.Component<Props> {
goToNextPage = () => {
NativeModules.RNCMyNativeView.goToNextPage();
};
goToPreviousPage = () => {
NativeModules.RNCMyNativeView.goToPreviousPage();
};
render() {
<View>
<MyNativeView ref={this.myNativeView} />
<ButtonContainer>
<Button
title="Previous"
onPress={() => {
this.myNativeView.current.goToPreviousPage();
}}
/>
<Button
<View>
<MyNativeView />
<ButtonContainer>
<Button title="Previous" />
<Button title="Next" />
</ButtonContainer>
<MyNativeView />
<ButtonContainer>
<Button title="Previous" />
<Button title="Next" />
@troZee
troZee / UIPageControl.m
Created November 2, 2019 22:10
Add UIPageControl dynamically
UIPageControl *pageIndicatorView = [[UIPageControl alloc] init];
pageIndicatorView.translatesAutoresizingMaskIntoConstraints = NO;
NSLayoutConstraint *bottomConstraint = [pageIndicatorView.bottomAnchor constraintEqualToAnchor: self.view.bottomAnchor constant:0];
NSLayoutConstraint *leadingConstraint = [pageIndicatorView.leadingAnchor constraintEqualToAnchor: self.view.leadingAnchor constant:0];
NSLayoutConstraint *trailingConstraint = [pageIndicatorView.trailingAnchor constraintEqualToAnchor: self.view.trailingAnchor constant:0];
[self.view addConstraints:@[bottomConstraint,leadingConstraint,trailingConstraint]];
[self.view layoutIfNeeded];
@troZee
troZee / regex.js
Created January 1, 2021 13:06
regex for only positive price
const regex = /(^0[\,\.][0-9]{1,}$)|(^[1-9][0-9]{1,}$)|(^[0-9]$)|(^[1-9][0-9]{0,}[\,\.][0-9]{1,}$)/gm;
const str = `01
001
033
0000033
00000.2
00000000000000
01010101010
0000.0
aaa
@troZee
troZee / priceRegex.js
Created January 1, 2021 13:10
Price regex for positive and negative numbers
const regex = /(^\-?0[\,\.][0-9]{1,}$)|(^\-?[1-9][0-9]{1,}$)|(^[0-9]$)|(^\-?[1-9][0-9]{0,}[\,\.][0-9]{1,}$)|(^\-?[1-9]$)/gm;
const str = `01
001
033
0000033
00000.2
00000000000000
01010101010
0000.0
aaa