Skip to content

Commit

Permalink
Merge pull request #935 from Letty/fix/rndemo
Browse files Browse the repository at this point in the history
Fix rndemo and upgrade to latest react native
  • Loading branch information
acro5piano authored Oct 7, 2023
2 parents 9459494 + d75042f commit 2cd6428
Show file tree
Hide file tree
Showing 55 changed files with 5,400 additions and 4,264 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"prettier --write",
"eslint --fix"
],
"*.{md}": [
"*.md": [
"prettier --write"
]
},
Expand Down
6 changes: 0 additions & 6 deletions rndemo/.buckconfig

This file was deleted.

2 changes: 2 additions & 0 deletions rndemo/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BUNDLE_PATH: "vendor/bundle"
BUNDLE_FORCE_RUBY_PLATFORM: 1
3 changes: 0 additions & 3 deletions rndemo/.editorconfig

This file was deleted.

4 changes: 4 additions & 0 deletions rndemo/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native',
};
66 changes: 0 additions & 66 deletions rndemo/.flowconfig

This file was deleted.

3 changes: 0 additions & 3 deletions rndemo/.gitattributes

This file was deleted.

27 changes: 17 additions & 10 deletions rndemo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local

# Android/IntelliJ
#
Expand All @@ -28,32 +29,38 @@ build/
.gradle
local.properties
*.iml
*.hprof
.cxx/
*.keystore
!debug.keystore

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots
**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

# CocoaPods
# Ruby / CocoaPods
/ios/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage
8 changes: 8 additions & 0 deletions rndemo/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
semi: false,
singleQuote: true,
trailingComma: 'all',
};
2 changes: 1 addition & 1 deletion rndemo/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
89 changes: 73 additions & 16 deletions rndemo/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import dayjs from 'dayjs'
import React from 'react'
import { Dimensions, Picker, SafeAreaView, StatusBar, View } from 'react-native'
import {
SafeAreaView,
StyleSheet,
Text,
TouchableOpacity,
useWindowDimensions,
View
} from 'react-native'

import { Calendar, ICalendarEventBase, Mode } from './build'

Expand Down Expand Up @@ -393,11 +400,12 @@ const events = [
]

export const App = () => {
const { height } = useWindowDimensions()
const [mode, setMode] = React.useState<Mode>('week')
const [additionalEvents, setAdditionalEvents] = React.useState<ICalendarEventBase[]>([])

const addEvent = React.useCallback(
(start) => {
(start: Date) => {
const title = 'new Event'
const end = dayjs(start).add(59, 'minute').toDate()
setAdditionalEvents([...additionalEvents, { start, end, title }])
Expand All @@ -406,31 +414,80 @@ export const App = () => {
)

return (
<React.Fragment>
<StatusBar barStyle="light-content" />
<View>
<SafeAreaView>
<View style={{ height: 60, borderBottomWidth: 0.5 }}>
<View style={{ width: '50%', marginLeft: 'auto' }}>
<Picker onValueChange={setMode} mode="dropdown">
<Picker.Item value="week" label="week" />
<Picker.Item value="day" label="day" />
<Picker.Item value="3days" label="3days" />
<Picker.Item value="month" label="month" />
</Picker>
<View>
<Text style={styles.headline}>Calendar Mode</Text>
<View style={styles.buttonRow}>
<TouchableOpacity
onPress={() => setMode('week')}
style={[
styles.buttonContainer,
mode === 'week' && styles.buttonContainerActive,
]}>
<Text>week</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => setMode('day')}
style={[
styles.buttonContainer,
mode === 'day' && styles.buttonContainerActive,
]}>
<Text>day</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => setMode('3days')}
style={[
styles.buttonContainer,
mode === '3days' && styles.buttonContainerActive,
]}>
<Text>3days</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => setMode('month')}
style={[
styles.buttonContainer,
mode === 'month' && styles.buttonContainerActive,
]}>
<Text>month</Text>
</TouchableOpacity>
</View>
</View>
<Calendar
height={Dimensions.get('window').height - 60}
height={height - 60}
events={[...events, ...additionalEvents]}
onPressCell={addEvent}
sortedMonthView={false}
mode={mode}
moreLabel="+{moreCount}"
onPressMoreLabel={(events) => {
console.log(events)
onPressMoreLabel={(moreEvents) => {
console.log(moreEvents)
}}
/>
</SafeAreaView>
</React.Fragment>
</View>
)
}

const styles = StyleSheet.create({
buttonContainer: {
backgroundColor: '#f1f1f1',
borderRadius: 10,
paddingHorizontal: 15,
paddingVertical: 5,
},
buttonContainerActive: {
borderBottomColor: 'blue',
borderBottomWidth: 3,
},
buttonRow: {
flexDirection: 'row',
justifyContent: 'space-between',
padding: 10,
},
headline: {
fontSize: 16,
},
})

export default App
6 changes: 6 additions & 0 deletions rndemo/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

gem 'cocoapods', '~> 1.12'
Loading

1 comment on commit 2cd6428

@vercel
Copy link

@vercel vercel bot commented on 2cd6428 Oct 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.