Skip to content

Commit

Permalink
WIP update everything and support kappacore based cabal-core
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaiwarner committed Dec 22, 2018
1 parent b4eedcc commit 0a90536
Show file tree
Hide file tree
Showing 26 changed files with 729,100 additions and 11,676 deletions.
17 changes: 17 additions & 0 deletions android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cabalmobile</name>
<comment>Project cabalmobile created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
23 changes: 23 additions & 0 deletions android/app/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment>Project app created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
4 changes: 2 additions & 2 deletions android/app/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ android_library(

android_build_config(
name = "build_config",
package = "chat.cabal.mobile",
package = "com.cabalmobile",
)

android_resource(
name = "res",
package = "chat.cabal.mobile",
package = "com.cabalmobile",
res = "src/main/res",
)

Expand Down
6 changes: 6 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ android {
versionCode 1
versionName "1.0"

aaptOptions {
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
}

externalNativeBuild {
cmake {
version "3.7.1"
Expand Down Expand Up @@ -155,6 +159,8 @@ android {
}

dependencies {
implementation project(':react-native-gesture-handler')
implementation project(':nodejs-mobile-react-native')
implementation project(':nodejs-mobile-react-native')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:28.0.0"
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="chat.cabal.mobile">
package="com.cabalmobile">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
Expand Down
15 changes: 14 additions & 1 deletion android/app/src/main/java/com/cabalmobile/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package chat.cabal.mobile;
package com.cabalmobile;

import com.facebook.react.ReactActivity;
// import com.facebook.react.ReactActivityDelegate;
// import com.facebook.react.ReactRootView;
// import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

public class MainActivity extends ReactActivity {

Expand All @@ -12,4 +15,14 @@ public class MainActivity extends ReactActivity {
protected String getMainComponentName() {
return "cabalmobile";
}

// @Override
// protected ReactActivityDelegate createReactActivityDelegate() {
// return new ReactActivityDelegate(this, getMainComponentName()) {
// @Override
// protected ReactRootView createRootView() {
// return new RNGestureHandlerEnabledRootView(MainActivity.this);
// }
// };
// }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chat.cabal.mobile;
package com.cabalmobile;

import android.app.Application;

Expand Down
4 changes: 4 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
rootProject.name = 'cabalmobile'
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
include ':nodejs-mobile-react-native'
project(':nodejs-mobile-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/nodejs-mobile-react-native/android')
include ':nodejs-mobile-react-native'
project(':nodejs-mobile-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/nodejs-mobile-react-native/android')

Expand Down
4 changes: 2 additions & 2 deletions frontend/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {createSwitchNavigator, createStackNavigator} from 'react-navigation'
import { createSwitchNavigator, createStackNavigator } from 'react-navigation'
import ChannelsList from './screens/ChannelsList'
import ChatScreen from './screens/ChatScreen'
import HomeScreen from './screens/HomeScreen'
Expand Down Expand Up @@ -50,7 +50,7 @@ export default createSwitchNavigator(
},
transitionConfig: () => ({
screenInterpolator: props => ({
transform: [{translateX: 0}, {translateY: 0}]
transform: [{ translateX: 0 }, { translateY: 0 }]
})
})
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/components/Avatar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import {View, StyleSheet} from 'react-native'
import { View, StyleSheet } from 'react-native'
import Blockies from 'blockies-bmp/react-native-component'
global.Buffer = require('buffer').Buffer // Import Buffer globally for the Blockies component

Expand All @@ -17,12 +17,12 @@ const styles = StyleSheet.create({

export default class Avatar extends React.Component {
render () {
const {isHidden, message} = this.props
const hiddenStyle = isHidden ? {height: 0} : null
const { isHidden, message } = this.props
const hiddenStyle = isHidden ? { opacity: 0 } : null
return (
<View style={[styles.avatar, hiddenStyle]}>
<Blockies
opts={{seed: message.author}}
opts={{ seed: message.user.name }}
size={40}
style={styles.avatarImage}
bgColor='#fff'
Expand Down
14 changes: 7 additions & 7 deletions frontend/components/Bubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
View,
Platform
} from 'react-native'
import {MessageText, MessageImage, Time, utils} from 'react-native-gifted-chat'
import { MessageText, MessageImage, Time, utils } from 'react-native-gifted-chat'

const {isSameUser, isSameDay} = utils
const { isSameUser, isSameDay } = utils

export default class Bubble extends React.Component {
constructor (props) {
Expand All @@ -27,7 +27,7 @@ export default class Bubble extends React.Component {
this.context
.actionSheet()
.showActionSheetWithOptions(
{options, cancelButtonIndex},
{ options, cancelButtonIndex },
buttonIndex => {
if (buttonIndex === 0) {
Clipboard.setString(this.props.currentMessage.text)
Expand Down Expand Up @@ -67,7 +67,7 @@ export default class Bubble extends React.Component {

renderMessageImage () {
if (this.props.currentMessage.image) {
const {containerStyle, wrapperStyle, ...messageImageProps} = this.props
const { containerStyle, wrapperStyle, ...messageImageProps } = this.props
if (this.props.renderMessageImage) {
return this.props.renderMessageImage(messageImageProps)
}
Expand All @@ -84,7 +84,7 @@ export default class Bubble extends React.Component {
renderUsername () {
const username = this.props.currentMessage.user.name
if (username) {
const {containerStyle, wrapperStyle, ...usernameProps} = this.props
const { containerStyle, wrapperStyle, ...usernameProps } = this.props
if (this.props.renderUsername) {
return this.props.renderUsername(usernameProps)
}
Expand All @@ -106,14 +106,14 @@ export default class Bubble extends React.Component {

renderTime () {
if (this.props.currentMessage.createdAt) {
const {containerStyle, wrapperStyle, ...timeProps} = this.props
const { containerStyle, wrapperStyle, ...timeProps } = this.props
if (this.props.renderTime) {
return this.props.renderTime(timeProps)
}
return (
<Time
{...timeProps}
containerStyle={{left: [styles.timeContainer]}}
containerStyle={{ left: [styles.timeContainer] }}
textStyle={{
left: [
styles.standardFont,
Expand Down
18 changes: 7 additions & 11 deletions frontend/components/Message.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react'
import {View, StyleSheet} from 'react-native'
import {Day, utils} from 'react-native-gifted-chat'
import { View, StyleSheet } from 'react-native'
import { Day, utils } from 'react-native-gifted-chat'
import Bubble from './Bubble'
import Avatar from './Avatar'

const {isSameUser, isSameDay} = utils
const { isSameUser, isSameDay } = utils

export default class Message extends React.Component {
getInnerComponentProps () {
const {containerStyle, ...props} = this.props
const { containerStyle, ...props } = this.props
return {
...props,
position: 'left',
Expand All @@ -31,7 +31,7 @@ export default class Message extends React.Component {
}

renderAvatar () {
const {currentMessage, previousMessage} = this.props
const { currentMessage, previousMessage } = this.props
const isHidden =
isSameUser(currentMessage, previousMessage) &&
isSameDay(currentMessage, previousMessage)
Expand All @@ -43,16 +43,12 @@ export default class Message extends React.Component {
const marginBottom = isSameUser(
this.props.currentMessage,
this.props.nextMessage
)
? 2
: 10
) ? 2 : 10

return (
<View>
{this.renderDay()}
<View
style={[styles.container, {marginBottom}, this.props.containerStyle]}
>
<View style={[styles.container, { marginBottom }, this.props.containerStyle]}>
{this.renderAvatar()}
{this.renderBubble()}
</View>
Expand Down
15 changes: 8 additions & 7 deletions frontend/screens/ChannelsList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import {
Alert,
AsyncStorage,
FlatList,
View,
Expand All @@ -19,7 +20,7 @@ class HomeHeader extends React.Component {

onPressCopy () {
Clipboard.setString(this.props.value)
alert('Copied to the clipboard!')
Alert.alert('Copied to the clipboard!')
}

render () {
Expand All @@ -43,7 +44,7 @@ class HomeHeader extends React.Component {
}

export default class HomeScreen extends React.Component {
static navigationOptions = ({navigation}) => ({
static navigationOptions = ({ navigation }) => ({
headerTitle: <HomeHeader value={navigation.getParam('key', '')} />
});

Expand Down Expand Up @@ -82,14 +83,14 @@ export default class HomeScreen extends React.Component {
startOrJoinInstance () {
const key = this.props.navigation.getParam('key', '')
const nick = this.state.nick
var msg = {type: 'join', key, nick}
var msg = { type: 'join', key, nick }
var raw = JSON.stringify(msg)
backend.channel.send(raw)
}

async updateKey (key) {
this.props.navigation.setParams({key, nick: this.state.nick})
this.setState(prev => ({...prev, key}))
this.props.navigation.setParams({ key, nick: this.state.nick })
this.setState(prev => ({ ...prev, key }))

if (this._initialLoad) {
this._initialLoad = false
Expand All @@ -101,13 +102,13 @@ export default class HomeScreen extends React.Component {
}

updateChannels (channels) {
this.setState(prev => ({...prev, channels}))
this.setState(prev => ({ ...prev, channels }))
}

enterChannel (channel) {
AsyncStorage.setItem('favorite-channel', channel)
const nick = this.state.nick
this.props.navigation.navigate('Chat', {channel, nick})
this.props.navigation.navigate('Chat', { channel, nick })
}

renderHeader () {
Expand Down
Loading

0 comments on commit 0a90536

Please sign in to comment.