Implement signin flow
parent
2e352f383e
commit
0208302907
|
@ -40,7 +40,6 @@
|
|||
"react-native-svg": "^12.4.0",
|
||||
"react-native-url-polyfill": "^1.3.0",
|
||||
"react-native-web": "^0.17.7",
|
||||
"rn-fetch-blob": "^0.12.0",
|
||||
"ucans": "0.9.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -8,13 +8,15 @@ import * as storage from './lib/storage'
|
|||
import {ShellModel} from './models/shell'
|
||||
|
||||
const ROOT_STATE_STORAGE_KEY = 'root'
|
||||
const DEFAULT_SERVICE = 'http://localhost:2583'
|
||||
|
||||
export async function setupState() {
|
||||
let rootStore: RootStoreModel
|
||||
let data: any
|
||||
|
||||
const api = AdxApi.service(`http://localhost:2583`)
|
||||
await libapi.setup(api)
|
||||
libapi.doPolyfill()
|
||||
|
||||
const api = AdxApi.service(DEFAULT_SERVICE)
|
||||
rootStore = new RootStoreModel(api)
|
||||
try {
|
||||
data = (await storage.load(ROOT_STATE_STORAGE_KEY)) || {}
|
||||
|
@ -29,17 +31,7 @@ export async function setupState() {
|
|||
storage.save(ROOT_STATE_STORAGE_KEY, snapshot)
|
||||
})
|
||||
|
||||
// TODO
|
||||
rootStore.session.setAuthed(true)
|
||||
// if (env.authStore) {
|
||||
// const isAuthed = await auth.isAuthed(env.authStore)
|
||||
// rootStore.session.setAuthed(isAuthed)
|
||||
|
||||
// // handle redirect from auth
|
||||
// if (await auth.initialLoadUcanCheck(env.authStore)) {
|
||||
// rootStore.session.setAuthed(true)
|
||||
// }
|
||||
// }
|
||||
await rootStore.session.setup()
|
||||
await rootStore.me.load()
|
||||
console.log(rootStore.me)
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
* models live. They are made available to every model via dependency injection.
|
||||
*/
|
||||
|
||||
import RNFetchBlob from 'rn-fetch-blob'
|
||||
// import {ReactNativeStore} from './auth'
|
||||
import AdxApi, {ServiceClient} from '../../third-party/api'
|
||||
import AdxApi from '../../third-party/api'
|
||||
import {ServiceClient} from '../../third-party/api/src/index'
|
||||
import {AdxUri} from '../../third-party/uri'
|
||||
import * as storage from './storage'
|
||||
|
||||
export async function setup(adx: ServiceClient) {
|
||||
export function doPolyfill() {
|
||||
AdxApi.xrpc.fetch = fetchHandler
|
||||
}
|
||||
|
||||
|
@ -121,32 +121,31 @@ async function fetchHandler(
|
|||
reqHeaders: Record<string, string>,
|
||||
reqBody: any,
|
||||
): Promise<FetchHandlerResponse> {
|
||||
reqHeaders['Authorization'] = 'did:test:alice' // DEBUG
|
||||
|
||||
const reqMimeType = reqHeaders['Content-Type'] || reqHeaders['content-type']
|
||||
if (reqMimeType && reqMimeType.startsWith('application/json')) {
|
||||
reqBody = JSON.stringify(reqBody)
|
||||
}
|
||||
|
||||
const res = await RNFetchBlob.fetch(
|
||||
/** @ts-ignore method coersion, it's fine -prf */
|
||||
reqMethod,
|
||||
reqUri,
|
||||
reqHeaders,
|
||||
reqBody,
|
||||
)
|
||||
const res = await fetch(reqUri, {
|
||||
method: reqMethod,
|
||||
headers: reqHeaders,
|
||||
body: reqBody,
|
||||
})
|
||||
|
||||
const resStatus = res.info().status
|
||||
const resHeaders = (res.info().headers || {}) as Record<string, string>
|
||||
const resStatus = res.status
|
||||
const resHeaders: Record<string, string> = {}
|
||||
res.headers.forEach((value: string, key: string) => {
|
||||
resHeaders[key] = value
|
||||
})
|
||||
const resMimeType = resHeaders['Content-Type'] || resHeaders['content-type']
|
||||
let resBody
|
||||
if (resMimeType) {
|
||||
if (resMimeType.startsWith('application/json')) {
|
||||
resBody = res.json()
|
||||
resBody = await res.json()
|
||||
} else if (resMimeType.startsWith('text/')) {
|
||||
resBody = res.text()
|
||||
resBody = await res.text()
|
||||
} else {
|
||||
resBody = res.base64()
|
||||
throw new Error('TODO: non-textual response body')
|
||||
}
|
||||
}
|
||||
return {
|
||||
|
|
|
@ -14,9 +14,8 @@ export class MeModel {
|
|||
async load() {
|
||||
const sess = this.rootStore.session
|
||||
if (sess.isAuthed) {
|
||||
// TODO
|
||||
this.did = 'did:test:alice'
|
||||
this.name = 'alice.todo'
|
||||
this.did = sess.userdid || ''
|
||||
this.name = sess.username
|
||||
const profile = await this.rootStore.api.todo.social.getProfile({
|
||||
user: this.did,
|
||||
})
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import {makeAutoObservable} from 'mobx'
|
||||
import AdxApi from '../../third-party/api'
|
||||
import {ServiceClient} from '../../third-party/api/src/index'
|
||||
import type {ServiceClient} from '../../third-party/api/src/index'
|
||||
import {createContext, useContext} from 'react'
|
||||
import {isObj, hasProp} from '../lib/type-guards'
|
||||
import {SessionModel} from './session'
|
||||
|
@ -13,7 +13,7 @@ import {ShellModel} from './shell'
|
|||
import {MeModel} from './me'
|
||||
|
||||
export class RootStoreModel {
|
||||
session = new SessionModel()
|
||||
session = new SessionModel(this)
|
||||
nav = new NavigationModel()
|
||||
shell = new ShellModel()
|
||||
me = new MeModel(this)
|
||||
|
|
|
@ -1,109 +1,133 @@
|
|||
import {makeAutoObservable} from 'mobx'
|
||||
import AdxApi from '../../third-party/api'
|
||||
import {isObj, hasProp} from '../lib/type-guards'
|
||||
// import {UserConfig} from '../../api'
|
||||
// import * as auth from '../lib/auth'
|
||||
import {RootStoreModel} from './root-store'
|
||||
|
||||
interface SessionData {
|
||||
service: string
|
||||
token: string
|
||||
username: string
|
||||
userdid: string
|
||||
}
|
||||
|
||||
export class SessionModel {
|
||||
isAuthed = false
|
||||
data: SessionData | null = null
|
||||
|
||||
constructor() {
|
||||
constructor(public rootStore: RootStoreModel) {
|
||||
makeAutoObservable(this, {
|
||||
rootStore: false,
|
||||
serialize: false,
|
||||
hydrate: false,
|
||||
})
|
||||
}
|
||||
|
||||
get isAuthed() {
|
||||
return this.data !== null
|
||||
}
|
||||
|
||||
serialize(): unknown {
|
||||
return {
|
||||
isAuthed: this.isAuthed,
|
||||
}
|
||||
return this.data
|
||||
}
|
||||
|
||||
hydrate(v: unknown) {
|
||||
if (isObj(v)) {
|
||||
if (hasProp(v, 'isAuthed') && typeof v.isAuthed === 'boolean') {
|
||||
this.isAuthed = v.isAuthed
|
||||
const data: SessionData = {
|
||||
service: '',
|
||||
token: '',
|
||||
username: '',
|
||||
userdid: '',
|
||||
}
|
||||
if (hasProp(v, 'service') && typeof v.service === 'string') {
|
||||
data.service = v.service
|
||||
}
|
||||
if (hasProp(v, 'token') && typeof v.token === 'string') {
|
||||
data.token = v.token
|
||||
}
|
||||
if (hasProp(v, 'username') && typeof v.username === 'string') {
|
||||
data.username = v.username
|
||||
}
|
||||
if (hasProp(v, 'userdid') && typeof v.userdid === 'string') {
|
||||
data.userdid = v.userdid
|
||||
}
|
||||
if (data.service && data.token && data.username && data.userdid) {
|
||||
this.data = data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setAuthed(v: boolean) {
|
||||
this.isAuthed = v
|
||||
clear() {
|
||||
console.log('clear()')
|
||||
this.data = null
|
||||
}
|
||||
|
||||
setState(data: SessionData) {
|
||||
this.data = data
|
||||
}
|
||||
|
||||
private configureApi(): boolean {
|
||||
if (!this.data) {
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
const serviceUri = new URL(this.data.service)
|
||||
this.rootStore.api.xrpc.uri = serviceUri
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`Invalid service URL: ${this.data.service}. Resetting session.`,
|
||||
)
|
||||
console.error(e)
|
||||
this.clear()
|
||||
return false
|
||||
}
|
||||
|
||||
this.rootStore.api.setHeader('Authorization', `Bearer ${this.data.token}`)
|
||||
return true
|
||||
}
|
||||
|
||||
async setup(): Promise<void> {
|
||||
if (!this.configureApi()) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const sess = await this.rootStore.api.todo.adx.getSession({})
|
||||
if (sess.success && this.data && this.data.userdid === sess.data.did) {
|
||||
return // success
|
||||
}
|
||||
} catch (e: any) {}
|
||||
|
||||
this.clear() // invalid session cached
|
||||
}
|
||||
|
||||
async login({
|
||||
service,
|
||||
username,
|
||||
password,
|
||||
}: {
|
||||
service: string
|
||||
username: string
|
||||
password: string
|
||||
}) {
|
||||
const api = AdxApi.service(service)
|
||||
const res = await api.todo.adx.createSession({}, {username, password})
|
||||
if (res.data.jwt) {
|
||||
this.setState({
|
||||
service: service,
|
||||
token: res.data.jwt,
|
||||
username: res.data.name,
|
||||
userdid: res.data.did,
|
||||
})
|
||||
this.configureApi()
|
||||
}
|
||||
}
|
||||
|
||||
async logout() {
|
||||
if (this.isAuthed) {
|
||||
this.rootStore.api.todo.adx.deleteSession({}).catch((e: any) => {
|
||||
console.error('(Minor issue) Failed to delete session on the server', e)
|
||||
})
|
||||
}
|
||||
this.clear()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
/*login: flow(function* () {
|
||||
/*self.uiIsProcessing = true
|
||||
self.uiError = undefined
|
||||
try {
|
||||
if (!self.env.authStore) {
|
||||
throw new Error('Auth store not initialized')
|
||||
}
|
||||
const res = yield auth.requestAppUcan(self.env.authStore)
|
||||
self.isAuthed = res
|
||||
self.uiIsProcessing = false
|
||||
return res
|
||||
} catch (e: any) {
|
||||
console.error('Failed to request app ucan', e)
|
||||
self.uiError = e.toString()
|
||||
self.uiIsProcessing = false
|
||||
return false
|
||||
}
|
||||
}),
|
||||
logout: flow(function* () {
|
||||
self.uiIsProcessing = true
|
||||
self.uiError = undefined
|
||||
try {
|
||||
if (!self.env.authStore) {
|
||||
throw new Error('Auth store not initialized')
|
||||
}
|
||||
const res = yield auth.logout(self.env.authStore)
|
||||
self.isAuthed = false
|
||||
self.uiIsProcessing = false
|
||||
return res
|
||||
} catch (e: any) {
|
||||
console.error('Failed to log out', e)
|
||||
self.uiError = e.toString()
|
||||
self.uiIsProcessing = false
|
||||
return false
|
||||
}
|
||||
}),
|
||||
loadAccount: flow(function* () {
|
||||
self.uiIsProcessing = true
|
||||
self.uiError = undefined
|
||||
try {
|
||||
// const cfg = yield UserConfig.hydrate({
|
||||
// serverUrl: self.serverUrl,
|
||||
// secretKeyStr: self.secretKeyStr,
|
||||
// rootAuthToken: self.rootAuthToken,
|
||||
// })
|
||||
// self.env.api.setUserCfg(cfg)
|
||||
self.isAuthed = true
|
||||
self.uiIsProcessing = false
|
||||
return true
|
||||
} catch (e: any) {
|
||||
console.error('Failed to create test account', e)
|
||||
self.uiError = e.toString()
|
||||
self.uiIsProcessing = false
|
||||
return false
|
||||
}
|
||||
}),
|
||||
createTestAccount: flow(function* (_serverUrl: string) {
|
||||
self.uiIsProcessing = true
|
||||
self.uiError = undefined
|
||||
try {
|
||||
// const cfg = yield UserConfig.createTest(serverUrl)
|
||||
// const state = yield cfg.serialize()
|
||||
// self.serverUrl = state.serverUrl
|
||||
// self.secretKeyStr = state.secretKeyStr
|
||||
// self.rootAuthToken = state.rootAuthToken
|
||||
self.isAuthed = true
|
||||
// self.env.api.setUserCfg(cfg)
|
||||
} catch (e: any) {
|
||||
console.error('Failed to create test account', e)
|
||||
self.uiError = e.toString()
|
||||
}
|
||||
self.uiIsProcessing = false
|
||||
}),
|
||||
}))*/
|
||||
|
|
|
@ -10178,9 +10178,13 @@ var Client = class {
|
|||
};
|
||||
var ServiceClient = class {
|
||||
constructor(baseClient, serviceUri) {
|
||||
this.headers = {};
|
||||
this.baseClient = baseClient;
|
||||
this.uri = typeof serviceUri === "string" ? new URL(serviceUri) : serviceUri;
|
||||
}
|
||||
setHeader(key, value) {
|
||||
this.headers[key] = value;
|
||||
}
|
||||
async call(methodNsid, params, data, opts) {
|
||||
const schema = this.baseClient.schemas.get(methodNsid);
|
||||
if (!schema) {
|
||||
|
@ -10188,7 +10192,13 @@ var ServiceClient = class {
|
|||
}
|
||||
const httpMethod = getMethodSchemaHTTPMethod(schema);
|
||||
const httpUri = constructMethodCallUri(schema, this.uri, params);
|
||||
const httpHeaders = constructMethodCallHeaders(schema, data, opts);
|
||||
const httpHeaders = constructMethodCallHeaders(schema, data, {
|
||||
headers: {
|
||||
...this.headers,
|
||||
...opts?.headers
|
||||
},
|
||||
encoding: opts?.encoding
|
||||
});
|
||||
const res = await this.baseClient.fetch(
|
||||
httpUri,
|
||||
httpMethod,
|
||||
|
@ -10243,13 +10253,28 @@ var methodSchemas = [
|
|||
encoding: "application/json",
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["username", "did"],
|
||||
required: ["username", "did", "password"],
|
||||
properties: {
|
||||
username: {
|
||||
type: "string"
|
||||
},
|
||||
did: {
|
||||
type: "string"
|
||||
},
|
||||
password: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
output: {
|
||||
encoding: "application/json",
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["jwt"],
|
||||
properties: {
|
||||
jwt: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10262,12 +10287,31 @@ var methodSchemas = [
|
|||
description: "Create an authentication session.",
|
||||
parameters: {},
|
||||
input: {
|
||||
encoding: "",
|
||||
schema: {}
|
||||
encoding: "application/json",
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["username", "password"],
|
||||
properties: {
|
||||
username: {
|
||||
type: "string"
|
||||
},
|
||||
password: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
output: {
|
||||
encoding: "",
|
||||
schema: {}
|
||||
encoding: "application/json",
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["jwt"],
|
||||
properties: {
|
||||
jwt: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -10326,8 +10370,19 @@ var methodSchemas = [
|
|||
schema: {}
|
||||
},
|
||||
output: {
|
||||
encoding: "",
|
||||
schema: {}
|
||||
encoding: "application/json",
|
||||
schema: {
|
||||
type: "object",
|
||||
required: ["name", "did"],
|
||||
properties: {
|
||||
name: {
|
||||
type: "string"
|
||||
},
|
||||
did: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -11518,6 +11573,9 @@ var ServiceClient2 = class {
|
|||
this.xrpc = xrpcService;
|
||||
this.todo = new TodoNS(this);
|
||||
}
|
||||
setHeader(key, value) {
|
||||
this.xrpc.setHeader(key, value);
|
||||
}
|
||||
};
|
||||
var TodoNS = class {
|
||||
constructor(service) {
|
||||
|
@ -11686,31 +11744,33 @@ var BadgeRecord = class {
|
|||
});
|
||||
return res.data;
|
||||
}
|
||||
async create(params, record) {
|
||||
async create(params, record, headers) {
|
||||
record.$type = "todo.social.badge";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoCreateRecord",
|
||||
{ type: "todo.social.badge", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async put(params, record) {
|
||||
async put(params, record, headers) {
|
||||
record.$type = "todo.social.badge";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoPutRecord",
|
||||
{ type: "todo.social.badge", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async delete(params) {
|
||||
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
|
||||
type: "todo.social.badge",
|
||||
...params
|
||||
});
|
||||
async delete(params, headers) {
|
||||
await this._service.xrpc.call(
|
||||
"todo.adx.repoDeleteRecord",
|
||||
{ type: "todo.social.badge", ...params },
|
||||
void 0,
|
||||
{ headers }
|
||||
);
|
||||
}
|
||||
};
|
||||
var FollowRecord = class {
|
||||
|
@ -11731,31 +11791,33 @@ var FollowRecord = class {
|
|||
});
|
||||
return res.data;
|
||||
}
|
||||
async create(params, record) {
|
||||
async create(params, record, headers) {
|
||||
record.$type = "todo.social.follow";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoCreateRecord",
|
||||
{ type: "todo.social.follow", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async put(params, record) {
|
||||
async put(params, record, headers) {
|
||||
record.$type = "todo.social.follow";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoPutRecord",
|
||||
{ type: "todo.social.follow", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async delete(params) {
|
||||
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
|
||||
type: "todo.social.follow",
|
||||
...params
|
||||
});
|
||||
async delete(params, headers) {
|
||||
await this._service.xrpc.call(
|
||||
"todo.adx.repoDeleteRecord",
|
||||
{ type: "todo.social.follow", ...params },
|
||||
void 0,
|
||||
{ headers }
|
||||
);
|
||||
}
|
||||
};
|
||||
var LikeRecord = class {
|
||||
|
@ -11776,31 +11838,33 @@ var LikeRecord = class {
|
|||
});
|
||||
return res.data;
|
||||
}
|
||||
async create(params, record) {
|
||||
async create(params, record, headers) {
|
||||
record.$type = "todo.social.like";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoCreateRecord",
|
||||
{ type: "todo.social.like", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async put(params, record) {
|
||||
async put(params, record, headers) {
|
||||
record.$type = "todo.social.like";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoPutRecord",
|
||||
{ type: "todo.social.like", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async delete(params) {
|
||||
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
|
||||
type: "todo.social.like",
|
||||
...params
|
||||
});
|
||||
async delete(params, headers) {
|
||||
await this._service.xrpc.call(
|
||||
"todo.adx.repoDeleteRecord",
|
||||
{ type: "todo.social.like", ...params },
|
||||
void 0,
|
||||
{ headers }
|
||||
);
|
||||
}
|
||||
};
|
||||
var MediaEmbedRecord = class {
|
||||
|
@ -11821,31 +11885,33 @@ var MediaEmbedRecord = class {
|
|||
});
|
||||
return res.data;
|
||||
}
|
||||
async create(params, record) {
|
||||
async create(params, record, headers) {
|
||||
record.$type = "todo.social.mediaEmbed";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoCreateRecord",
|
||||
{ type: "todo.social.mediaEmbed", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async put(params, record) {
|
||||
async put(params, record, headers) {
|
||||
record.$type = "todo.social.mediaEmbed";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoPutRecord",
|
||||
{ type: "todo.social.mediaEmbed", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async delete(params) {
|
||||
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
|
||||
type: "todo.social.mediaEmbed",
|
||||
...params
|
||||
});
|
||||
async delete(params, headers) {
|
||||
await this._service.xrpc.call(
|
||||
"todo.adx.repoDeleteRecord",
|
||||
{ type: "todo.social.mediaEmbed", ...params },
|
||||
void 0,
|
||||
{ headers }
|
||||
);
|
||||
}
|
||||
};
|
||||
var PostRecord = class {
|
||||
|
@ -11866,31 +11932,33 @@ var PostRecord = class {
|
|||
});
|
||||
return res.data;
|
||||
}
|
||||
async create(params, record) {
|
||||
async create(params, record, headers) {
|
||||
record.$type = "todo.social.post";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoCreateRecord",
|
||||
{ type: "todo.social.post", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async put(params, record) {
|
||||
async put(params, record, headers) {
|
||||
record.$type = "todo.social.post";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoPutRecord",
|
||||
{ type: "todo.social.post", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async delete(params) {
|
||||
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
|
||||
type: "todo.social.post",
|
||||
...params
|
||||
});
|
||||
async delete(params, headers) {
|
||||
await this._service.xrpc.call(
|
||||
"todo.adx.repoDeleteRecord",
|
||||
{ type: "todo.social.post", ...params },
|
||||
void 0,
|
||||
{ headers }
|
||||
);
|
||||
}
|
||||
};
|
||||
var ProfileRecord = class {
|
||||
|
@ -11911,31 +11979,33 @@ var ProfileRecord = class {
|
|||
});
|
||||
return res.data;
|
||||
}
|
||||
async create(params, record) {
|
||||
async create(params, record, headers) {
|
||||
record.$type = "todo.social.profile";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoCreateRecord",
|
||||
{ type: "todo.social.profile", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async put(params, record) {
|
||||
async put(params, record, headers) {
|
||||
record.$type = "todo.social.profile";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoPutRecord",
|
||||
{ type: "todo.social.profile", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async delete(params) {
|
||||
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
|
||||
type: "todo.social.profile",
|
||||
...params
|
||||
});
|
||||
async delete(params, headers) {
|
||||
await this._service.xrpc.call(
|
||||
"todo.adx.repoDeleteRecord",
|
||||
{ type: "todo.social.profile", ...params },
|
||||
void 0,
|
||||
{ headers }
|
||||
);
|
||||
}
|
||||
};
|
||||
var RepostRecord = class {
|
||||
|
@ -11956,31 +12026,33 @@ var RepostRecord = class {
|
|||
});
|
||||
return res.data;
|
||||
}
|
||||
async create(params, record) {
|
||||
async create(params, record, headers) {
|
||||
record.$type = "todo.social.repost";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoCreateRecord",
|
||||
{ type: "todo.social.repost", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async put(params, record) {
|
||||
async put(params, record, headers) {
|
||||
record.$type = "todo.social.repost";
|
||||
const res = await this._service.xrpc.call(
|
||||
"todo.adx.repoPutRecord",
|
||||
{ type: "todo.social.repost", ...params },
|
||||
record,
|
||||
{ encoding: "application/json" }
|
||||
{ encoding: "application/json", headers }
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
async delete(params) {
|
||||
await this._service.xrpc.call("todo.adx.repoDeleteRecord", {
|
||||
type: "todo.social.repost",
|
||||
...params
|
||||
});
|
||||
async delete(params, headers) {
|
||||
await this._service.xrpc.call(
|
||||
"todo.adx.repoDeleteRecord",
|
||||
{ type: "todo.social.repost", ...params },
|
||||
void 0,
|
||||
{ headers }
|
||||
);
|
||||
}
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -43,6 +43,7 @@ export declare class ServiceClient {
|
|||
xrpc: XrpcServiceClient;
|
||||
todo: TodoNS;
|
||||
constructor(baseClient: Client, xrpcService: XrpcServiceClient);
|
||||
setHeader(key: string, value: string): void;
|
||||
}
|
||||
export declare class TodoNS {
|
||||
_service: ServiceClient;
|
||||
|
@ -103,13 +104,13 @@ export declare class BadgeRecord {
|
|||
uri: string;
|
||||
value: TodoSocialBadge.Record;
|
||||
}>;
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialBadge.Record): Promise<{
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialBadge.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialBadge.Record): Promise<{
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialBadge.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
|
||||
}
|
||||
export declare class FollowRecord {
|
||||
_service: ServiceClient;
|
||||
|
@ -124,13 +125,13 @@ export declare class FollowRecord {
|
|||
uri: string;
|
||||
value: TodoSocialFollow.Record;
|
||||
}>;
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialFollow.Record): Promise<{
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialFollow.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialFollow.Record): Promise<{
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialFollow.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
|
||||
}
|
||||
export declare class LikeRecord {
|
||||
_service: ServiceClient;
|
||||
|
@ -145,13 +146,13 @@ export declare class LikeRecord {
|
|||
uri: string;
|
||||
value: TodoSocialLike.Record;
|
||||
}>;
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialLike.Record): Promise<{
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialLike.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialLike.Record): Promise<{
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialLike.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
|
||||
}
|
||||
export declare class MediaEmbedRecord {
|
||||
_service: ServiceClient;
|
||||
|
@ -166,13 +167,13 @@ export declare class MediaEmbedRecord {
|
|||
uri: string;
|
||||
value: TodoSocialMediaEmbed.Record;
|
||||
}>;
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialMediaEmbed.Record): Promise<{
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialMediaEmbed.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialMediaEmbed.Record): Promise<{
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialMediaEmbed.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
|
||||
}
|
||||
export declare class PostRecord {
|
||||
_service: ServiceClient;
|
||||
|
@ -187,13 +188,13 @@ export declare class PostRecord {
|
|||
uri: string;
|
||||
value: TodoSocialPost.Record;
|
||||
}>;
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialPost.Record): Promise<{
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialPost.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialPost.Record): Promise<{
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialPost.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
|
||||
}
|
||||
export declare class ProfileRecord {
|
||||
_service: ServiceClient;
|
||||
|
@ -208,13 +209,13 @@ export declare class ProfileRecord {
|
|||
uri: string;
|
||||
value: TodoSocialProfile.Record;
|
||||
}>;
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialProfile.Record): Promise<{
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialProfile.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialProfile.Record): Promise<{
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialProfile.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
|
||||
}
|
||||
export declare class RepostRecord {
|
||||
_service: ServiceClient;
|
||||
|
@ -229,11 +230,11 @@ export declare class RepostRecord {
|
|||
uri: string;
|
||||
value: TodoSocialRepost.Record;
|
||||
}>;
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialRepost.Record): Promise<{
|
||||
create(params: Omit<TodoAdxRepoCreateRecord.QueryParams, 'type'>, record: TodoSocialRepost.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialRepost.Record): Promise<{
|
||||
put(params: Omit<TodoAdxRepoPutRecord.QueryParams, 'type'>, record: TodoSocialRepost.Record, headers?: Record<string, string>): Promise<{
|
||||
uri: string;
|
||||
}>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>): Promise<void>;
|
||||
delete(params: Omit<TodoAdxRepoDeleteRecord.QueryParams, 'type'>, headers?: Record<string, string>): Promise<void>;
|
||||
}
|
||||
|
|
|
@ -8,9 +8,14 @@ export interface CallOptions {
|
|||
export interface InputSchema {
|
||||
username: string;
|
||||
did: string;
|
||||
password: string;
|
||||
}
|
||||
export interface OutputSchema {
|
||||
jwt: string;
|
||||
}
|
||||
export interface Response {
|
||||
success: boolean;
|
||||
error: boolean;
|
||||
headers: Headers;
|
||||
data: OutputSchema;
|
||||
}
|
||||
|
|
|
@ -3,13 +3,14 @@ export interface QueryParams {
|
|||
}
|
||||
export interface CallOptions {
|
||||
headers?: Headers;
|
||||
encoding: '';
|
||||
encoding: 'application/json';
|
||||
}
|
||||
export interface InputSchema {
|
||||
[k: string]: unknown;
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
export interface OutputSchema {
|
||||
[k: string]: unknown;
|
||||
jwt: string;
|
||||
}
|
||||
export interface Response {
|
||||
success: boolean;
|
||||
|
|
|
@ -9,7 +9,8 @@ export interface InputSchema {
|
|||
[k: string]: unknown;
|
||||
}
|
||||
export interface OutputSchema {
|
||||
[k: string]: unknown;
|
||||
name: string;
|
||||
did: string;
|
||||
}
|
||||
export interface Response {
|
||||
success: boolean;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -102,24 +102,32 @@ export const s = StyleSheet.create({
|
|||
p2: {padding: 2},
|
||||
p5: {padding: 5},
|
||||
p10: {padding: 10},
|
||||
p20: {padding: 20},
|
||||
pr2: {paddingRight: 2},
|
||||
pr5: {paddingRight: 5},
|
||||
pr10: {paddingRight: 10},
|
||||
pr20: {paddingRight: 20},
|
||||
pl2: {paddingLeft: 2},
|
||||
pl5: {paddingLeft: 5},
|
||||
pl10: {paddingLeft: 10},
|
||||
pl20: {paddingLeft: 20},
|
||||
pt2: {paddingTop: 2},
|
||||
pt5: {paddingTop: 5},
|
||||
pt10: {paddingTop: 10},
|
||||
pt20: {paddingTop: 20},
|
||||
pb2: {paddingBottom: 2},
|
||||
pb5: {paddingBottom: 5},
|
||||
pb10: {paddingBottom: 10},
|
||||
pb20: {paddingBottom: 20},
|
||||
|
||||
// flex
|
||||
flexRow: {flexDirection: 'row'},
|
||||
flexCol: {flexDirection: 'column'},
|
||||
flex1: {flex: 1},
|
||||
|
||||
// position
|
||||
absolute: {position: 'absolute'},
|
||||
|
||||
// dimensions
|
||||
w100pct: {width: '100%'},
|
||||
h100pct: {height: '100%'},
|
||||
|
|
|
@ -3,8 +3,6 @@ import {IconProp} from '@fortawesome/fontawesome-svg-core'
|
|||
import {Home} from './screens/Home'
|
||||
import {Search} from './screens/Search'
|
||||
import {Notifications} from './screens/Notifications'
|
||||
import {Login} from './screens/Login'
|
||||
import {Signup} from './screens/Signup'
|
||||
import {NotFound} from './screens/NotFound'
|
||||
import {PostThread} from './screens/PostThread'
|
||||
import {PostLikedBy} from './screens/PostLikedBy'
|
||||
|
@ -47,8 +45,6 @@ export const routes: Route[] = [
|
|||
'retweet',
|
||||
r('/profile/(?<name>[^/]+)/post/(?<recordKey>[^/]+)/reposted-by'),
|
||||
],
|
||||
[Login, ['far', 'user'], r('/login')],
|
||||
[Signup, ['far', 'user'], r('/signup')],
|
||||
]
|
||||
|
||||
export function match(url: string): MatchResult {
|
||||
|
|
|
@ -1,27 +1,287 @@
|
|||
import React from 'react'
|
||||
import {Text, View} from 'react-native'
|
||||
import React, {useState} from 'react'
|
||||
import {
|
||||
ActivityIndicator,
|
||||
KeyboardAvoidingView,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TextInput,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
useWindowDimensions,
|
||||
} from 'react-native'
|
||||
import Svg, {Line} from 'react-native-svg'
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
// import {useStores} from '../../state'
|
||||
import {s, colors} from '../lib/styles'
|
||||
import {useStores} from '../../state'
|
||||
|
||||
enum ScreenState {
|
||||
SigninOrCreateAccount,
|
||||
Signin,
|
||||
}
|
||||
|
||||
const SigninOrCreateAccount = ({
|
||||
onPressSignin,
|
||||
}: {
|
||||
onPressSignin: () => void
|
||||
}) => {
|
||||
const winDim = useWindowDimensions()
|
||||
const halfWidth = winDim.width / 2
|
||||
return (
|
||||
<>
|
||||
<View style={styles.hero}>
|
||||
<Text style={styles.title}>Bluesky</Text>
|
||||
<Text style={styles.subtitle}>[ private beta ]</Text>
|
||||
</View>
|
||||
<View style={s.flex1}>
|
||||
<TouchableOpacity style={styles.btn}>
|
||||
<Text style={styles.btnLabel}>Create a new account</Text>
|
||||
</TouchableOpacity>
|
||||
<View style={styles.or}>
|
||||
<Svg height="1" width={winDim.width} style={styles.orLine}>
|
||||
<Line
|
||||
x1="30"
|
||||
y1="0"
|
||||
x2={halfWidth - 20}
|
||||
y2="0"
|
||||
stroke="white"
|
||||
strokeWidth="1"
|
||||
/>
|
||||
<Line
|
||||
x1={halfWidth + 20}
|
||||
y1="0"
|
||||
x2={winDim.width - 30}
|
||||
y2="0"
|
||||
stroke="white"
|
||||
strokeWidth="1"
|
||||
/>
|
||||
</Svg>
|
||||
<Text style={styles.orLabel}>or</Text>
|
||||
</View>
|
||||
<TouchableOpacity style={styles.btn} onPress={onPressSignin}>
|
||||
<Text style={styles.btnLabel}>Sign in</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
const Signin = ({onPressBack}: {onPressBack: () => void}) => {
|
||||
const store = useStores()
|
||||
const [isProcessing, setIsProcessing] = useState<boolean>(false)
|
||||
const [error, setError] = useState<string>('')
|
||||
const [username, setUsername] = useState<string>('')
|
||||
const [password, setPassword] = useState<string>('')
|
||||
|
||||
const onPressNext = async () => {
|
||||
setError('')
|
||||
setIsProcessing(true)
|
||||
try {
|
||||
await store.session.login({
|
||||
service: 'http://localhost:2583/',
|
||||
username,
|
||||
password,
|
||||
})
|
||||
} catch (e: any) {
|
||||
const errMsg = e.toString()
|
||||
console.log(e)
|
||||
if (errMsg.includes('Authentication Required')) {
|
||||
setError('Invalid username or password')
|
||||
} else if (errMsg.includes('Network request failed')) {
|
||||
setError(
|
||||
'Unable to contact your service. Please check your Internet connection.',
|
||||
)
|
||||
} else {
|
||||
setError(errMsg.replace(/^Error:/, ''))
|
||||
}
|
||||
} finally {
|
||||
setIsProcessing(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<KeyboardAvoidingView behavior="padding" style={{flex: 1}}>
|
||||
<View style={styles.hero}>
|
||||
<Text style={styles.title}>Bluesky</Text>
|
||||
<Text style={styles.subtitle}>[ private beta ]</Text>
|
||||
</View>
|
||||
<View style={s.flex1}>
|
||||
<View style={styles.group}>
|
||||
<View style={styles.groupTitle}>
|
||||
<Text style={[s.white, s.f18]}>Sign in</Text>
|
||||
</View>
|
||||
<View style={styles.groupContent}>
|
||||
<View style={[s.mb5]}>
|
||||
<TextInput
|
||||
style={styles.textInput}
|
||||
placeholder="Email or username"
|
||||
autoCapitalize="none"
|
||||
autoFocus
|
||||
value={username}
|
||||
onChangeText={setUsername}
|
||||
editable={!isProcessing}
|
||||
/>
|
||||
</View>
|
||||
<View style={[s.mb5]}>
|
||||
<TextInput
|
||||
style={styles.textInput}
|
||||
placeholder="Password"
|
||||
autoCapitalize="none"
|
||||
secureTextEntry
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
editable={!isProcessing}
|
||||
/>
|
||||
</View>
|
||||
{error ? (
|
||||
<View style={styles.error}>
|
||||
<View style={styles.errorIcon}>
|
||||
<FontAwesomeIcon
|
||||
icon="exclamation"
|
||||
style={s.white}
|
||||
size={10}
|
||||
/>
|
||||
</View>
|
||||
<View style={s.flex1}>
|
||||
<Text style={[s.white, s.bold]}>{error}</Text>
|
||||
</View>
|
||||
</View>
|
||||
) : undefined}
|
||||
</View>
|
||||
</View>
|
||||
<View style={[s.flexRow, s.pl20, s.pr20]}>
|
||||
<TouchableOpacity onPress={onPressBack}>
|
||||
<Text style={[s.white, s.f18, s.bold, s.pl5]}>Back</Text>
|
||||
</TouchableOpacity>
|
||||
<View style={s.flex1} />
|
||||
<TouchableOpacity onPress={onPressNext}>
|
||||
{isProcessing ? (
|
||||
<ActivityIndicator color="#fff" />
|
||||
) : (
|
||||
<Text style={[s.white, s.f18, s.bold, s.pr5]}>Next</Text>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
)
|
||||
}
|
||||
|
||||
export const Login = observer(
|
||||
(/*{navigation}: RootTabsScreenProps<'Login'>*/) => {
|
||||
// const store = useStores()
|
||||
const [screenState, setScreenState] = useState<ScreenState>(
|
||||
ScreenState.SigninOrCreateAccount,
|
||||
)
|
||||
const onPressSignin = () => {
|
||||
setScreenState(ScreenState.Signin)
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={{justifyContent: 'center', alignItems: 'center'}}>
|
||||
<Text style={{fontSize: 20, fontWeight: 'bold'}}>Sign In</Text>
|
||||
{/*store.session.uiError && <Text>{store.session.uiError}</Text>}
|
||||
{!store.session.uiIsProcessing ? (
|
||||
<>
|
||||
<Button title="Login" onPress={() => store.session.login()} />
|
||||
<Button
|
||||
title="Sign Up"
|
||||
onPress={() => navigation.navigate('Signup')}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<ActivityIndicator />
|
||||
)*/}
|
||||
<View style={styles.outer}>
|
||||
{screenState === ScreenState.SigninOrCreateAccount ? (
|
||||
<SigninOrCreateAccount onPressSignin={onPressSignin} />
|
||||
) : undefined}
|
||||
{screenState === ScreenState.Signin ? (
|
||||
<Signin
|
||||
onPressBack={() =>
|
||||
setScreenState(ScreenState.SigninOrCreateAccount)
|
||||
}
|
||||
/>
|
||||
) : undefined}
|
||||
</View>
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
outer: {
|
||||
flex: 1,
|
||||
},
|
||||
hero: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
},
|
||||
title: {
|
||||
textAlign: 'center',
|
||||
color: colors.white,
|
||||
fontSize: 68,
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
subtitle: {
|
||||
textAlign: 'center',
|
||||
color: colors.white,
|
||||
fontSize: 18,
|
||||
},
|
||||
btn: {
|
||||
borderWidth: 1,
|
||||
borderColor: colors.white,
|
||||
borderRadius: 10,
|
||||
paddingVertical: 16,
|
||||
marginBottom: 20,
|
||||
marginHorizontal: 20,
|
||||
},
|
||||
btnLabel: {
|
||||
textAlign: 'center',
|
||||
color: colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
or: {
|
||||
marginBottom: 20,
|
||||
},
|
||||
orLine: {
|
||||
position: 'absolute',
|
||||
top: 10,
|
||||
},
|
||||
orLabel: {
|
||||
textAlign: 'center',
|
||||
color: colors.white,
|
||||
fontSize: 16,
|
||||
},
|
||||
group: {
|
||||
borderWidth: 1,
|
||||
borderColor: colors.white,
|
||||
borderRadius: 10,
|
||||
marginBottom: 20,
|
||||
marginHorizontal: 20,
|
||||
},
|
||||
groupTitle: {
|
||||
paddingVertical: 8,
|
||||
paddingHorizontal: 12,
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: colors.blue1,
|
||||
},
|
||||
groupContent: {
|
||||
paddingVertical: 8,
|
||||
paddingHorizontal: 12,
|
||||
},
|
||||
textInput: {
|
||||
width: '100%',
|
||||
backgroundColor: colors.white,
|
||||
paddingHorizontal: 8,
|
||||
paddingVertical: 8,
|
||||
borderRadius: 4,
|
||||
fontSize: 18,
|
||||
},
|
||||
error: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
marginTop: 5,
|
||||
backgroundColor: colors.purple3,
|
||||
paddingHorizontal: 8,
|
||||
paddingVertical: 5,
|
||||
borderRadius: 4,
|
||||
},
|
||||
errorIcon: {
|
||||
borderWidth: 1,
|
||||
borderColor: colors.white,
|
||||
color: colors.white,
|
||||
borderRadius: 30,
|
||||
width: 16,
|
||||
height: 16,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
marginRight: 5,
|
||||
},
|
||||
})
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
import React from 'react'
|
||||
import {Text, View} from 'react-native'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
// import {useStores} from '../../state'
|
||||
|
||||
export const Signup = observer(
|
||||
(/*{navigation}: RootTabsScreenProps<'Signup'>*/) => {
|
||||
// const store = useStores()
|
||||
return (
|
||||
<View style={{justifyContent: 'center', alignItems: 'center'}}>
|
||||
<Text style={{fontSize: 20, fontWeight: 'bold'}}>Create Account</Text>
|
||||
{/*store.session.uiError ?? <Text>{store.session.uiError}</Text>}
|
||||
{!store.session.uiIsProcessing ? (
|
||||
<>
|
||||
<Button
|
||||
title="Create new account"
|
||||
onPress={() => store.session.login()}
|
||||
/>
|
||||
<Button
|
||||
title="Log in to an existing account"
|
||||
onPress={() => navigation.navigate('Login')}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<ActivityIndicator />
|
||||
)*/}
|
||||
</View>
|
||||
)
|
||||
},
|
||||
)
|
|
@ -1,4 +1,4 @@
|
|||
import React, {useState, useRef, useEffect} from 'react'
|
||||
import React, {useState, useEffect} from 'react'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {
|
||||
useWindowDimensions,
|
||||
|
@ -11,6 +11,8 @@ import {
|
|||
View,
|
||||
} from 'react-native'
|
||||
import {ScreenContainer, Screen} from 'react-native-screens'
|
||||
import LinearGradient from 'react-native-linear-gradient'
|
||||
// import Svg, {Polygon} from 'react-native-svg'
|
||||
import {GestureDetector, Gesture} from 'react-native-gesture-handler'
|
||||
import Animated, {
|
||||
useSharedValue,
|
||||
|
@ -25,12 +27,13 @@ import {useStores} from '../../../state'
|
|||
import {NavigationModel} from '../../../state/models/navigation'
|
||||
import {TabsSelectorModel} from '../../../state/models/shell'
|
||||
import {match, MatchResult} from '../../routes'
|
||||
import {Login} from '../../screens/Login'
|
||||
import {Modal} from '../../com/modals/Modal'
|
||||
import {LocationNavigator} from './location-navigator'
|
||||
import {createBackMenu, createForwardMenu} from './history-menu'
|
||||
import {createAccountsMenu} from './accounts-menu'
|
||||
import {createLocationMenu} from './location-menu'
|
||||
import {s, colors} from '../../lib/styles'
|
||||
import {s, colors, gradients} from '../../lib/styles'
|
||||
import {AVIS} from '../../lib/assets'
|
||||
|
||||
const locationIconNeedsNudgeUp = (icon: IconProp) => icon === 'house'
|
||||
|
@ -164,6 +167,53 @@ export const MobileShell: React.FC = observer(() => {
|
|||
opacity: interpolate(swipeGestureInterp.value, [0, 1.0], [0.6, 0.0]),
|
||||
}))
|
||||
|
||||
console.log('authed?', store.session.isAuthed)
|
||||
if (!store.session.isAuthed) {
|
||||
return (
|
||||
<LinearGradient
|
||||
colors={['#007CFF', '#00BCFF']}
|
||||
start={{x: 0, y: 0.8}}
|
||||
end={{x: 1, y: 1}}
|
||||
style={styles.outerContainer}>
|
||||
{
|
||||
undefined /* TODO want this? <Svg height={winDim.height} width={winDim.width} style={s.absolute}>
|
||||
<Polygon
|
||||
points={`
|
||||
${winDim.width},0
|
||||
${winDim.width - 250},0
|
||||
0,${winDim.height - 140}
|
||||
0,${winDim.height}
|
||||
${winDim.width},${winDim.height}`}
|
||||
fill="#fff"
|
||||
fillOpacity="0.04"
|
||||
/>
|
||||
<Polygon
|
||||
points={`
|
||||
${winDim.width},0
|
||||
${winDim.width - 100},0
|
||||
0,${winDim.height - 60}
|
||||
0,${winDim.height}
|
||||
${winDim.width},${winDim.height}`}
|
||||
fill="#fff"
|
||||
fillOpacity="0.04"
|
||||
/>
|
||||
<Polygon
|
||||
points={`
|
||||
${winDim.width},100
|
||||
0,${winDim.height}
|
||||
${winDim.width},${winDim.height}`}
|
||||
fill="#fff"
|
||||
fillOpacity="0.04"
|
||||
/>
|
||||
</Svg>*/
|
||||
}
|
||||
<SafeAreaView style={styles.innerContainer}>
|
||||
<Login />
|
||||
</SafeAreaView>
|
||||
</LinearGradient>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.outerContainer}>
|
||||
<View style={styles.topBar}>
|
||||
|
|
25
yarn.lock
25
yarn.lock
|
@ -3640,11 +3640,6 @@ balanced-match@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
|
||||
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
|
||||
|
||||
base-64@0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/base-64/-/base-64-0.1.0.tgz#780a99c84e7d600260361511c4877613bf24f6bb"
|
||||
integrity sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==
|
||||
|
||||
base64-js@^1.1.2, base64-js@^1.3.1, base64-js@^1.5.1:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
|
||||
|
@ -6110,18 +6105,6 @@ glob-to-regexp@^0.4.1:
|
|||
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e"
|
||||
integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==
|
||||
|
||||
glob@7.0.6:
|
||||
version "7.0.6"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.6.tgz#211bafaf49e525b8cd93260d14ab136152b3f57a"
|
||||
integrity sha512-f8c0rE8JiCxpa52kWPAOa3ZaYEnzofDzCQLCn3Vdk0Z5OVLq3BsRFJI4S4ykpeVW6QMGBUkMeUpoEgWnMTnw5Q==
|
||||
dependencies:
|
||||
fs.realpath "^1.0.0"
|
||||
inflight "^1.0.4"
|
||||
inherits "2"
|
||||
minimatch "^3.0.2"
|
||||
once "^1.3.0"
|
||||
path-is-absolute "^1.0.0"
|
||||
|
||||
glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6:
|
||||
version "7.2.3"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
|
||||
|
@ -10780,14 +10763,6 @@ rimraf@~2.6.2:
|
|||
dependencies:
|
||||
glob "^7.1.3"
|
||||
|
||||
rn-fetch-blob@^0.12.0:
|
||||
version "0.12.0"
|
||||
resolved "https://registry.yarnpkg.com/rn-fetch-blob/-/rn-fetch-blob-0.12.0.tgz#ec610d2f9b3f1065556b58ab9c106eeb256f3cba"
|
||||
integrity sha512-+QnR7AsJ14zqpVVUbzbtAjq0iI8c9tCg49tIoKO2ezjzRunN7YL6zFSFSWZm6d+mE/l9r+OeDM3jmb2tBb2WbA==
|
||||
dependencies:
|
||||
base-64 "0.1.0"
|
||||
glob "7.0.6"
|
||||
|
||||
rollup-plugin-terser@^7.0.0:
|
||||
version "7.0.2"
|
||||
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d"
|
||||
|
|
Loading…
Reference in New Issue