Skip to content

Commit f138fd6

Browse files
JemokaTheEnquirer
andauthored
Merge pull request #266 from Shabang-Systems/feat-settingsv3
Settings, Keybinds, and Keybord-Nav UI Version 3 co-authored-by: TheEnquirer <[email protected]>
2 parents 6b0c8da + b2cece4 commit f138fd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+8517
-2989
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ ionic.config.json
3232

3333
*.jks
3434
playstore_creds.json
35+
/.log/

justfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
run:
2+
yarn ionic:runserver

package.json

+14-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
"name": "Condution",
33
"version": "1.2.0",
44
"dependencies": {
5+
"@babel/helper-string-parser": "^7.18.10",
56
"@capacitor-community/electron": "^3.0.1",
67
"@capacitor/android": "^3.0.2",
78
"@capacitor/browser": "^1.0.2",
89
"@capacitor/core": "^3.3.4",
910
"@capacitor/filesystem": "^1.0.2",
1011
"@capacitor/haptics": "^1.0.2",
1112
"@capacitor/ios": "^3.0.2",
13+
"@capacitor/preferences": "^4.0.1",
1214
"@capacitor/storage": "^1.0.2",
1315
"@ionic/core": "^5.6.10",
1416
"@ionic/react": "^5.6.10",
@@ -31,12 +33,18 @@
3133
"electron-updater": "^4.3.9",
3234
"firebase": "^8.6.8",
3335
"install": "^0.13.0",
36+
"ionic": "^5.4.16",
3437
"ionicons": "^5.5.2",
3538
"jquery": "^3.5.1",
39+
"kbar": "^0.1.0-beta.36",
3640
"mousetrap": "^1.6.5",
3741
"mousetrap-global-bind": "^1.1.0",
42+
"mousetrap-record": "^1.0.1",
43+
"nanoid": "^4.0.0",
44+
"node-polyfill-webpack-plugin": "^2.0.0",
3845
"node-sass": "^6.0.1",
3946
"normalize-url": "^4.5.1",
47+
"path-browserify": "^1.0.1",
4048
"react": "17",
4149
"react-beautiful-dnd": "^13.0.0",
4250
"react-bootstrap": "^1.6.1",
@@ -45,6 +53,8 @@
4553
"react-dom": "^17.0.2",
4654
"react-getscreen": "^1.1.3",
4755
"react-input-autosize": "^3.0.0",
56+
"react-input-shortcut": "^0.0.1",
57+
"react-keybind": "^0.9.4",
4858
"react-localization": "^1.0.17",
4959
"react-lottie": "^1.2.3",
5060
"react-outside-click-handler": "^1.3.0",
@@ -53,6 +63,7 @@
5363
"react-router-dom": "^5.1.2",
5464
"react-scripts": "^4.0.3",
5565
"react-select": "^4.3.1",
66+
"react-shortcut-picker": "^1.3.1",
5667
"react-spring": "8.0.25",
5768
"react-tagsinput": "^3.19.0",
5869
"react-tooltip": "^4.2.21",
@@ -105,7 +116,9 @@
105116
"@typescript-eslint/parser": "^4.28.0",
106117
"electron": "^13.1.4",
107118
"electron-builder": "^22.11.7",
108-
"electron-notarize": "^1.0.0"
119+
"electron-notarize": "^1.0.0",
120+
"eslint-config-react": "^1.1.7",
121+
"eslint-config-react-app": "^7.0.1"
109122
},
110123
"description": "Tasks? Done. That was quick.",
111124
"build": {

public/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<!-- add to homescreen for ios -->
2222
<meta name="apple-mobile-web-app-capable" content="yes" />
2323
<meta name="apple-mobile-web-app-title" content="Condution" />
24+
<meta name="color-scheme" content="light dark" />
2425
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
2526
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
2627
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css" rel="stylesheet" />

src/App.jsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import './themefiles/condutiontheme-default-adapter.css';
2525
import './themefiles/condutiontheme-default.css';
2626
import './themefiles/condutiontheme-default-dark.css';
2727
import './themefiles/condutiontheme-default-light.css';
28-
//import './themefiles/condutiontheme-default-new.css';
2928
import './themefiles/condutiontheme-black-n-red.css';
3029

3130
/* Font awesome */
@@ -38,6 +37,9 @@ import './theme/variables.css';
3837
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
3938
import { Storage } from '@capacitor/storage';
4039

40+
/* Keybinds! */
41+
import { withShortcut, ShortcutProvider, ShortcutConsumer } from './static/react-keybind'
42+
4143
import $ from "jquery";
4244

4345
/* Our Lovley Core Engine */
@@ -413,10 +415,10 @@ class App extends Component {
413415
case "firebase":
414416
case "json":
415417
case "portjson":
416-
return <Home cm={this.cm} dispatch={this.authDispatch} displayName={this.state.displayName} localizations={this.state.localizations} authType={this.state.authMode}/>;
418+
return <ShortcutProvider> <Home cm={this.cm} dispatch={this.authDispatch} displayName={this.state.displayName} localizations={this.state.localizations} authType={this.state.authMode}/> </ShortcutProvider>;
417419
//email={firebase.auth().currentUser.email}
418420
case "workspace":
419-
return <Home cm={this.cm} dispatch={this.authDispatch} displayName={this.state.displayName} localizations={this.state.localizations} authType={this.state.authMode} workspace={this.state.workspace}/>;
421+
return <ShortcutProvider> <Home cm={this.cm} dispatch={this.authDispatch} displayName={this.state.displayName} localizations={this.state.localizations} authType={this.state.authMode} workspace={this.state.workspace}/> </ShortcutProvider>;
420422
//return <Home engine={Engine} uid={this.state.uid} dispatch={this.authDispatch} gruntman={this.gruntman} displayName={this.state.displayName} localizations={this.state.localizations} authType={this.state.authMode} workspace={this.state.workspace}/>;
421423
case "json":
422424
//return <Home engine={Engine} uid={this.state.uid} dispatch={this.authDispatch} gruntman={this.gruntman} displayName={this.state.displayName} localizations={this.state.localizations} authType={this.state.authMode}/>;
@@ -435,7 +437,7 @@ class App extends Component {
435437
}
436438
}
437439

438-
export default App;
440+
export default withShortcut(App);
439441
//class App extends Component {
440442
//render() {
441443
//return (

src/about.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<div id="center">
6262
<h1 style="margin:0; font-size: 24px; padding-bottom: 6px"><t style="font-weight: 300;padding-right: 3px;">#!/Shabang</t> <b style="color:#434d5f;">Condution</b></h1>
6363
<t style="font-size: 15px; font-weight: 600; padding-right: 10px;">Tasks? Done. That was simple.</t>
64-
<t style="font-size: 12px; font-weight: 300"><b>snow crash</b> v1.2.0_build4_M</t>
64+
<t style="font-size: 12px; font-weight: 300"><b>snow crash</b> v1.2.0_build0_M</t>
6565
<br />
6666
<br />
6767
<br />

src/pages/Calendar.jsx

+69-36
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { IonContent, IonPage, IonSplitPane, IonMenu, IonText, IonIcon, IonMenuButton, IonRouterOutlet, IonMenuToggle, isPlatform } from '@ionic/react';
22
//import { chevronForwardCircle, checkmarkCircle, filterOutline, listOutline, bicycle } from 'ionicons/icons';
3-
import React, { Component, useState, useEffect } from 'react';
3+
import React, { Component, useState, useEffect, useRef } from 'react';
44
import {withGetScreen} from 'react-getscreen'
55
import './Calendar.css'
66
import './Pages.css';
@@ -12,6 +12,8 @@ import { Query } from "../backend/src/Objects/Utils.ts";
1212
import T from "../backend/src/Objects/Task.ts";
1313
import CalendarPopover, { CalendarUnit } from './Components/CalendarPopover';
1414
import CalendarTasklistPopover from './Components/CalendarTasklistPopover';
15+
import { withShortcut, ShortcutProvider, ShortcutConsumer } from '../static/react-keybind'
16+
import keybindHandler from "./Components/KeybindHandler"
1517

1618
const autoBind = require('auto-bind/react');
1719

@@ -82,11 +84,26 @@ function CalPageBigOllendar(props) {
8284
let [isPopoverShown, setIsPopoverShown] = useState(false);
8385

8486
let [shownList, setShownList] = useState([]);
85-
86-
Array.prototype.max = function() {
87-
return Math.max.apply(null, this);
88-
};
8987

88+
//Array.prototype.max = function() { // THIS POLLUTES THE PROTOTYPE. IT BREAKS LOOPING THROUGH THE KEYS.
89+
// return Math.max.apply(null, this);
90+
//};
91+
92+
93+
const goRight = useRef(null);
94+
const goLeft = useRef(null);
95+
96+
const navigateLeft = () => {
97+
if (goLeft.current) {
98+
goLeft.current.click()
99+
}
100+
}
101+
102+
const navigateRight = () => {
103+
if (goRight.current) {
104+
goRight.current.click()
105+
}
106+
}
90107
let refresh = (async function() {
91108
let map = new Map();
92109
let names = new Map();
@@ -118,9 +135,10 @@ function CalPageBigOllendar(props) {
118135
let nameList = Array.from(names.values());
119136
let idList = Array.from(ids.values());
120137
if (values.length > 0) {
121-
let max = values.max();
138+
const max = (arr) => arr.reduce((a, b) => { return Math.max(a, b) })
139+
let val_max = max(values)
122140
let style = getComputedStyle(document.body);
123-
let hexes = values.map(e=>__util_calculate_gradient(style.getPropertyValue('--heatmap-darkest').trim().slice(1), style.getPropertyValue('--heatmap-lightest').trim().slice(1), e/max));
141+
let hexes = values.map(e=>__util_calculate_gradient(style.getPropertyValue('--heatmap-darkest').trim().slice(1), style.getPropertyValue('--heatmap-lightest').trim().slice(1), e/val_max));
124142
Array.from(map.keys()).forEach((e, i)=>{hm[e]={color:hexes[i], value:values[i], names:nameList[i], ids: idList[i]}});
125143
}
126144
setHeat(hm);
@@ -130,6 +148,29 @@ function CalPageBigOllendar(props) {
130148
refresh();
131149
},[dateSelected, refreshed]);
132150

151+
const { shortcut } = props
152+
useEffect(async () => {
153+
154+
const { shortcut } = props
155+
156+
// let ks = await keybindSource;
157+
if (props.allKeybinds !== null) {
158+
const toUnbind = keybindHandler(props, [
159+
[navigateRight, props.allKeybinds.Calendar['Next month'], 'Next month', 'Goes to the next month'],
160+
[navigateLeft, props.allKeybinds.Calendar['Previous month'], 'Previous month', 'Goes to the previous month'],
161+
])
162+
163+
return () => {
164+
const { shortcut } = props
165+
for (const i in toUnbind) { // this doesn't seem to be working?
166+
shortcut.unregisterShortcut(toUnbind[i])
167+
}
168+
shortcut.unregisterShortcut(["h", "l", "ArrowLeft", "ArrowRight"]) // so i'll do it manually..
169+
// TODO figure this one out
170+
}
171+
}
172+
}, [props.allKeybinds])
173+
133174
return (
134175
<div id="calendar-page-bigol-calendar-wrapper" style={{display: "inline-block", height: "85%", width: "95%", ...props.style}}>
135176
<CalendarTasklistPopover uid={props.uid} cm={props.cm} isShown={isPopoverShown} onDidDismiss={()=>setIsPopoverShown(false)} list={shownList} localizations={props.localizations} currentDate={dateSelected}/>
@@ -173,14 +214,18 @@ function CalPageBigOllendar(props) {
173214
)}
174215
</div>
175216
<div id="bigol-calendar-tools">
176-
<a className="fas fa-caret-left calendar-button" onClick={()=>{
217+
<a
218+
ref={goLeft}
219+
className="fas fa-caret-left calendar-button" onClick={()=>{
177220
let date = new Date(firstDayMonth.getFullYear(), firstDayMonth.getMonth()-1, 1);
178221
setDateSelected(date);
179222
if (props.onDateSelected)
180223
props.onDateSelected(date);
181224

182225
}}></a>
183-
<a className="fas fa-caret-right calendar-button" onClick={()=>{
226+
<a
227+
ref={goRight}
228+
className="fas fa-caret-right calendar-button" onClick={()=>{
184229
let date = new Date(firstDayMonth.getFullYear(), firstDayMonth.getMonth()+1, 1);
185230
setDateSelected(date);
186231
if (props.onDateSelected)
@@ -224,11 +269,13 @@ class Calendar extends Component {
224269
currentDate: (today), // new date
225270
taskList: [],
226271
popoverIsVisible: false,
272+
keybinds: [],
227273

228274
};
229275

230276
this.updatePrefix = this.random();
231277
this.repeater = React.createRef(); // what's my repeater? | i.. i dont know what this does...
278+
this.calPageBigRef = React.createRef();
232279

233280
// AutoBind!
234281
autoBind(this);
@@ -240,33 +287,13 @@ class Calendar extends Component {
240287
this.setState({showEdit: false});
241288
} // util func for hiding repeat
242289

243-
componentWillUnmount() {
244-
}
290+
componentWillUnmount() {}
291+
292+
async refresh() {}
245293

246-
async refresh() {
247-
// projectDB.map(proj=>buildSelectString(proj));
248-
249-
//let endDate = new Date(this.state.currentDate);
250-
//endDate.setHours(23,59,59,60);
251-
//let taskList = await this.props.engine.db.selectTasksInRange(this.props.uid, this.state.currentDate, endDate);
252-
253-
//refreshed++;
254-
255-
//this.setState({
256-
//possibleProjects: pPandT[0][0], // set the project stuff
257-
//possibleTags: pPandT[1][0], // set the tag stuff
258-
//possibleProjectsRev: pPandT[0][1], // set more projects stuff
259-
//possibleTagsRev: pPandT[1][1], // set more tags stuff
260-
//availability: avail, // set the avail
261-
//projectSelects: projectList, // set the project list
262-
//tagSelects: tagsList, // set the tag list
263-
//projectDB, // and the project db
264-
//taskList
265-
//}); // once we finish, set the state
266-
}
267294

268295
componentDidMount() {
269-
this.refresh()
296+
this.refresh()
270297
}
271298

272299
random() { return (((1+Math.random())*0x10000)|0).toString(16)+"-"+(((1+Math.random())*0x10000)|0).toString(16);}
@@ -327,7 +354,14 @@ class Calendar extends Component {
327354
this.setState({currentDate: d, taskList});
328355
}).bind(this)}/>
329356
else
330-
return <CalPageBigOllendar localizations={this.props.localizations} uid={this.props.uid} cm={this.props.cm} availability={this.state.availability}/>
357+
return <CalPageBigOllendar
358+
localizations={this.props.localizations}
359+
uid={this.props.uid}
360+
cm={this.props.cm}
361+
availability={this.state.availability}
362+
{...this.props}
363+
//ref={this.calPageBigRef} // not working
364+
/>
331365
})()}
332366
{(()=>{
333367
if (this.props.isMobile())
@@ -350,5 +384,4 @@ class Calendar extends Component {
350384
)
351385
}
352386
}
353-
export default withGetScreen(Calendar, {mobileLimit: 720, tabletLimit:768, shouldListenOnResize: true});
354-
387+
export default withShortcut(withGetScreen(Calendar, {mobileLimit: 720, tabletLimit:768, shouldListenOnResize: true}));

src/pages/Completed.css

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
.fetch-more { /* fetch more css */
3-
/*border: 1px solid red;*/
43
font-size: 12px;
54
color: var(--completed-fetch-more-text);
65
padding-left: 17px;

0 commit comments

Comments
 (0)