diff --git a/squarenotsquare/Launcher.js b/squarenotsquare/Launcher.js index 2e71fc1..d6a3ffc 100644 --- a/squarenotsquare/Launcher.js +++ b/squarenotsquare/Launcher.js @@ -3,11 +3,11 @@ import {Provider} from 'react-redux'; import SquareStack from './src/navigation/SquareStack'; function SquareNotSquare(props){ - return ( - - - - ) + return ( + + + + ) } export default SquareNotSquare; \ No newline at end of file diff --git a/squarenotsquare/__mock__/mockDB.js b/squarenotsquare/__mock__/mockDB.js index ac497c0..0d9daf2 100644 --- a/squarenotsquare/__mock__/mockDB.js +++ b/squarenotsquare/__mock__/mockDB.js @@ -1,3 +1,3 @@ export async function initDB() { - return null; + return null; } \ No newline at end of file diff --git a/squarenotsquare/__mock__/mockKeyStore.js b/squarenotsquare/__mock__/mockKeyStore.js index 5370d3b..c6521a5 100644 --- a/squarenotsquare/__mock__/mockKeyStore.js +++ b/squarenotsquare/__mock__/mockKeyStore.js @@ -1,9 +1,9 @@ export async function removeKey(key) { - return true; + return true; } export async function setKey(key, value) { - return true; + return true; } export async function getKey(key) { diff --git a/squarenotsquare/__mock__/mockRealm.js b/squarenotsquare/__mock__/mockRealm.js index 37be736..e9fe715 100644 --- a/squarenotsquare/__mock__/mockRealm.js +++ b/squarenotsquare/__mock__/mockRealm.js @@ -1,135 +1,135 @@ // https://github.com/realm/realm-js/issues/370#issuecomment-270849466 export default class MockRealm { - constructor(params) { - this.schema = {}; - this.schemaVersion = params.schemaVersion; - this.callbackList = []; - this.data = {}; - this.schemaCallbackList = {}; - params.schema.forEach((schema) => { - this.data[schema.name] = {}; - }); - params.schema.forEach((schema) => { - this.schema[schema.name] = schema; - }); - this.lastLookedUpModel = null; - } + constructor(params) { + this.schema = {}; + this.schemaVersion = params.schemaVersion; + this.callbackList = []; + this.data = {}; + this.schemaCallbackList = {}; + params.schema.forEach((schema) => { + this.data[schema.name] = {}; + }); + params.schema.forEach((schema) => { + this.schema[schema.name] = schema; + }); + this.lastLookedUpModel = null; + } - objects(schemaName) { - this.lastLookedUpModel = schemaName; - const objects = Object.values(this.data[schemaName]); - objects.values = () => objects; - objects.sorted = () => this.compareFunc ? objects.sort(this.compareFunc) : objects.sort(); - objects.addListener = (cb) => { - if (this.schemaCallbackList[schemaName]) { - this.schemaCallbackList[schemaName].push(cb); - } else { - this.schemaCallbackList[schemaName] = [cb]; - } - }; - objects.removeListener = () => {}; - objects.filtered = this.filtered ? this.filtered.bind(this, schemaName) : () => objects; - return objects; + objects(schemaName) { + this.lastLookedUpModel = schemaName; + const objects = Object.values(this.data[schemaName]); + objects.values = () => objects; + objects.sorted = () => this.compareFunc ? objects.sort(this.compareFunc) : objects.sort(); + objects.addListener = (cb) => { + if (this.schemaCallbackList[schemaName]) { + this.schemaCallbackList[schemaName].push(cb); + } else { + this.schemaCallbackList[schemaName] = [cb]; } + }; + objects.removeListener = () => {}; + objects.filtered = this.filtered ? this.filtered.bind(this, schemaName) : () => objects; + return objects; + } - write(fn) { - this.writing = true; - fn(); - this.writing = false; - } + write(fn) { + this.writing = true; + fn(); + this.writing = false; + } - create(schemaName, object) { - const modelObject = object; - const properties = this.schema[schemaName].schema.properties; - Object.keys(properties).forEach((key) => { - if (modelObject[key] && modelObject[key].model) { - this.data[modelObject[key].model][modelObject[key].id] = this.create( - modelObject[key].model, modelObject[key], - ); - } else if (modelObject[key] && modelObject[key].length && modelObject[key][0].model) { - modelObject[key].forEach((obj) => { - this.data[modelObject[key][0].model][obj.id] = obj; - }); - modelObject[key].filtered = this.filtered ? this.filtered : () => modelObject[key]; - modelObject[key].sorted = () => modelObject[key].sort(); - } else if (modelObject[key] === undefined) { - if (typeof properties[key] === 'object' && properties[key].optional) { - modelObject[key] = null; - } - if (typeof properties[key] === 'object' && ['list', 'linkingObjects'].includes(properties[key].type)) { - modelObject[key] = []; - modelObject[key].filtered = () => []; - modelObject[key].sorted = () => []; - } - } + create(schemaName, object) { + const modelObject = object; + const properties = this.schema[schemaName].schema.properties; + Object.keys(properties).forEach((key) => { + if (modelObject[key] && modelObject[key].model) { + this.data[modelObject[key].model][modelObject[key].id] = this.create( + modelObject[key].model, modelObject[key], + ); + } else if (modelObject[key] && modelObject[key].length && modelObject[key][0].model) { + modelObject[key].forEach((obj) => { + this.data[modelObject[key][0].model][obj.id] = obj; }); - - this.data[schemaName][modelObject.id] = modelObject; - if (this.writing) { - if (this.schemaCallbackList[schemaName]) { - this.schemaCallbackList[schemaName].forEach(cb => cb(schemaName, { - insertions: { length: 1 }, - modifications: { length: 0 }, - deletions: { length: 0 }, - })); - } - this.callbackList.forEach((cb) => { cb(); }); + modelObject[key].filtered = this.filtered ? this.filtered : () => modelObject[key]; + modelObject[key].sorted = () => modelObject[key].sort(); + } else if (modelObject[key] === undefined) { + if (typeof properties[key] === 'object' && properties[key].optional) { + modelObject[key] = null; + } + if (typeof properties[key] === 'object' && ['list', 'linkingObjects'].includes(properties[key].type)) { + modelObject[key] = []; + modelObject[key].filtered = () => []; + modelObject[key].sorted = () => []; } - return modelObject; } + }); - objectForPrimaryKey(model, id) { - this.lastLookedUpModel = model; - return this.data[model][id]; + this.data[schemaName][modelObject.id] = modelObject; + if (this.writing) { + if (this.schemaCallbackList[schemaName]) { + this.schemaCallbackList[schemaName].forEach(cb => cb(schemaName, { + insertions: { length: 1 }, + modifications: { length: 0 }, + deletions: { length: 0 }, + })); } - - delete(object) { - if (this.lastLookedUpModel || object.model) { - const model = object.model ? object.model : this.lastLookedUpModel - if (Array.isArray(object)) { - object.forEach((item) => { - delete this.data[model][item.id]; - }); - } - delete this.data[model][object.id]; - if (this.writing) { - if (this.schemaCallbackList[model]) { - this.schemaCallbackList[model].forEach(cb => cb(model, { - insertions: { length: 0 }, - modifications: { length: 0 }, - deletions: { length: 1 }, - })); - } - this.callbackList.forEach((cb) => { cb(); }); - } - } + this.callbackList.forEach((cb) => { cb(); }); } + return modelObject; + } - deleteAll() { - Object.keys(this.schema).forEach((key) => { - if (this.writing && this.schemaCallbackList[this.schema[key].name]) { - this.schemaCallbackList[this.schema[key].name].forEach(cb => cb(key, { - insertions: { length: 0 }, - modifications: { length: 0 }, - deletions: { length: Object.values(this.data[this.schema[key].name]).length }, - })); - } - this.data[this.schema[key].name] = {}; + objectForPrimaryKey(model, id) { + this.lastLookedUpModel = model; + return this.data[model][id]; + } + + delete(object) { + if (this.lastLookedUpModel || object.model) { + const model = object.model ? object.model : this.lastLookedUpModel + if (Array.isArray(object)) { + object.forEach((item) => { + delete this.data[model][item.id]; }); - if (this.writing) this.callbackList.forEach((cb) => { cb(); }); } - - addListener(event, callback) { - this.callbackList.push(callback); + delete this.data[model][object.id]; + if (this.writing) { + if (this.schemaCallbackList[model]) { + this.schemaCallbackList[model].forEach(cb => cb(model, { + insertions: { length: 0 }, + modifications: { length: 0 }, + deletions: { length: 1 }, + })); + } + this.callbackList.forEach((cb) => { cb(); }); + } } + } - prepareData(schemaName, objects) { - objects.forEach((object) => { - this.create(schemaName, object); - }); + deleteAll() { + Object.keys(this.schema).forEach((key) => { + if (this.writing && this.schemaCallbackList[this.schema[key].name]) { + this.schemaCallbackList[this.schema[key].name].forEach(cb => cb(key, { + insertions: { length: 0 }, + modifications: { length: 0 }, + deletions: { length: Object.values(this.data[this.schema[key].name]).length }, + })); } + this.data[this.schema[key].name] = {}; + }); + if (this.writing) this.callbackList.forEach((cb) => { cb(); }); + } + + addListener(event, callback) { + this.callbackList.push(callback); + } + + prepareData(schemaName, objects) { + objects.forEach((object) => { + this.create(schemaName, object); + }); + } } MockRealm.Object = class Object { - isValid() { return true; } + isValid() { return true; } }; \ No newline at end of file diff --git a/squarenotsquare/__mock__/mockRealmObject.js b/squarenotsquare/__mock__/mockRealmObject.js index 481e814..a32e1cc 100644 --- a/squarenotsquare/__mock__/mockRealmObject.js +++ b/squarenotsquare/__mock__/mockRealmObject.js @@ -4,29 +4,29 @@ import { User } from "../src/realm/entities/User"; export class MockRealm{ - constructor(schemaVersion){ - this.schemaVersion = schemaVersion; - this[System.name] = []; - this[Score.name] = []; - this[User.name] = []; - this.deletedKeys = []; - } + constructor(schemaVersion){ + this.schemaVersion = schemaVersion; + this[System.name] = []; + this[Score.name] = []; + this[User.name] = []; + this.deletedKeys = []; + } - create(repoName, entity){ - this[repoName].push(entity); - } + create(repoName, entity){ + this[repoName].push(entity); + } - objects(repoName){ - let objects = this[repoName]; - objects.filtered = this.filtered ? this.filtered.bind(this, repoName) : () => objects; - return objects; - } + objects(repoName){ + let objects = this[repoName]; + objects.filtered = this.filtered ? this.filtered.bind(this, repoName) : () => objects; + return objects; + } - write(callback){ - callback(); - } + write(callback){ + callback(); + } - delete(key){ - this.deletedKeys.push(key); - } + delete(key){ + this.deletedKeys.push(key); + } } \ No newline at end of file diff --git a/squarenotsquare/__tests__/Action-Creators-test.js b/squarenotsquare/__tests__/Action-Creators-test.js index 93a2832..3aa0404 100644 --- a/squarenotsquare/__tests__/Action-Creators-test.js +++ b/squarenotsquare/__tests__/Action-Creators-test.js @@ -8,10 +8,10 @@ const middlewares = [thunk]; const mockStore = configureMockStore(middlewares); test('starts redux store', () => { - const localStore = mockStore(); - return localStore.dispatch(appInit()) - .then( () => { - const actualAction = localStore.getActions()[0]; - expect(actualAction.type).toEqual(APP_INIT); - }) + const localStore = mockStore(); + return localStore.dispatch(appInit()) + .then( () => { + const actualAction = localStore.getActions()[0]; + expect(actualAction.type).toEqual(APP_INIT); + }) }); \ No newline at end of file diff --git a/squarenotsquare/__tests__/DB-Setup-test.js b/squarenotsquare/__tests__/DB-Setup-test.js new file mode 100644 index 0000000..ca6c85a --- /dev/null +++ b/squarenotsquare/__tests__/DB-Setup-test.js @@ -0,0 +1,7 @@ +import { initDB } from "../src/realm/dbInit"; + +test('Realm DB inits', async () => { + let realmDB = await initDB(); + + expect +}); \ No newline at end of file diff --git a/squarenotsquare/__tests__/Migration-test.js b/squarenotsquare/__tests__/Migration-test.js index f86722b..e13d886 100644 --- a/squarenotsquare/__tests__/Migration-test.js +++ b/squarenotsquare/__tests__/Migration-test.js @@ -4,30 +4,30 @@ import { migratev1 } from "../src/realm/migrations/MigrateV1"; import { MockRealm } from "../__mock__/mockRealmObject"; test('Realm migrates to V0', () => { - let oldRealm = new MockRealm(0); - let newRealm = new MockRealm(0); - migratev0(oldRealm, newRealm); - expect(newRealm.schemaVersion).toBe(0); + let oldRealm = new MockRealm(0); + let newRealm = new MockRealm(0); + migratev0(oldRealm, newRealm); + expect(newRealm.schemaVersion).toBe(0); }) test('Realm migrates to V1', () => { - let oldRealm = new MockRealm(0); - let newRealm = new MockRealm(0); - migratev0(oldRealm, newRealm); + let oldRealm = new MockRealm(0); + let newRealm = new MockRealm(0); + migratev0(oldRealm, newRealm); - oldRealm = newRealm; - newRealm = new MockRealm(1); - migratev1(oldRealm, newRealm); + oldRealm = newRealm; + newRealm = new MockRealm(1); + migratev1(oldRealm, newRealm); - expect(newRealm[System.name][0].key).toBe('username'); - expect(newRealm[System.name][0].value).toBe('changeme'); + expect(newRealm[System.name][0].key).toBe('username'); + expect(newRealm[System.name][0].value).toBe('changeme'); }) test('Realm halts V1 migration when schema is V2+', () => { - let oldRealm = new MockRealm(2); - newRealm = new MockRealm(1); - migratev1(oldRealm, newRealm); - oldRealm.create(System.name, {key: 'key1', value: 'value'}) + let oldRealm = new MockRealm(2); + newRealm = new MockRealm(1); + migratev1(oldRealm, newRealm); + oldRealm.create(System.name, {key: 'key1', value: 'value'}) - expect(oldRealm[System.name].length).toBe(1); + expect(oldRealm[System.name].length).toBe(1); }) \ No newline at end of file diff --git a/squarenotsquare/__tests__/Repo-test.js b/squarenotsquare/__tests__/Repo-test.js index 428eef1..c891706 100644 --- a/squarenotsquare/__tests__/Repo-test.js +++ b/squarenotsquare/__tests__/Repo-test.js @@ -7,114 +7,114 @@ import 'react-native-get-random-values'; import { v4 as uuidv4 } from 'uuid'; test('ScoreRepo inits', () => { - let testRepo = new ScoreRepo({fakeRealm: true}); - expect(testRepo.realmDB.fakeRealm).toEqual(true); + let testRepo = new ScoreRepo({fakeRealm: true}); + expect(testRepo.realmDB.fakeRealm).toEqual(true); }) test('SystemRepo inits', () => { - let testRepo = new SystemRepo({fakeRealm: true}); - expect(testRepo.realmDB.fakeRealm).toEqual(true); + let testRepo = new SystemRepo({fakeRealm: true}); + expect(testRepo.realmDB.fakeRealm).toEqual(true); }) test('UserRepo inits', () => { - let testRepo = new UserRepo({fakeRealm: true}); - expect(testRepo.realmDB.fakeRealm).toEqual(true); + let testRepo = new UserRepo({fakeRealm: true}); + expect(testRepo.realmDB.fakeRealm).toEqual(true); }) test('SystemRepo gets all values', () => { - let mockRealm = new MockRealm(0); - let testRepo = new SystemRepo(mockRealm); - let systemKey1 = { - id: uuidv4(), - key: 'key1', - value: 'val1' - }; - - let systemKey2 = { - id: uuidv4(), - key: 'key2', - value: 'val2' - }; - - mockRealm.create(System.name, systemKey1); - mockRealm.create(System.name, systemKey2); - - let queried = testRepo.getAllSystemValues(); - - expect(queried[systemKey1.key]).toEqual('val1'); - expect(queried[systemKey2.key]).toEqual('val2'); + let mockRealm = new MockRealm(0); + let testRepo = new SystemRepo(mockRealm); + let systemKey1 = { + id: uuidv4(), + key: 'key1', + value: 'val1' + }; + + let systemKey2 = { + id: uuidv4(), + key: 'key2', + value: 'val2' + }; + + mockRealm.create(System.name, systemKey1); + mockRealm.create(System.name, systemKey2); + + let queried = testRepo.getAllSystemValues(); + + expect(queried[systemKey1.key]).toEqual('val1'); + expect(queried[systemKey2.key]).toEqual('val2'); }) test('SystemRepo creates system value', () => { - let mockRealm = new MockRealm(0); - let testRepo = new SystemRepo(mockRealm); + let mockRealm = new MockRealm(0); + let testRepo = new SystemRepo(mockRealm); - let newSystemKey = { - key: 'newKey', - value: 'isNew' - }; + let newSystemKey = { + key: 'newKey', + value: 'isNew' + }; - testRepo.createSystemValue(newSystemKey.key, newSystemKey.value); - let object = mockRealm[System.name][0]; - expect(object.value).toEqual('isNew'); + testRepo.createSystemValue(newSystemKey.key, newSystemKey.value); + let object = mockRealm[System.name][0]; + expect(object.value).toEqual('isNew'); }) test('SystemRepo handles creation of existing system value', () => { - let mockRealm = new MockRealm(0); - let testRepo = new SystemRepo(mockRealm); - - let newSystemKey = { - key: 'newKey', - value: 'isNew' - }; - - testRepo.createSystemValue(newSystemKey.key, newSystemKey.value); - testRepo.createSystemValue(newSystemKey.key, newSystemKey.value); - let object = mockRealm[System.name][0]; - expect(object.value).toEqual('isNew'); + let mockRealm = new MockRealm(0); + let testRepo = new SystemRepo(mockRealm); + + let newSystemKey = { + key: 'newKey', + value: 'isNew' + }; + + testRepo.createSystemValue(newSystemKey.key, newSystemKey.value); + testRepo.createSystemValue(newSystemKey.key, newSystemKey.value); + let object = mockRealm[System.name][0]; + expect(object.value).toEqual('isNew'); }) test('SystemRepo deletes existing system value', () => { - let mockRealm = new MockRealm(0); - let testRepo = new SystemRepo(mockRealm); + let mockRealm = new MockRealm(0); + let testRepo = new SystemRepo(mockRealm); - let newSystemKey = { - key: 'newKey', - value: 'isNew' - }; + let newSystemKey = { + key: 'newKey', + value: 'isNew' + }; - testRepo.createSystemValue(newSystemKey.key, newSystemKey.value); - testRepo.deleteSystemValue(newSystemKey.key); + testRepo.createSystemValue(newSystemKey.key, newSystemKey.value); + testRepo.deleteSystemValue(newSystemKey.key); - expect(mockRealm.deletedKeys[0].value).toEqual(newSystemKey.value); + expect(mockRealm.deletedKeys[0].value).toEqual(newSystemKey.value); }) test('SystemRepo deletes non-existing system value', () => { - let mockRealm = new MockRealm(0); - let testRepo = new SystemRepo(mockRealm); + let mockRealm = new MockRealm(0); + let testRepo = new SystemRepo(mockRealm); - testRepo.deleteSystemValue('key'); - expect(mockRealm.deletedKeys.length).toEqual(0); + testRepo.deleteSystemValue('key'); + expect(mockRealm.deletedKeys.length).toEqual(0); }) test('SystemRepo gets multiple system values', () => { - let mockRealm = new MockRealm(0); - let testRepo = new SystemRepo(mockRealm); - - let systemKey1 = { - id: uuidv4(), - key: 'key1', - value: 'val1' - }; - - let systemKey2 = { - id: uuidv4(), - key: 'key1', - value: 'val1' - }; - - mockRealm.create(System.name, systemKey1); - mockRealm.create(System.name, systemKey2); - let response = testRepo.getSystemKeyValue(systemKey1.key); - expect(response).toEqual('Multiple system keys found for key1'); + let mockRealm = new MockRealm(0); + let testRepo = new SystemRepo(mockRealm); + + let systemKey1 = { + id: uuidv4(), + key: 'key1', + value: 'val1' + }; + + let systemKey2 = { + id: uuidv4(), + key: 'key1', + value: 'val1' + }; + + mockRealm.create(System.name, systemKey1); + mockRealm.create(System.name, systemKey2); + let response = testRepo.getSystemKeyValue(systemKey1.key); + expect(response).toEqual('Multiple system keys found for key1'); }) \ No newline at end of file diff --git a/squarenotsquare/index.js b/squarenotsquare/index.js index e99c319..16b4988 100644 --- a/squarenotsquare/index.js +++ b/squarenotsquare/index.js @@ -9,7 +9,7 @@ const squareStore = configStore; squareStore.dispatch(appInit()); const ProppedContainer = () => { - return ; + return ; }; AppRegistry.registerComponent(appName, () => ProppedContainer); \ No newline at end of file diff --git a/squarenotsquare/jest.config.js b/squarenotsquare/jest.config.js index b6c222b..aa7322b 100644 --- a/squarenotsquare/jest.config.js +++ b/squarenotsquare/jest.config.js @@ -1,16 +1,16 @@ module.exports = { - // setupFiles: ['./jestSetup.js'], - preset: 'react-native', - verbose: true, - setupFiles: ['./node_modules/react-native-gesture-handler/jestSetup.js'], - moduleDirectories: ['node_modules', 'src'], - moduleNameMapper: { - // '@react-native-firebase/messaging: '/__mock__/mockFirebase.js', - '../services/Keystore': '/__mock__/mockKeyStore.js', - '\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '/__mock__/file.js' - }, - transform: { - '^.+\\.(ts|tsx)?$': 'ts-jest', - '^.+\\.(js|jsx)$': 'babel-jest', - } + // setupFiles: ['./jestSetup.js'], + preset: 'react-native', + verbose: true, + setupFiles: ['./node_modules/react-native-gesture-handler/jestSetup.js'], + moduleDirectories: ['node_modules', 'src'], + moduleNameMapper: { + // '@react-native-firebase/messaging: '/__mock__/mockFirebase.js', + '../services/Keystore': '/__mock__/mockKeyStore.js', + '\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '/__mock__/file.js' + }, + transform: { + '^.+\\.(ts|tsx)?$': 'ts-jest', + '^.+\\.(js|jsx)$': 'babel-jest', + } } \ No newline at end of file diff --git a/squarenotsquare/metro.config.js b/squarenotsquare/metro.config.js index e91aba9..0631cd7 100644 --- a/squarenotsquare/metro.config.js +++ b/squarenotsquare/metro.config.js @@ -7,11 +7,11 @@ module.exports = { transformer: { - getTransformOptions: async () => ({ - transform: { - experimentalImportSupport: false, - inlineRequires: true, - }, - }), + getTransformOptions: async () => ({ + transform: { + experimentalImportSupport: false, + inlineRequires: true, + }, + }), }, }; diff --git a/squarenotsquare/src/libs/Random.js b/squarenotsquare/src/libs/Random.js index 79b4968..aeea885 100644 --- a/squarenotsquare/src/libs/Random.js +++ b/squarenotsquare/src/libs/Random.js @@ -1,13 +1,13 @@ export function generateKey() { - let result = []; - const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - let charactersLength = characters.length; + let result = []; + const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + let charactersLength = characters.length; - for (let i = 0; i < 64; i++) { - result.push( - characters.charAt(Math.floor(Math.random() * charactersLength)), - ); - } + for (let i = 0; i < 64; i++) { + result.push( + characters.charAt(Math.floor(Math.random() * charactersLength)), + ); + } - return result.join(''); + return result.join(''); } \ No newline at end of file diff --git a/squarenotsquare/src/navigation/SquareNav.js b/squarenotsquare/src/navigation/SquareNav.js index 650f40d..30d8ac7 100644 --- a/squarenotsquare/src/navigation/SquareNav.js +++ b/squarenotsquare/src/navigation/SquareNav.js @@ -3,5 +3,5 @@ import { createRef } from "react"; export const squareRef = createRef(); export function navigate(name, params) { - squareRef.current?.navigate(name, params); + squareRef.current?.navigate(name, params); } \ No newline at end of file diff --git a/squarenotsquare/src/navigation/SquareStack.js b/squarenotsquare/src/navigation/SquareStack.js index d62f4e4..28bce3f 100644 --- a/squarenotsquare/src/navigation/SquareStack.js +++ b/squarenotsquare/src/navigation/SquareStack.js @@ -12,39 +12,39 @@ import Splash from '../screens/Splash'; const SquareNav = createStackNavigator(); function SquareStack() { - let noHeader = {headerShown: false}; + let noHeader = {headerShown: false}; - return ( - - - - - - - - - - ) + return ( + + + + + + + + + + ) } export default SquareStack; \ No newline at end of file diff --git a/squarenotsquare/src/realm/dbAPI.js b/squarenotsquare/src/realm/dbAPI.js index 07fa106..60f506f 100644 --- a/squarenotsquare/src/realm/dbAPI.js +++ b/squarenotsquare/src/realm/dbAPI.js @@ -1,29 +1,29 @@ import {systemRepo, userRepo, scoreRepo} from './dbInit'; class realmAPI { - constructor(){ - if (realmDB === null) { - realmDB = this; - } - - return realmDB; + constructor(){ + if (realmDB === null) { + realmDB = this; } - getAllSystemValues() { - return systemRepo.getAllSystemValues(); - } - - createSystemValue(key, value) { - systemRepo.createSystemValue(key, value); - } + return realmDB; + } - deleteSystemValue(key) { - systemRepo.deleteSystemValue(key); - } + getAllSystemValues() { + return systemRepo.getAllSystemValues(); + } + + createSystemValue(key, value) { + systemRepo.createSystemValue(key, value); + } - getSystemValue(key) { - return systemRepo.getSystemKeyValue(key); - } + deleteSystemValue(key) { + systemRepo.deleteSystemValue(key); + } + + getSystemValue(key) { + return systemRepo.getSystemKeyValue(key); + } } export let realmDB = new realmAPI(); \ No newline at end of file diff --git a/squarenotsquare/src/realm/dbInit.js b/squarenotsquare/src/realm/dbInit.js index 25853b6..06ea0d8 100644 --- a/squarenotsquare/src/realm/dbInit.js +++ b/squarenotsquare/src/realm/dbInit.js @@ -22,61 +22,59 @@ let systemRepo = null; let scoreRepo = null; let userRepo = null; -let realmDB = null; - export async function initDB(){ - try { - const dbKeyRef = 'squareDB'; - let fromStore = await KeyStore.getKey(dbKeyRef); - - if (fromStore === null) { - let newKey = generateKey(); - await KeyStore.setKey(dbKeyRef, newKey); - fromStore = await KeyStore.getKey(dbKeyRef); - } - - let dbKey = new Uint8Array(64); - if (fromStore !== null){ - for (let i = 0; i < 64; ++i){ - dbKey[i] = fromStore.charAt(i); - } - } + try { + const dbKeyRef = 'squareDB'; + let fromStore = await KeyStore.getKey(dbKeyRef); + + if (fromStore === null) { + let newKey = generateKey(); + await KeyStore.setKey(dbKeyRef, newKey); + fromStore = await KeyStore.getKey(dbKeyRef); + } + + let dbKey = new Uint8Array(64); + if (fromStore !== null){ + for (let i = 0; i < 64; ++i){ + dbKey[i] = fromStore.charAt(i); + } + } - let dbRef = realmDB; + let dbRef = null; - if (dbRef === null){ - let schemaList = [ - {schemaVersion: 0, schema: [System, User, Score], migration: migratev0, encryptionKey: dbKey}, - {schemaVersion: 1, schema: [System, User, Score], migration: migratev1, encryptionKey: dbKey} - ] - - let currentSchema = Realm.schemaVersion(Realm.defaultPath, dbKey); - - if (currentSchema === -1) { - currentSchema = 0; - } - - while (currentSchema < schemaList.length) { - if (dbRef !== null) { - dbRef.close(); - } + if (dbRef === null){ + let schemaList = [ + {schemaVersion: 0, schema: [System, User, Score], migration: migratev0, encryptionKey: dbKey}, + {schemaVersion: 1, schema: [System, User, Score], migration: migratev1, encryptionKey: dbKey} + ] + + let currentSchema = Realm.schemaVersion(Realm.defaultPath, dbKey); + + if (currentSchema === -1) { + currentSchema = 0; + } - dbRef = new Realm(schemaList[currentSchema]); - currentSchema += 1; - } - - if (dbRef === null) { - dbRef = new Realm(schemaList[schemaList.length - 1]); - } - - systemRepo = new SystemRepo(dbRef); - userRepo = new UserRepo(dbRef); - scoreRepo = new ScoreRepo(dbRef) + while (currentSchema < schemaList.length) { + if (dbRef !== null) { + dbRef.close(); } - - let realmDB = dbRef; - return realmDB; - } catch (err) { - console.log(err); + + dbRef = new Realm(schemaList[currentSchema]); + currentSchema += 1; + } + + if (dbRef === null) { + dbRef = new Realm(schemaList[schemaList.length - 1]); + } + + systemRepo = new SystemRepo(dbRef); + userRepo = new UserRepo(dbRef); + scoreRepo = new ScoreRepo(dbRef) } + + return dbRef; + } catch (err) { + console.log(err); + return null; + } } \ No newline at end of file diff --git a/squarenotsquare/src/realm/entities/Score.js b/squarenotsquare/src/realm/entities/Score.js index 5e65d37..2c1c055 100644 --- a/squarenotsquare/src/realm/entities/Score.js +++ b/squarenotsquare/src/realm/entities/Score.js @@ -1,9 +1,9 @@ export const Score = { - name: 'Score', - primaryKey: 'id', - properties: { - id: 'string', - user: 'string', - value: 'string' - } + name: 'Score', + primaryKey: 'id', + properties: { + id: 'string', + user: 'string', + value: 'string' + } }; \ No newline at end of file diff --git a/squarenotsquare/src/realm/entities/System.js b/squarenotsquare/src/realm/entities/System.js index 03d0f45..27139d0 100644 --- a/squarenotsquare/src/realm/entities/System.js +++ b/squarenotsquare/src/realm/entities/System.js @@ -1,9 +1,9 @@ export const System = { - name: 'System', - primaryKey: 'id', - properties: { - id: 'string', - key: 'string', - value: 'string' - } + name: 'System', + primaryKey: 'id', + properties: { + id: 'string', + key: 'string', + value: 'string' + } }; \ No newline at end of file diff --git a/squarenotsquare/src/realm/entities/User.js b/squarenotsquare/src/realm/entities/User.js index 5f1aaf1..003c325 100644 --- a/squarenotsquare/src/realm/entities/User.js +++ b/squarenotsquare/src/realm/entities/User.js @@ -1,8 +1,8 @@ export const User = { - name: 'User', - primaryKey: 'id', - properties: { - id: 'string', - name: 'string' - } + name: 'User', + primaryKey: 'id', + properties: { + id: 'string', + name: 'string' + } } \ No newline at end of file diff --git a/squarenotsquare/src/realm/migrations/MigrateV0.js b/squarenotsquare/src/realm/migrations/MigrateV0.js index 24868d7..7543afc 100644 --- a/squarenotsquare/src/realm/migrations/MigrateV0.js +++ b/squarenotsquare/src/realm/migrations/MigrateV0.js @@ -1,3 +1,3 @@ export function migratev0(oldRealm, newRealm) { - Function.prototype + Function.prototype } \ No newline at end of file diff --git a/squarenotsquare/src/realm/migrations/MigrateV1.js b/squarenotsquare/src/realm/migrations/MigrateV1.js index 797c6e2..a88bc4d 100644 --- a/squarenotsquare/src/realm/migrations/MigrateV1.js +++ b/squarenotsquare/src/realm/migrations/MigrateV1.js @@ -3,11 +3,11 @@ import 'react-native-get-random-values'; import { v4 as uuidv4 } from 'uuid'; export function migratev1(oldRealm, newRealm) { - if (oldRealm.schemaVersion === 0) { - newRealm.create(System.name, { - id: uuidv4(), - key: 'username', - value: 'changeme' - }); - } + if (oldRealm.schemaVersion === 0) { + newRealm.create(System.name, { + id: uuidv4(), + key: 'username', + value: 'changeme' + }); + } } diff --git a/squarenotsquare/src/realm/repos/ScoreRepo.js b/squarenotsquare/src/realm/repos/ScoreRepo.js index fae72dc..1932cea 100644 --- a/squarenotsquare/src/realm/repos/ScoreRepo.js +++ b/squarenotsquare/src/realm/repos/ScoreRepo.js @@ -3,9 +3,9 @@ import 'react-native-get-random-values'; import { v4 as uuidv4 } from 'uuid'; export default class ScoreRepo { - realmDB = null; + realmDB = null; - constructor(db) { - this.realmDB = db; - } + constructor(db) { + this.realmDB = db; + } } \ No newline at end of file diff --git a/squarenotsquare/src/realm/repos/SystemRepo.js b/squarenotsquare/src/realm/repos/SystemRepo.js index eab676e..c20a1ff 100644 --- a/squarenotsquare/src/realm/repos/SystemRepo.js +++ b/squarenotsquare/src/realm/repos/SystemRepo.js @@ -3,63 +3,63 @@ import 'react-native-get-random-values'; import { v4 as uuidv4 } from 'uuid'; export default class SystemRepo { - realmDB = null; + realmDB = null; - constructor(db) { - this.realmDB = db; - } + constructor(db) { + this.realmDB = db; + } - getAllSystemValues = () => { - let system = this.realmDB.objects(System.name); - let systemValues = {}; - system.forEach((row) => { - systemValues[row.key] = row.value; - }); - return systemValues; - }; + getAllSystemValues = () => { + let system = this.realmDB.objects(System.name); + let systemValues = {}; + system.forEach((row) => { + systemValues[row.key] = row.value; + }); + return systemValues; + }; - createSystemValue = (key, value) => { - let sysID = null; - let sysKey = key; - let sysValue = value; - - let existing = this.getSystemKeyValue(key); - - if (existing.id === null) { - sysID = uuidv4(); - } else { - sysID = existing.id; - } - this.realmDB.write(() => { - this.realmDB.create( - System.name, - { - id: sysID, - key: sysKey, - value: sysValue, - }, - true, - ); - }); - }; + createSystemValue = (key, value) => { + let sysID = null; + let sysKey = key; + let sysValue = value; + + let existing = this.getSystemKeyValue(key); + + if (existing.id === null) { + sysID = uuidv4(); + } else { + sysID = existing.id; + } + this.realmDB.write(() => { + this.realmDB.create( + System.name, + { + id: sysID, + key: sysKey, + value: sysValue, + }, + true, + ); + }); + }; - deleteSystemValue = (key) => { - let existingKey = this.getSystemKeyValue(key); - if (existingKey.id !== null) { - this.realmDB.write(() => { - this.realmDB.delete(existingKey); - }); - } - }; + deleteSystemValue = (key) => { + let existingKey = this.getSystemKeyValue(key); + if (existingKey.id !== null) { + this.realmDB.write(() => { + this.realmDB.delete(existingKey); + }); + } + }; - getSystemKeyValue = (key) => { - let row = this.realmDB.objects(System.name).filtered('key = $0', key); - if (row.length === 1) { - return {id: row[0].id, value: row[0].value}; - } else if (row.length > 1) { - return 'Multiple system keys found for ' + key; - } else { - return {id: null, value: null}; - } - }; + getSystemKeyValue = (key) => { + let row = this.realmDB.objects(System.name).filtered('key = $0', key); + if (row.length === 1) { + return {id: row[0].id, value: row[0].value}; + } else if (row.length > 1) { + return 'Multiple system keys found for ' + key; + } else { + return {id: null, value: null}; + } + }; } \ No newline at end of file diff --git a/squarenotsquare/src/realm/repos/UserRepo.js b/squarenotsquare/src/realm/repos/UserRepo.js index 9892340..dcef5e8 100644 --- a/squarenotsquare/src/realm/repos/UserRepo.js +++ b/squarenotsquare/src/realm/repos/UserRepo.js @@ -3,9 +3,9 @@ import 'react-native-get-random-values'; import { v4 as uuidv4 } from 'uuid'; export default class UserRepo { - realmDB = null; + realmDB = null; - constructor(db) { - this.realmDB = db; - } + constructor(db) { + this.realmDB = db; + } } \ No newline at end of file diff --git a/squarenotsquare/src/redux/actions/SystemActions.js b/squarenotsquare/src/redux/actions/SystemActions.js index 5793adc..fae6cf8 100644 --- a/squarenotsquare/src/redux/actions/SystemActions.js +++ b/squarenotsquare/src/redux/actions/SystemActions.js @@ -3,19 +3,19 @@ import { realmDB } from "../../realm/dbAPI"; import { APP_INIT } from "../types/SystemTypes"; export function appInit() { - return async (dispatch) => { - await initDB(); - dispatch(onInit()); - } + return async (dispatch) => { + await initDB(); + dispatch(onInit()); + } } function onInit() { - return (dispatch) => { - dispatch({ - type: APP_INIT - //system: system - //user: user - //score: score - }); - } + return (dispatch) => { + dispatch({ + type: APP_INIT + //system: system + //user: user + //score: score + }); + } } \ No newline at end of file diff --git a/squarenotsquare/src/redux/reducers/NavReducer.js b/squarenotsquare/src/redux/reducers/NavReducer.js index 7e204c1..16f162a 100644 --- a/squarenotsquare/src/redux/reducers/NavReducer.js +++ b/squarenotsquare/src/redux/reducers/NavReducer.js @@ -3,13 +3,13 @@ import * as SquareNav from '../../navigation/SquareNav'; import { APP_INIT } from '../types/SystemTypes'; export function navReducer(state = {}, action){ - switch (action.type) { - case APP_INIT: - //SquareNav.navigate('Home'); - break; - default: - break; - } + switch (action.type) { + case APP_INIT: + //SquareNav.navigate('Home'); + break; + default: + break; + } - return state; + return state; } \ No newline at end of file diff --git a/squarenotsquare/src/redux/reducers/RootReducer.js b/squarenotsquare/src/redux/reducers/RootReducer.js index 83105b2..8b54e1f 100644 --- a/squarenotsquare/src/redux/reducers/RootReducer.js +++ b/squarenotsquare/src/redux/reducers/RootReducer.js @@ -3,8 +3,8 @@ import { systemReducer } from './SystemReducer'; import { navReducer } from './NavReducer'; const rootReducer = combineReducers({ - ...systemReducer, - navReducer + ...systemReducer, + navReducer }); export default rootReducer; \ No newline at end of file diff --git a/squarenotsquare/src/redux/reducers/SystemReducer.js b/squarenotsquare/src/redux/reducers/SystemReducer.js index 81d2858..013edc1 100644 --- a/squarenotsquare/src/redux/reducers/SystemReducer.js +++ b/squarenotsquare/src/redux/reducers/SystemReducer.js @@ -1,14 +1,14 @@ import { APP_INIT } from "../types/SystemTypes"; function sys(state = {}, action) { - switch (action.type) { - case APP_INIT: - return {...state, ...action.system}; - default: - return state; - } + switch (action.type) { + case APP_INIT: + return {...state, ...action.system}; + default: + return state; + } } export const systemReducer = { - system: sys + system: sys }; \ No newline at end of file diff --git a/squarenotsquare/src/screens/Game.js b/squarenotsquare/src/screens/Game.js index 2153317..106d1d5 100644 --- a/squarenotsquare/src/screens/Game.js +++ b/squarenotsquare/src/screens/Game.js @@ -4,11 +4,11 @@ import { useState } from "react"; function Game(props){ - return ( - - test - - ); + return ( + + test + + ); } export default Game; \ No newline at end of file diff --git a/squarenotsquare/src/screens/HighScore.js b/squarenotsquare/src/screens/HighScore.js index 390422a..4ec3a80 100644 --- a/squarenotsquare/src/screens/HighScore.js +++ b/squarenotsquare/src/screens/HighScore.js @@ -4,11 +4,11 @@ import { useState } from "react"; function HighScore(props){ - return ( - - test - - ); + return ( + + test + + ); } export default HighScore; \ No newline at end of file diff --git a/squarenotsquare/src/screens/Home.js b/squarenotsquare/src/screens/Home.js index 35ee4e7..e836d60 100644 --- a/squarenotsquare/src/screens/Home.js +++ b/squarenotsquare/src/screens/Home.js @@ -4,11 +4,11 @@ import { useState } from "react"; function Home(props){ - return ( - - test - - ); + return ( + + test + + ); } export default Home; \ No newline at end of file diff --git a/squarenotsquare/src/screens/Settings.js b/squarenotsquare/src/screens/Settings.js index 91cfd0a..a08d504 100644 --- a/squarenotsquare/src/screens/Settings.js +++ b/squarenotsquare/src/screens/Settings.js @@ -4,11 +4,11 @@ import { useState } from "react"; function Settings(props){ - return ( - - test - - ); + return ( + + test + + ); } export default Settings; \ No newline at end of file diff --git a/squarenotsquare/src/screens/Splash.js b/squarenotsquare/src/screens/Splash.js index 5323b79..fa261a7 100644 --- a/squarenotsquare/src/screens/Splash.js +++ b/squarenotsquare/src/screens/Splash.js @@ -4,11 +4,11 @@ import { useState } from "react"; function Splash(props){ - return ( - - test - - ); + return ( + + test + + ); } export default Splash; \ No newline at end of file diff --git a/squarenotsquare/src/screens/styles/AppStyles.js b/squarenotsquare/src/screens/styles/AppStyles.js index f90743a..441a1bf 100644 --- a/squarenotsquare/src/screens/styles/AppStyles.js +++ b/squarenotsquare/src/screens/styles/AppStyles.js @@ -4,62 +4,62 @@ import * as fonts from '../../themes/Fonts'; import * as metrics from '../../themes/Metrics'; export const styles = StyleSheet.create({ - flex: {flex: 1}, - flexDouble: {flex: 2}, - flexTriple: {flex: 3}, - flexHalf: {flex: 0.5}, - flexThird: {flex: 0.33}, - flexTwoThirds: {flex: 0.67}, - flexRow: {flexDirection: 'row'}, - flexColumn: {flexDirection: 'column'}, - flexWrap: {flexWrap: 'wrap'}, - flexShrink: {flexShrink: 1}, + flex: {flex: 1}, + flexDouble: {flex: 2}, + flexTriple: {flex: 3}, + flexHalf: {flex: 0.5}, + flexThird: {flex: 0.33}, + flexTwoThirds: {flex: 0.67}, + flexRow: {flexDirection: 'row'}, + flexColumn: {flexDirection: 'column'}, + flexWrap: {flexWrap: 'wrap'}, + flexShrink: {flexShrink: 1}, - centeredJustify: {justifyContent: 'center'}, - centeredItems: {alignItems: 'center'}, - centeredContent: {alignContent: 'center'}, - centeredSelf: {alignSelf: 'center'}, + centeredJustify: {justifyContent: 'center'}, + centeredItems: {alignItems: 'center'}, + centeredContent: {alignContent: 'center'}, + centeredSelf: {alignSelf: 'center'}, - startAlign: {alignSelf: 'flex-start'}, - endAlign: {alignSelf: 'flex-end'}, - startJustify: {justifyContent: 'flex-start'}, - endJustify: {justifyContent: 'flex-end'}, + startAlign: {alignSelf: 'flex-start'}, + endAlign: {alignSelf: 'flex-end'}, + startJustify: {justifyContent: 'flex-start'}, + endJustify: {justifyContent: 'flex-end'}, - stretch: {alignSelf: 'stretch'}, - absolute: { - position: 'absolute', - top: metrics.screenSections.headerHeight, - bottom: 0, - left: 0, - right: 0, - }, + stretch: {alignSelf: 'stretch'}, + absolute: { + position: 'absolute', + top: metrics.screenSections.headerHeight, + bottom: 0, + left: 0, + right: 0, + }, - spaceBetween: {justifyContent: 'space-between'}, - spaceEvenly: {justifyContent: 'space-evenly'}, - spaceAround: {justifyContent: 'space-around'}, + spaceBetween: {justifyContent: 'space-between'}, + spaceEvenly: {justifyContent: 'space-evenly'}, + spaceAround: {justifyContent: 'space-around'}, - centeredText: {textAlign: 'center'}, - rightText: {textAlign: 'right'}, - leftText: {textAlign: 'left'}, + centeredText: {textAlign: 'center'}, + rightText: {textAlign: 'right'}, + leftText: {textAlign: 'left'}, - headerTitleFont: {fontSize: fonts.headerTitle.size}, - largeFont: {fontSize: fonts.large.size}, - mediumFont: {fontSize: fonts.medium.size}, - smallFont: {fontSize: fonts.small.size}, - tinyFont: {fontSize: fonts.tiny.size}, - subFont: {fontSize: fonts.subFont.size}, - tickFont: {fontSize: fonts.tickFont.size}, + headerTitleFont: {fontSize: fonts.headerTitle.size}, + largeFont: {fontSize: fonts.large.size}, + mediumFont: {fontSize: fonts.medium.size}, + smallFont: {fontSize: fonts.small.size}, + tinyFont: {fontSize: fonts.tiny.size}, + subFont: {fontSize: fonts.subFont.size}, + tickFont: {fontSize: fonts.tickFont.size}, - italic: {fontStyle: 'italic'}, - greyText: {color: colors.material.grey600}, - redText: {color: colors.material.red800}, - blueText: {color: colors.material.blue400}, - boldText: {fontWeight: 'bold'}, + italic: {fontStyle: 'italic'}, + greyText: {color: colors.material.grey600}, + redText: {color: colors.material.red800}, + blueText: {color: colors.material.blue400}, + boldText: {fontWeight: 'bold'}, - lightText: {color: colors.impulseColors.lightText}, - darkText: {color: colors.impulseColors.black}, + lightText: {color: colors.impulseColors.lightText}, + darkText: {color: colors.impulseColors.black}, - body: { - backgroundColor: colors.material.light, - } + body: { + backgroundColor: colors.material.light, + } }) \ No newline at end of file diff --git a/squarenotsquare/src/services/Keystore.js b/squarenotsquare/src/services/Keystore.js index 3ee94cc..09aae48 100644 --- a/squarenotsquare/src/services/Keystore.js +++ b/squarenotsquare/src/services/Keystore.js @@ -2,37 +2,37 @@ import RNSecureKeyStore, {ACCESSIBLE} from 'react-native-secure-key-store'; export async function removeKey(key) { await RNSecureKeyStore.remove(key).then( - (res) => { - console.log('Removed key ' + res); - }, - (err) => { - console.log(err.message); - }, + (res) => { + console.log('Removed key ' + res); + }, + (err) => { + console.log(err.message); + }, ); } export async function setKey(key, value) { await RNSecureKeyStore.set(key, value, { - accessible: ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY, + accessible: ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY, }).then( - (res) => { - console.log('Set key ' + res); - }, - (err) => { - console.log(err.message); - }, + (res) => { + console.log('Set key ' + res); + }, + (err) => { + console.log(err.message); + }, ); } export async function getKey(key) { let value = null; await RNSecureKeyStore.get(key).then( - (res) => { - value = res; - }, - (err) => { - console.log(err.message); - }, + (res) => { + value = res; + }, + (err) => { + console.log(err.message); + }, ); return value; } diff --git a/squarenotsquare/src/themes/Colors.js b/squarenotsquare/src/themes/Colors.js index 83eb8f4..c79531a 100644 --- a/squarenotsquare/src/themes/Colors.js +++ b/squarenotsquare/src/themes/Colors.js @@ -1,31 +1,31 @@ export const material = { - dark: '#212121', - light: '#ffffff', + dark: '#212121', + light: '#ffffff', - //200 - blue200: '#90caf9', + //200 + blue200: '#90caf9', - //400 - blue400: '#5c6bc0', - grey400: '#bdbdbd', + //400 + blue400: '#5c6bc0', + grey400: '#bdbdbd', - //600 - grey600: '#757575', + //600 + grey600: '#757575', - //700 - grey700: '#616161', + //700 + grey700: '#616161', - //800 - amber800: '#ff8f00', - blue800: '#1565c0', - red800: '#c62828', - red800dark: '#7f0000', - grey800: '#424242', - grey800dark: '#1b1b1b', - green800: '#2e7d32', + //800 + amber800: '#ff8f00', + blue800: '#1565c0', + red800: '#c62828', + red800dark: '#7f0000', + grey800: '#424242', + grey800dark: '#1b1b1b', + green800: '#2e7d32', } export const fonts = { - dark: '#000000', - light: '#ffffff' + dark: '#000000', + light: '#ffffff' }; \ No newline at end of file diff --git a/squarenotsquare/src/themes/Fonts.js b/squarenotsquare/src/themes/Fonts.js index 184d5ea..a787705 100644 --- a/squarenotsquare/src/themes/Fonts.js +++ b/squarenotsquare/src/themes/Fonts.js @@ -3,47 +3,47 @@ import {PixelRatio} from 'react-native'; const scalar = PixelRatio.getFontScale(); function normalizeFont(size) { - return size * scalar + return size * scalar }; export const fonts = { - headerTitle: { - fam: 'arial', - size: normalizeFont(30), - }, - - sectionHeader: { - fam: 'arial', - size: normalizeFont(26), - }, - - large: { - fam: 'arial', - size: normalizeFont(22), - }, - - medium: { - fam: 'arial', - size: normalizeFont(20), - }, - - small: { - fam: 'arial', - size: normalizeFont(16), - }, - - tiny: { - fam: 'arial', - size: normalizeFont(14), - }, - - mini: { - fam: 'arial', - size: normalizeFont(10), - }, - - subFont: { - fam: 'arial', - size: normalizeFont(8), - }, + headerTitle: { + fam: 'arial', + size: normalizeFont(30), + }, + + sectionHeader: { + fam: 'arial', + size: normalizeFont(26), + }, + + large: { + fam: 'arial', + size: normalizeFont(22), + }, + + medium: { + fam: 'arial', + size: normalizeFont(20), + }, + + small: { + fam: 'arial', + size: normalizeFont(16), + }, + + tiny: { + fam: 'arial', + size: normalizeFont(14), + }, + + mini: { + fam: 'arial', + size: normalizeFont(10), + }, + + subFont: { + fam: 'arial', + size: normalizeFont(8), + }, } \ No newline at end of file diff --git a/squarenotsquare/src/themes/Icons.js b/squarenotsquare/src/themes/Icons.js index 685154d..2f13380 100644 --- a/squarenotsquare/src/themes/Icons.js +++ b/squarenotsquare/src/themes/Icons.js @@ -1,5 +1,5 @@ export const squareIcons = { - settings: 'cog-outline', - toggleOn: 'toggle-switch-on', - toggleOfff: 'toggle-switch-off' + settings: 'cog-outline', + toggleOn: 'toggle-switch-on', + toggleOfff: 'toggle-switch-off' }; \ No newline at end of file diff --git a/squarenotsquare/src/themes/Metrics.js b/squarenotsquare/src/themes/Metrics.js index 6b5f7f5..f19077d 100644 --- a/squarenotsquare/src/themes/Metrics.js +++ b/squarenotsquare/src/themes/Metrics.js @@ -3,7 +3,7 @@ import { PixelRatio, Dimensions } from "react-native"; let scalar = PixelRatio.get(); function normalize(size){ - return (size * scalar); + return (size * scalar); } let dimensions = Dimensions.get('window'); @@ -15,11 +15,11 @@ let screenWidth = width; let screenHeight = height; if (width > height) { - screenHeight = width; - screenWidth = height; + screenHeight = width; + screenWidth = height; } export const screenSections = { - headerHeight: normalize(20), - sectionWidth: screenWidth + headerHeight: normalize(20), + sectionWidth: screenWidth } \ No newline at end of file