-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic support for dark mode & update Swift schema. #1565
base: channel/major-13
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "realm-studio", | ||
"productName": "Realm Studio", | ||
"productName": "Cosmic Realms", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this. |
||
"version": "13.0.2", | ||
"description": "A tool for everything Realm!", | ||
"author": { | ||
|
@@ -12,7 +12,7 @@ | |
"license": "Apache-2.0", | ||
"main": "./build/main.bundle.js", | ||
"build": { | ||
"appId": "com.mongodb.realm-studio", | ||
"appId": "foundation.wabi.realm-studio", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this. |
||
"directories": { | ||
"buildResources": "./resources" | ||
}, | ||
|
@@ -72,7 +72,7 @@ | |
}, | ||
"protocols": [ | ||
{ | ||
"name": "Realm Studio", | ||
"name": "Cosmic Realms", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this. |
||
"schemes": [ | ||
"x-realm-cloud", | ||
"x-realm-studio" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ const fs = require("fs"); | |
const path = require("path"); | ||
const { notarize } = require("electron-notarize"); | ||
|
||
const appBundleId = "com.mongodb.realm-studio"; | ||
const ascProvider = "QX5CR2FTN2"; // Apple: short team name | ||
const appBundleId = "foundation.wabi.realm-studio"; | ||
const ascProvider = "UQ9J5QT9DL"; // Apple: short team name | ||
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this. |
||
|
||
exports.notarizeMacApp = async (context) => { | ||
const { APPLE_ID_APP_USERNAME, APPLE_ID_APP_PASSWORD } = process.env; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,7 @@ export const getDefaultMenuTemplate = ( | |
store.toggleShowInternalFeatures(); | ||
updateMenu(); | ||
}, | ||
}, | ||
}, | ||
{ role: 'reload', visible: showInternalFeatures }, | ||
{ role: 'toggleDevTools', visible: showInternalFeatures }, | ||
{ type: 'separator', visible: showInternalFeatures }, | ||
|
@@ -105,6 +105,17 @@ export const getDefaultMenuTemplate = ( | |
}, | ||
}, | ||
{ type: 'separator' }, | ||
{ | ||
label: "Enable Dark Mode", | ||
id: 'toggle-appearance', | ||
type: 'checkbox', | ||
checked: store.shouldShowDarkMode(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer if this was pulled from the system preferences. Would be great if there was a way to say "use my preferences" and then be able to provide an override. |
||
click: () => { | ||
store.toggleDarkMode(); | ||
updateMenu(); | ||
}, | ||
}, | ||
{ type: 'separator' }, | ||
{ role: 'resetZoom' }, | ||
{ role: 'zoomIn' }, | ||
{ role: 'zoomOut' }, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,7 +216,7 @@ export class Updater { | |
dialog.showMessageBoxSync({ | ||
type: 'info', | ||
message: `A new version of ${appName} is downloaded!`, | ||
detail: `${appName} ${lastestVersion} is downloaded.\nClick "Ok" to quit and restart Realm Studio.`, | ||
detail: `${appName} ${lastestVersion} is downloaded.\nClick "Ok" to quit and restart Cosmic Realms.`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this. |
||
buttons: ['Ok'], | ||
defaultId: 0, | ||
}) === 0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,37 +38,35 @@ export default class SwiftSchemaExporter extends SchemaExporter { | |
} | ||
|
||
public makeSchema(schema: Realm.ObjectSchema) { | ||
this.appendLine(`class ${schema.name}: Object {`); | ||
this.appendLine(`class ${schema.name}: Object\n{\n`); | ||
|
||
// Primary key | ||
if (schema.primaryKey) { | ||
this.appendLine(' @Persisted(primaryKey: true)'); | ||
this.appendLine(' var ' + schema.primaryKey + ': ObjectId\n'); | ||
} | ||
|
||
// Properties | ||
const indexedProp: INamedObjectSchemaProperty[] = []; | ||
filteredProperties(schema.properties).forEach(prop => { | ||
this.appendLine(' ' + this.propertyLine(prop)); | ||
this.appendLine(' ' + this.propertyLine(prop)); | ||
if (prop.indexed && prop.name !== schema.primaryKey) { | ||
indexedProp.push(prop); | ||
} | ||
}); | ||
|
||
// Primary key | ||
if (schema.primaryKey) { | ||
this.appendLine(''); | ||
this.appendLine(' override static func primaryKey() -> String? {'); | ||
this.appendLine(' return "' + schema.primaryKey + '"'); | ||
this.appendLine(' }'); | ||
} | ||
|
||
// Indexed Properties | ||
if (indexedProp.length > 0) { | ||
this.appendLine(''); | ||
this.appendLine( | ||
' override static func indexedProperties() -> [String] {', | ||
' override static func indexedProperties() -> [String] {', | ||
); | ||
|
||
const indexedPropsStr = indexedProp | ||
.map(prop => `"${prop.name}"`) | ||
.join(', '); | ||
this.appendLine(` return [${indexedPropsStr}]`); | ||
this.appendLine(' }'); | ||
this.appendLine(` return [${indexedPropsStr}]`); | ||
this.appendLine(' }'); | ||
} | ||
|
||
// End class | ||
|
@@ -109,7 +107,7 @@ export default class SwiftSchemaExporter extends SchemaExporter { | |
if (prop.optional) { | ||
strArray += '?'; | ||
} | ||
return `let ${prop.name} = List<${strArray}>()`; | ||
return `@Persisted\n var ${prop.name} = [${strArray}]()\n`; | ||
} | ||
|
||
const propType = propertyType(prop.type); | ||
|
@@ -121,41 +119,31 @@ export default class SwiftSchemaExporter extends SchemaExporter { | |
case 'int': | ||
case 'float': | ||
case 'double': | ||
return `let ${prop.name} = RealmOptional<${propType}>()`; | ||
|
||
case 'string': | ||
case 'data': | ||
case 'date': | ||
case 'objectId': | ||
case 'decimal128': | ||
return `@objc dynamic var ${prop.name}: ${propType}? = nil`; | ||
|
||
case 'object': | ||
return `@objc dynamic var ${prop.name}: ${prop.objectType}?`; | ||
return `@Persisted\n var ${prop.name}: ${propType}?\n`; | ||
default: | ||
return `ERROR - unknown type '${prop.type}'`; | ||
} | ||
} | ||
|
||
// Non Optional types | ||
const str = `@objc dynamic var ${prop.name}: ${propType} = `; | ||
const str = `@Persisted\n var ${prop.name}: ${propType}\n`; | ||
switch (prop.type) { | ||
case 'bool': | ||
return str + 'false'; | ||
case 'int': | ||
case 'float': | ||
case 'double': | ||
return str + '0'; | ||
case 'string': | ||
return str + '""'; | ||
case 'data': | ||
return str + 'Data()'; | ||
case 'date': | ||
return str + 'Date()'; | ||
case 'objectId': | ||
return str + 'ObjectId()'; | ||
case 'decimal128': | ||
return str + 'Decimal128()'; | ||
return str; | ||
case 'object': | ||
return 'Objects must always be optional. Something is not right in this model!'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer if the changes to the swift schema export went into a separate PR. |
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,17 +27,20 @@ import { WindowType } from './windows/WindowOptions'; | |
type RemovalCallback = () => void; | ||
|
||
const KEY_SHOW_SYSTEM_CLASSES = 'browser.show-system-classes'; | ||
const KEY_SHOW_DARK_MODE = 'browser.show-dark-mode'; | ||
const KEY_SHOW_INTERNAL_FEATURES = 'general.show-internal-features'; | ||
const KEY_WINDOW_OPTIONS = 'window-options'; | ||
|
||
type StudioStore = { | ||
[KEY_SHOW_SYSTEM_CLASSES]: boolean; | ||
[KEY_SHOW_DARK_MODE]: boolean; | ||
[KEY_SHOW_INTERNAL_FEATURES]: boolean; | ||
[key: string]: unknown; | ||
}; | ||
|
||
class RealmStudioStore { | ||
public readonly KEY_SHOW_SYSTEM_CLASSES = KEY_SHOW_SYSTEM_CLASSES; | ||
public readonly KEY_SHOW_DARK_MODE = KEY_SHOW_DARK_MODE; | ||
public readonly KEY_SHOW_INTERNAL_FEATURES = KEY_SHOW_INTERNAL_FEATURES; | ||
public readonly KEY_WINDOW_OPTIONS = KEY_WINDOW_OPTIONS; | ||
|
||
|
@@ -48,6 +51,12 @@ class RealmStudioStore { | |
this.store.set(KEY_SHOW_SYSTEM_CLASSES, !currentValue); | ||
} | ||
|
||
public toggleDarkMode() | ||
{ | ||
const currentValue = this.shouldShowInternalFeatures(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line seems incorrect. |
||
this.store.set(KEY_SHOW_DARK_MODE, !currentValue); | ||
} | ||
|
||
public toggleShowInternalFeatures() { | ||
const currentValue = this.shouldShowInternalFeatures(); | ||
this.store.set(KEY_SHOW_INTERNAL_FEATURES, !currentValue); | ||
|
@@ -57,6 +66,10 @@ class RealmStudioStore { | |
return this.store.get(KEY_SHOW_SYSTEM_CLASSES, false); | ||
} | ||
|
||
public shouldShowDarkMode(): boolean { | ||
return this.store.get(KEY_SHOW_DARK_MODE, false); | ||
} | ||
|
||
public shouldShowInternalFeatures(): boolean { | ||
return this.store.get(KEY_SHOW_INTERNAL_FEATURES, false); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ electron.app.once('ready', () => { | |
message: `Writing to the ready signal: ${p}`, | ||
}); | ||
*/ | ||
fs.writeFileSync(p, 'Hello from a future Realm Studio!', { | ||
fs.writeFileSync(p, 'Hello from a future Cosmic Realms!', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this. |
||
encoding: 'utf8', | ||
}); | ||
// Exit ... | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,8 @@ | |
}, | ||
"license": "Apache-2.0", | ||
"build": { | ||
"appId": "com.mongodb.realm-studio", | ||
"productName": "Realm Studio", | ||
"appId": "foundation.wabi.realm-studio", | ||
"productName": "Cosmic Realms", | ||
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this. |
||
"mac": { | ||
"target": [ | ||
"zip" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this.