Commit cfa701991cd5e09c587fca0fed40801f3bb5dcf2
dx: rename SyncTab to ConnectionsTab
Andre Staltz committed on 8/22/2018, 7:55:58 PMParent: 9c43dc489a4000eaa7eb961144517d9fe4fa9c3f
Files changed
e2e/central.js | ||
---|---|---|
@@ -36,20 +36,20 @@ | ||
36 | 36 | ), |
37 | 37 | 'I see Public tab button', |
38 | 38 | ); |
39 | 39 | |
40 | - // Sync tab | |
41 | - const syncTabButton = await driver.elementByAndroidUIAutomator( | |
42 | - 'new UiSelector().descriptionContains("Sync Tab Button")', | |
40 | + // Connections tab | |
41 | + const connectionsTabButton = await driver.elementByAndroidUIAutomator( | |
42 | + 'new UiSelector().descriptionContains("Connections Tab Button")', | |
43 | 43 | ); |
44 | - t.ok(syncTabButton, 'I see Sync Tab button'); | |
45 | - await syncTabButton.tap(); | |
44 | + t.ok(connectionsTabButton, 'I see the Connections Tab button'); | |
45 | + await connectionsTabButton.tap(); | |
46 | 46 | t.pass('I tap it'); |
47 | 47 | t.ok( |
48 | 48 | await driver.elementByAndroidUIAutomator( |
49 | 49 | 'new UiSelector().textContains("Friends around you")', |
50 | 50 | ), |
51 | - 'I see Sync tab body', | |
51 | + 'I see Connections tab body', | |
52 | 52 | ); |
53 | 53 | |
54 | 54 | const lanHelpButton = await driver.elementByAndroidUIAutomator( |
55 | 55 | 'new UiSelector().descriptionContains("Show LAN Help")', |
src/app/screens/central/index.ts | ||
---|---|---|
@@ -26,12 +26,20 @@ | ||
26 | 26 | import {Toast, Duration as ToastDuration} from '../../drivers/toast'; |
27 | 27 | import {Command, NavSource} from 'cycle-native-navigation'; |
28 | 28 | import {SSBSource, Req} from '../../drivers/ssb'; |
29 | 29 | import {publicTab, Sinks as PublicTabSinks} from './public-tab/index'; |
30 | -import {syncTab, Sinks as SyncTabSinks} from './sync-tab/index'; | |
30 | +import { | |
31 | + connectionsTab, | |
32 | + Sinks as ConnectionsTabSinks, | |
33 | +} from './connections-tab/index'; | |
31 | 34 | import {topBar, Sinks as TBSinks} from './top-bar'; |
32 | 35 | import intent from './intent'; |
33 | -import model, {State, publicTabLens, syncTabLens, topBarLens} from './model'; | |
36 | +import model, { | |
37 | + State, | |
38 | + publicTabLens, | |
39 | + connectionsTabLens, | |
40 | + topBarLens, | |
41 | +} from './model'; | |
34 | 42 | import view from './view'; |
35 | 43 | import navigation from './navigation'; |
36 | 44 | import sampleCombine from 'xstream/extra/sampleCombine'; |
37 | 45 | |
@@ -80,28 +88,28 @@ | ||
80 | 88 | onion: publicTabLens, |
81 | 89 | '*': 'publicTab', |
82 | 90 | })({...sources, scrollToTop: scrollToTop$}); |
83 | 91 | |
84 | - const syncTabSinks: SyncTabSinks = isolate(syncTab, { | |
85 | - onion: syncTabLens, | |
86 | - '*': 'syncTab', | |
92 | + const connectionsTabSinks: ConnectionsTabSinks = isolate(connectionsTab, { | |
93 | + onion: connectionsTabLens, | |
94 | + '*': 'connectionsTab', | |
87 | 95 | })(sources); |
88 | 96 | |
89 | 97 | const command$ = navigation( |
90 | 98 | {openDrawer$: topBarSinks.menuPress}, |
91 | - xs.merge(publicTabSinks.navigation, syncTabSinks.navigation), | |
99 | + xs.merge(publicTabSinks.navigation, connectionsTabSinks.navigation), | |
92 | 100 | ); |
93 | 101 | const centralReducer$ = model(actions, sources.ssb); |
94 | 102 | const reducer$ = xs.merge( |
95 | 103 | centralReducer$, |
96 | 104 | publicTabSinks.onion, |
97 | - syncTabSinks.onion, | |
105 | + connectionsTabSinks.onion, | |
98 | 106 | ) as Stream<Reducer<State>>; |
99 | 107 | const vdom$ = view( |
100 | 108 | sources.onion.state$, |
101 | 109 | topBarSinks.screen, |
102 | 110 | publicTabSinks.screen, |
103 | - syncTabSinks.screen, | |
111 | + connectionsTabSinks.screen, | |
104 | 112 | ); |
105 | 113 | |
106 | 114 | const toast$: Stream<Toast> = sources.ssb.acceptInviteResponse$.map(res => { |
107 | 115 | if (res === true) |
@@ -121,9 +129,9 @@ | ||
121 | 129 | return { |
122 | 130 | screen: vdom$, |
123 | 131 | onion: reducer$, |
124 | 132 | navigation: command$, |
125 | - alert: syncTabSinks.alert, | |
133 | + alert: connectionsTabSinks.alert, | |
126 | 134 | ssb: publicTabSinks.ssb, |
127 | 135 | toast: toast$, |
128 | 136 | }; |
129 | 137 | } |
src/app/screens/central/model.ts | ||
---|---|---|
@@ -21,16 +21,16 @@ | ||
21 | 21 | import {Reducer, Lens} from 'cycle-onionify'; |
22 | 22 | import {FeedId} from 'ssb-typescript'; |
23 | 23 | import {State as PublicTabState} from './public-tab/model'; |
24 | 24 | import {State as TopBarState} from './top-bar'; |
25 | -import {State as SyncTabState} from './sync-tab/model'; | |
25 | +import {State as ConnectionsTabState} from './connections-tab/model'; | |
26 | 26 | import {SSBSource} from '../../drivers/ssb'; |
27 | 27 | |
28 | 28 | export type State = { |
29 | 29 | selfFeedId: FeedId; |
30 | 30 | currentTab: number; |
31 | 31 | publicTab?: PublicTabState; |
32 | - syncTab?: SyncTabState; | |
32 | + connectionsTab?: ConnectionsTabState; | |
33 | 33 | numOfPublicUpdates: number; |
34 | 34 | }; |
35 | 35 | |
36 | 36 | export function initState(selfFeedId: FeedId): State { |
@@ -76,12 +76,12 @@ | ||
76 | 76 | }; |
77 | 77 | }, |
78 | 78 | }; |
79 | 79 | |
80 | -export const syncTabLens: Lens<State, SyncTabState> = { | |
81 | - get: (parent: State): SyncTabState => { | |
82 | - if (parent.syncTab) { | |
83 | - return {...parent.syncTab, selfFeedId: parent.selfFeedId}; | |
80 | +export const connectionsTabLens: Lens<State, ConnectionsTabState> = { | |
81 | + get: (parent: State): ConnectionsTabState => { | |
82 | + if (parent.connectionsTab) { | |
83 | + return {...parent.connectionsTab, selfFeedId: parent.selfFeedId}; | |
84 | 84 | } else { |
85 | 85 | return { |
86 | 86 | selfFeedId: parent.selfFeedId, |
87 | 87 | lanEnabled: false, |
@@ -92,12 +92,12 @@ | ||
92 | 92 | }; |
93 | 93 | } |
94 | 94 | }, |
95 | 95 | |
96 | - set: (parent: State, child: SyncTabState): State => { | |
96 | + set: (parent: State, child: ConnectionsTabState): State => { | |
97 | 97 | return { |
98 | 98 | ...parent, |
99 | - syncTab: child, | |
99 | + connectionsTab: child, | |
100 | 100 | }; |
101 | 101 | }, |
102 | 102 | }; |
103 | 103 |
src/app/screens/central/view.ts | ||
---|---|---|
@@ -34,12 +34,12 @@ | ||
34 | 34 | accessible: true, |
35 | 35 | accessibilityLabel: 'Public Tab Button', |
36 | 36 | }, |
37 | 37 | |
38 | - sync: { | |
38 | + connections: { | |
39 | 39 | name: 'wan', |
40 | 40 | accessible: true, |
41 | - accessibilityLabel: 'Sync Tab Button', | |
41 | + accessibilityLabel: 'Connections Tab Button', | |
42 | 42 | }, |
43 | 43 | }; |
44 | 44 | |
45 | 45 | function renderPublicIcon(numOfPublicUpdates: number) { |
@@ -78,10 +78,13 @@ | ||
78 | 78 | selectedItemStyle: styles.tabItemSelected, |
79 | 79 | tabs: [ |
80 | 80 | renderPublicIcon(state.numOfPublicUpdates), |
81 | 81 | { |
82 | - normal: h(Icon, {...iconProps.tab, ...iconData.sync}), | |
83 | - selected: h(Icon, {...iconProps.tabSelected, ...iconData.sync}), | |
82 | + normal: h(Icon, {...iconProps.tab, ...iconData.connections}), | |
83 | + selected: h(Icon, { | |
84 | + ...iconProps.tabSelected, | |
85 | + ...iconData.connections, | |
86 | + }), | |
84 | 87 | }, |
85 | 88 | ], |
86 | 89 | }), |
87 | 90 | }, |
src/app/screens/central/connections-tab/README.md | ||
---|---|---|
@@ -1,0 +1,1 @@ | ||
1 | +This Cycle.js component represents the screen where the user can see current connections with other users, syncing data through various means, such as Wi-Fi LAN, internet, Bluetooth, etc. |
src/app/screens/central/connections-tab/index.ts | ||
---|---|---|
@@ -1,0 +1,67 @@ | ||
1 | +/** | |
2 | + * MMMMM is a mobile app for Secure Scuttlebutt networks | |
3 | + * | |
4 | + * Copyright (C) 2017 Andre 'Staltz' Medeiros | |
5 | + * | |
6 | + * This program is free software: you can redistribute it and/or modify | |
7 | + * it under the terms of the GNU General Public License as published by | |
8 | + * the Free Software Foundation, either version 3 of the License, or | |
9 | + * (at your option) any later version. | |
10 | + * | |
11 | + * This program is distributed in the hope that it will be useful, | |
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | + * GNU General Public License for more details. | |
15 | + * | |
16 | + * You should have received a copy of the GNU General Public License | |
17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | + */ | |
19 | + | |
20 | +import {Stream} from 'xstream'; | |
21 | +import {ReactElement} from 'react'; | |
22 | +import {StateSource, Reducer} from 'cycle-onionify'; | |
23 | +import {Command as AlertCommand} from 'cycle-native-alert'; | |
24 | +import {ReactSource} from '@cycle/react'; | |
25 | +import {Command} from 'cycle-native-navigation'; | |
26 | +import {WifiSource} from '../../../drivers/wifi'; | |
27 | +import {SSBSource} from '../../../drivers/ssb'; | |
28 | +import view from './view'; | |
29 | +import intent from './intent'; | |
30 | +import model, {State} from './model'; | |
31 | +import navigation from './navigation'; | |
32 | + | |
33 | +export type Sources = { | |
34 | + screen: ReactSource; | |
35 | + onion: StateSource<State>; | |
36 | + ssb: SSBSource; | |
37 | + wifi: WifiSource; | |
38 | +}; | |
39 | + | |
40 | +export type Sinks = { | |
41 | + screen: Stream<ReactElement<any>>; | |
42 | + navigation: Stream<Command>; | |
43 | + alert: Stream<AlertCommand>; | |
44 | + onion: Stream<Reducer<State>>; | |
45 | +}; | |
46 | + | |
47 | +export function connectionsTab(sources: Sources): Sinks { | |
48 | + const actions = intent(sources.screen); | |
49 | + const vdom$ = view(sources.onion.state$); | |
50 | + const command$ = navigation(actions, sources.onion.state$); | |
51 | + const reducer$ = model(sources.ssb, sources.wifi); | |
52 | + const alert$ = actions.showLANHelp$.mapTo({ | |
53 | + title: 'Friends around you', | |
54 | + message: | |
55 | + 'This list shows friends (accounts you follow) which are currently ' + | |
56 | + 'connected to you in the same Local Area Network, for instance the ' + | |
57 | + 'same Wi-Fi, so they are probably "around you".', | |
58 | + buttons: [{text: 'OK', id: 'okay'}], | |
59 | + }); | |
60 | + | |
61 | + return { | |
62 | + alert: alert$, | |
63 | + navigation: command$, | |
64 | + screen: vdom$, | |
65 | + onion: reducer$, | |
66 | + }; | |
67 | +} |
src/app/screens/central/connections-tab/intent.ts | ||
---|---|---|
@@ -1,0 +1,38 @@ | ||
1 | +/** | |
2 | + * MMMMM is a mobile app for Secure Scuttlebutt networks | |
3 | + * | |
4 | + * Copyright (C) 2017 Andre 'Staltz' Medeiros | |
5 | + * | |
6 | + * This program is free software: you can redistribute it and/or modify | |
7 | + * it under the terms of the GNU General Public License as published by | |
8 | + * the Free Software Foundation, either version 3 of the License, or | |
9 | + * (at your option) any later version. | |
10 | + * | |
11 | + * This program is distributed in the hope that it will be useful, | |
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | + * GNU General Public License for more details. | |
15 | + * | |
16 | + * You should have received a copy of the GNU General Public License | |
17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | + */ | |
19 | + | |
20 | +import xs, {Stream} from 'xstream'; | |
21 | +import {ReactSource} from '@cycle/react'; | |
22 | +import {FeedId} from 'ssb-typescript'; | |
23 | + | |
24 | +export default function intent(reactSource: ReactSource) { | |
25 | + return { | |
26 | + showLANHelp$: reactSource.select('lan-help').events('press').mapTo(null), | |
27 | + | |
28 | + goToPeerProfile$: xs.merge( | |
29 | + reactSource.select('lan-peers').events('pressPeer'), | |
30 | + reactSource.select('pub-peers').events('pressPeer'), | |
31 | + ) as Stream<FeedId>, | |
32 | + | |
33 | + goToPasteInvite$: reactSource | |
34 | + .select('invites') | |
35 | + .events('pressPaste') | |
36 | + .mapTo(null), | |
37 | + }; | |
38 | +} |
src/app/screens/central/connections-tab/model.ts | ||
---|---|---|
@@ -1,0 +1,75 @@ | ||
1 | +/** | |
2 | + * MMMMM is a mobile app for Secure Scuttlebutt networks | |
3 | + * | |
4 | + * Copyright (C) 2017 Andre 'Staltz' Medeiros | |
5 | + * | |
6 | + * This program is free software: you can redistribute it and/or modify | |
7 | + * it under the terms of the GNU General Public License as published by | |
8 | + * the Free Software Foundation, either version 3 of the License, or | |
9 | + * (at your option) any later version. | |
10 | + * | |
11 | + * This program is distributed in the hope that it will be useful, | |
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | + * GNU General Public License for more details. | |
15 | + * | |
16 | + * You should have received a copy of the GNU General Public License | |
17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | + */ | |
19 | + | |
20 | +import xs, {Stream} from 'xstream'; | |
21 | +import {PeerMetadata, FeedId} from 'ssb-typescript'; | |
22 | +import {Reducer} from 'cycle-onionify'; | |
23 | +import {SSBSource} from '../../../drivers/ssb'; | |
24 | +import {WifiSource} from '../../../drivers/wifi'; | |
25 | + | |
26 | +export type State = { | |
27 | + selfFeedId: FeedId; | |
28 | + lanEnabled: boolean; | |
29 | + peers: { | |
30 | + lan: Array<PeerMetadata>; | |
31 | + pub: Array<PeerMetadata>; | |
32 | + }; | |
33 | +}; | |
34 | + | |
35 | +export default function model( | |
36 | + ssbSource: SSBSource, | |
37 | + wifiSource: WifiSource, | |
38 | +): Stream<Reducer<State>> { | |
39 | + const initReducer$ = xs.of(function initReducer(): State { | |
40 | + return { | |
41 | + selfFeedId: '', | |
42 | + lanEnabled: false, | |
43 | + peers: { | |
44 | + lan: [], | |
45 | + pub: [], | |
46 | + }, | |
47 | + }; | |
48 | + }); | |
49 | + | |
50 | + const updateLanEnabled$ = wifiSource.isEnabled().map( | |
51 | + lanEnabled => | |
52 | + function updateLanEnabled(prev: State): State { | |
53 | + return { | |
54 | + selfFeedId: prev.selfFeedId, | |
55 | + lanEnabled, | |
56 | + peers: prev.peers, | |
57 | + }; | |
58 | + }, | |
59 | + ); | |
60 | + | |
61 | + const setPeersReducer$ = ssbSource.peers$.map( | |
62 | + peers => | |
63 | + function setPeersReducer(prev: State): State { | |
64 | + const lan = peers.filter(peer => peer.source === 'local'); | |
65 | + const pub = peers.filter(peer => peer.source !== 'local'); | |
66 | + return { | |
67 | + selfFeedId: prev.selfFeedId, | |
68 | + lanEnabled: prev.lanEnabled, | |
69 | + peers: {lan, pub}, | |
70 | + }; | |
71 | + }, | |
72 | + ); | |
73 | + | |
74 | + return xs.merge(initReducer$, setPeersReducer$, updateLanEnabled$); | |
75 | +} |
src/app/screens/central/connections-tab/navigation.ts | ||
---|---|---|
@@ -1,0 +1,71 @@ | ||
1 | +/** | |
2 | + * MMMMM is a mobile app for Secure Scuttlebutt networks | |
3 | + * | |
4 | + * Copyright (C) 2017 Andre 'Staltz' Medeiros | |
5 | + * | |
6 | + * This program is free software: you can redistribute it and/or modify | |
7 | + * it under the terms of the GNU General Public License as published by | |
8 | + * the Free Software Foundation, either version 3 of the License, or | |
9 | + * (at your option) any later version. | |
10 | + * | |
11 | + * This program is distributed in the hope that it will be useful, | |
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | + * GNU General Public License for more details. | |
15 | + * | |
16 | + * You should have received a copy of the GNU General Public License | |
17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | + */ | |
19 | + | |
20 | +import xs, {Stream} from 'xstream'; | |
21 | +import sampleCombine from 'xstream/extra/sampleCombine'; | |
22 | +import {FeedId} from 'ssb-typescript'; | |
23 | +import {Command} from 'cycle-native-navigation'; | |
24 | +import {Screens} from '../../..'; | |
25 | +import {navOptions as profileScreenNavOptions} from '../../profile'; | |
26 | +import {navOptions as pasteInviteScreenNavOptions} from '../../invite-paste'; | |
27 | +import {State} from './model'; | |
28 | + | |
29 | +export type Actions = { | |
30 | + goToPeerProfile$: Stream<FeedId>; | |
31 | + goToPasteInvite$: Stream<any>; | |
32 | +}; | |
33 | + | |
34 | +export default function navigation( | |
35 | + actions: Actions, | |
36 | + state$: Stream<State>, | |
37 | +): Stream<Command> { | |
38 | + const toProfile$ = actions.goToPeerProfile$ | |
39 | + .compose(sampleCombine(state$)) | |
40 | + .map( | |
41 | + ([feedId, state]) => | |
42 | + ({ | |
43 | + type: 'push', | |
44 | + layout: { | |
45 | + component: { | |
46 | + name: Screens.Profile, | |
47 | + passProps: { | |
48 | + selfFeedId: state.selfFeedId, | |
49 | + feedId, | |
50 | + }, | |
51 | + options: profileScreenNavOptions, | |
52 | + }, | |
53 | + }, | |
54 | + } as Command), | |
55 | + ); | |
56 | + | |
57 | + const toPasteInvite$ = actions.goToPasteInvite$.map( | |
58 | + () => | |
59 | + ({ | |
60 | + type: 'showOverlay', | |
61 | + layout: { | |
62 | + component: { | |
63 | + name: Screens.InvitePaste, | |
64 | + options: pasteInviteScreenNavOptions, | |
65 | + }, | |
66 | + }, | |
67 | + } as Command), | |
68 | + ); | |
69 | + | |
70 | + return xs.merge(toProfile$, toPasteInvite$); | |
71 | +} |
src/app/screens/central/connections-tab/styles.ts | ||
---|---|---|
@@ -1,0 +1,37 @@ | ||
1 | +/** | |
2 | + * MMMMM is a mobile app for Secure Scuttlebutt networks | |
3 | + * | |
4 | + * Copyright (C) 2017 Andre 'Staltz' Medeiros | |
5 | + * | |
6 | + * This program is free software: you can redistribute it and/or modify | |
7 | + * it under the terms of the GNU General Public License as published by | |
8 | + * the Free Software Foundation, either version 3 of the License, or | |
9 | + * (at your option) any later version. | |
10 | + * | |
11 | + * This program is distributed in the hope that it will be useful, | |
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | + * GNU General Public License for more details. | |
15 | + * | |
16 | + * You should have received a copy of the GNU General Public License | |
17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | + */ | |
19 | + | |
20 | +import {StyleSheet} from 'react-native'; | |
21 | +import {Dimensions as Dimens} from '../../../global-styles/dimens'; | |
22 | +import {Palette} from '../../../global-styles/palette'; | |
23 | + | |
24 | +export const styles = StyleSheet.create({ | |
25 | + container: { | |
26 | + backgroundColor: Palette.brand.voidBackground, | |
27 | + alignSelf: 'stretch', | |
28 | + flex: 1, | |
29 | + }, | |
30 | +}); | |
31 | + | |
32 | +export const iconProps = { | |
33 | + info: { | |
34 | + size: Dimens.iconSizeSmall, | |
35 | + color: Palette.brand.darkTextWeak, | |
36 | + }, | |
37 | +}; |
src/app/screens/central/connections-tab/view.ts | ||
---|---|---|
@@ -1,0 +1,69 @@ | ||
1 | +/** | |
2 | + * MMMMM is a mobile app for Secure Scuttlebutt networks | |
3 | + * | |
4 | + * Copyright (C) 2017 Andre 'Staltz' Medeiros | |
5 | + * | |
6 | + * This program is free software: you can redistribute it and/or modify | |
7 | + * it under the terms of the GNU General Public License as published by | |
8 | + * the Free Software Foundation, either version 3 of the License, or | |
9 | + * (at your option) any later version. | |
10 | + * | |
11 | + * This program is distributed in the hope that it will be useful, | |
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | + * GNU General Public License for more details. | |
15 | + * | |
16 | + * You should have received a copy of the GNU General Public License | |
17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | + */ | |
19 | + | |
20 | +import {Stream} from 'xstream'; | |
21 | +import {h} from '@cycle/react'; | |
22 | +import {ScrollView} from 'react-native'; | |
23 | +import {styles} from './styles'; | |
24 | +import {State} from './model'; | |
25 | +import InviteHeader from '../../../components/InviteHeader'; | |
26 | +import SyncChannelAccordion from '../../../components/SyncChannelAccordion'; | |
27 | + | |
28 | +export default function view(state$: Stream<State>) { | |
29 | + return state$.map(state => | |
30 | + h(ScrollView, {style: styles.container}, [ | |
31 | + h(InviteHeader, {sel: 'invites'}), | |
32 | + | |
33 | + // h(SyncChannelAccordion, { | |
34 | + // icon: 'bluetooth', | |
35 | + // name: 'Bluetooth', | |
36 | + // active: false, | |
37 | + // info: 'Connect with people very near', | |
38 | + // onPressActivate: () => {}, | |
39 | + // peers: state.peers.bluetooth, | |
40 | + // }), | |
41 | + | |
42 | + h(SyncChannelAccordion, { | |
43 | + sel: 'lan-peers', | |
44 | + icon: 'wifi', | |
45 | + name: 'Local network', | |
46 | + active: state.lanEnabled, | |
47 | + info: 'Connect with people in the same space', | |
48 | + peers: state.peers.lan, | |
49 | + }), | |
50 | + | |
51 | + // h(SyncChannelAccordion, { | |
52 | + // icon: 'account-network', | |
53 | + // name: 'Internet P2P', | |
54 | + // active: false, | |
55 | + // info: 'Connect with friends online now on the internet', | |
56 | + // peers: state.peers.dht, | |
57 | + // }), | |
58 | + | |
59 | + h(SyncChannelAccordion, { | |
60 | + sel: 'pub-peers', | |
61 | + icon: 'server-network', | |
62 | + name: 'Internet servers', | |
63 | + active: true, | |
64 | + info: 'Connect with community servers on the internet', | |
65 | + peers: state.peers.pub, | |
66 | + }), | |
67 | + ]), | |
68 | + ); | |
69 | +} |
src/app/screens/central/sync-tab/README.md | ||
---|---|---|
@@ -1,1 +1,0 @@ | ||
1 | -This Cycle.js component represents the screen where the user can perform syncing of data through various means, such as Wi-Fi LAN, internet, Bluetooth, etc. |
src/app/screens/central/sync-tab/index.ts | ||
---|---|---|
@@ -1,67 +1,0 @@ | ||
1 | -/** | |
2 | - * MMMMM is a mobile app for Secure Scuttlebutt networks | |
3 | - * | |
4 | - * Copyright (C) 2017 Andre 'Staltz' Medeiros | |
5 | - * | |
6 | - * This program is free software: you can redistribute it and/or modify | |
7 | - * it under the terms of the GNU General Public License as published by | |
8 | - * the Free Software Foundation, either version 3 of the License, or | |
9 | - * (at your option) any later version. | |
10 | - * | |
11 | - * This program is distributed in the hope that it will be useful, | |
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - * GNU General Public License for more details. | |
15 | - * | |
16 | - * You should have received a copy of the GNU General Public License | |
17 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | - */ | |
19 | - | |
20 | -import {Stream} from 'xstream'; | |
21 | -import {ReactElement} from 'react'; | |
22 | -import {StateSource, Reducer} from 'cycle-onionify'; | |
23 | -import {Command as AlertCommand} from 'cycle-native-alert'; | |
24 | -import {ReactSource} from '@cycle/react'; | |
25 | -import {Command} from 'cycle-native-navigation'; | |
26 | -import {WifiSource} from '../../../drivers/wifi'; | |
27 | -import {SSBSource} from '../../../drivers/ssb'; | |
28 | -import view from './view'; | |
29 | -import intent from './intent'; | |
30 | -import model, {State} from './model'; | |
31 | -import navigation from './navigation'; | |
32 | - | |
33 | -export type Sources = { | |
34 | - screen: ReactSource; | |
35 | - onion: StateSource<State>; | |
36 | - ssb: SSBSource; | |
37 | - wifi: WifiSource; | |
38 | -}; | |
39 | - | |
40 | -export type Sinks = { | |
41 | - screen: Stream<ReactElement<any>>; | |
42 | - navigation: Stream<Command>; | |
43 | - alert: Stream<AlertCommand>; | |
44 | - onion: Stream<Reducer<State>>; | |
45 | -}; | |
46 | - | |
47 | -export function syncTab(sources: Sources): Sinks { | |
48 | - const actions = intent(sources.screen); | |
49 | - const vdom$ = view(sources.onion.state$); | |
50 | - const command$ = navigation(actions, sources.onion.state$); | |
51 | - const reducer$ = model(sources.ssb, sources.wifi); | |
52 | - const alert$ = actions.showLANHelp$.mapTo({ | |
53 | - title: 'Friends around you', | |
54 | - message: | |
55 | - 'This list shows friends (accounts you follow) which are currently ' + | |
56 | - 'connected to you in the same Local Area Network, for instance the ' + | |
57 | - 'same Wi-Fi, so they are probably "around you".', | |
58 | - buttons: [{text: 'OK', id: 'okay'}], | |
59 | - }); | |
60 | - | |
61 | - return { | |
62 | - alert: alert$, | |
63 | - navigation: command$, | |
64 | - screen: vdom$, | |
65 | - onion: reducer$, | |
66 | - }; | |
67 | -} |
src/app/screens/central/sync-tab/intent.ts | ||
---|---|---|
@@ -1,38 +1,0 @@ | ||
1 | -/** | |
2 | - * MMMMM is a mobile app for Secure Scuttlebutt networks | |
3 | - * | |
4 | - * Copyright (C) 2017 Andre 'Staltz' Medeiros | |
5 | - * | |
6 | - * This program is free software: you can redistribute it and/or modify | |
7 | - * it under the terms of the GNU General Public License as published by | |
8 | - * the Free Software Foundation, either version 3 of the License, or | |
9 | - * (at your option) any later version. | |
10 | - * | |
11 | - * This program is distributed in the hope that it will be useful, | |
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - * GNU General Public License for more details. | |
15 | - * | |
16 | - * You should have received a copy of the GNU General Public License | |
17 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | - */ | |
19 | - | |
20 | -import xs, {Stream} from 'xstream'; | |
21 | -import {ReactSource} from '@cycle/react'; | |
22 | -import {FeedId} from 'ssb-typescript'; | |
23 | - | |
24 | -export default function intent(reactSource: ReactSource) { | |
25 | - return { | |
26 | - showLANHelp$: reactSource.select('lan-help').events('press').mapTo(null), | |
27 | - | |
28 | - goToPeerProfile$: xs.merge( | |
29 | - reactSource.select('lan-peers').events('pressPeer'), | |
30 | - reactSource.select('pub-peers').events('pressPeer'), | |
31 | - ) as Stream<FeedId>, | |
32 | - | |
33 | - goToPasteInvite$: reactSource | |
34 | - .select('invites') | |
35 | - .events('pressPaste') | |
36 | - .mapTo(null), | |
37 | - }; | |
38 | -} |
src/app/screens/central/sync-tab/model.ts | ||
---|---|---|
@@ -1,75 +1,0 @@ | ||
1 | -/** | |
2 | - * MMMMM is a mobile app for Secure Scuttlebutt networks | |
3 | - * | |
4 | - * Copyright (C) 2017 Andre 'Staltz' Medeiros | |
5 | - * | |
6 | - * This program is free software: you can redistribute it and/or modify | |
7 | - * it under the terms of the GNU General Public License as published by | |
8 | - * the Free Software Foundation, either version 3 of the License, or | |
9 | - * (at your option) any later version. | |
10 | - * | |
11 | - * This program is distributed in the hope that it will be useful, | |
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - * GNU General Public License for more details. | |
15 | - * | |
16 | - * You should have received a copy of the GNU General Public License | |
17 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | - */ | |
19 | - | |
20 | -import xs, {Stream} from 'xstream'; | |
21 | -import {PeerMetadata, FeedId} from 'ssb-typescript'; | |
22 | -import {Reducer} from 'cycle-onionify'; | |
23 | -import {SSBSource} from '../../../drivers/ssb'; | |
24 | -import {WifiSource} from '../../../drivers/wifi'; | |
25 | - | |
26 | -export type State = { | |
27 | - selfFeedId: FeedId; | |
28 | - lanEnabled: boolean; | |
29 | - peers: { | |
30 | - lan: Array<PeerMetadata>; | |
31 | - pub: Array<PeerMetadata>; | |
32 | - }; | |
33 | -}; | |
34 | - | |
35 | -export default function model( | |
36 | - ssbSource: SSBSource, | |
37 | - wifiSource: WifiSource, | |
38 | -): Stream<Reducer<State>> { | |
39 | - const initReducer$ = xs.of(function initReducer(): State { | |
40 | - return { | |
41 | - selfFeedId: '', | |
42 | - lanEnabled: false, | |
43 | - peers: { | |
44 | - lan: [], | |
45 | - pub: [], | |
46 | - }, | |
47 | - }; | |
48 | - }); | |
49 | - | |
50 | - const updateLanEnabled$ = wifiSource.isEnabled().map( | |
51 | - lanEnabled => | |
52 | - function updateLanEnabled(prev: State): State { | |
53 | - return { | |
54 | - selfFeedId: prev.selfFeedId, | |
55 | - lanEnabled, | |
56 | - peers: prev.peers, | |
57 | - }; | |
58 | - }, | |
59 | - ); | |
60 | - | |
61 | - const setPeersReducer$ = ssbSource.peers$.map( | |
62 | - peers => | |
63 | - function setPeersReducer(prev: State): State { | |
64 | - const lan = peers.filter(peer => peer.source === 'local'); | |
65 | - const pub = peers.filter(peer => peer.source !== 'local'); | |
66 | - return { | |
67 | - selfFeedId: prev.selfFeedId, | |
68 | - lanEnabled: prev.lanEnabled, | |
69 | - peers: {lan, pub}, | |
70 | - }; | |
71 | - }, | |
72 | - ); | |
73 | - | |
74 | - return xs.merge(initReducer$, setPeersReducer$, updateLanEnabled$); | |
75 | -} |
src/app/screens/central/sync-tab/navigation.ts | ||
---|---|---|
@@ -1,71 +1,0 @@ | ||
1 | -/** | |
2 | - * MMMMM is a mobile app for Secure Scuttlebutt networks | |
3 | - * | |
4 | - * Copyright (C) 2017 Andre 'Staltz' Medeiros | |
5 | - * | |
6 | - * This program is free software: you can redistribute it and/or modify | |
7 | - * it under the terms of the GNU General Public License as published by | |
8 | - * the Free Software Foundation, either version 3 of the License, or | |
9 | - * (at your option) any later version. | |
10 | - * | |
11 | - * This program is distributed in the hope that it will be useful, | |
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - * GNU General Public License for more details. | |
15 | - * | |
16 | - * You should have received a copy of the GNU General Public License | |
17 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | - */ | |
19 | - | |
20 | -import xs, {Stream} from 'xstream'; | |
21 | -import sampleCombine from 'xstream/extra/sampleCombine'; | |
22 | -import {FeedId} from 'ssb-typescript'; | |
23 | -import {Command} from 'cycle-native-navigation'; | |
24 | -import {Screens} from '../../..'; | |
25 | -import {navOptions as profileScreenNavOptions} from '../../profile'; | |
26 | -import {navOptions as pasteInviteScreenNavOptions} from '../../invite-paste'; | |
27 | -import {State} from './model'; | |
28 | - | |
29 | -export type Actions = { | |
30 | - goToPeerProfile$: Stream<FeedId>; | |
31 | - goToPasteInvite$: Stream<any>; | |
32 | -}; | |
33 | - | |
34 | -export default function navigation( | |
35 | - actions: Actions, | |
36 | - state$: Stream<State>, | |
37 | -): Stream<Command> { | |
38 | - const toProfile$ = actions.goToPeerProfile$ | |
39 | - .compose(sampleCombine(state$)) | |
40 | - .map( | |
41 | - ([feedId, state]) => | |
42 | - ({ | |
43 | - type: 'push', | |
44 | - layout: { | |
45 | - component: { | |
46 | - name: Screens.Profile, | |
47 | - passProps: { | |
48 | - selfFeedId: state.selfFeedId, | |
49 | - feedId, | |
50 | - }, | |
51 | - options: profileScreenNavOptions, | |
52 | - }, | |
53 | - }, | |
54 | - } as Command), | |
55 | - ); | |
56 | - | |
57 | - const toPasteInvite$ = actions.goToPasteInvite$.map( | |
58 | - () => | |
59 | - ({ | |
60 | - type: 'showOverlay', | |
61 | - layout: { | |
62 | - component: { | |
63 | - name: Screens.InvitePaste, | |
64 | - options: pasteInviteScreenNavOptions, | |
65 | - }, | |
66 | - }, | |
67 | - } as Command), | |
68 | - ); | |
69 | - | |
70 | - return xs.merge(toProfile$, toPasteInvite$); | |
71 | -} |
src/app/screens/central/sync-tab/styles.ts | ||
---|---|---|
@@ -1,37 +1,0 @@ | ||
1 | -/** | |
2 | - * MMMMM is a mobile app for Secure Scuttlebutt networks | |
3 | - * | |
4 | - * Copyright (C) 2017 Andre 'Staltz' Medeiros | |
5 | - * | |
6 | - * This program is free software: you can redistribute it and/or modify | |
7 | - * it under the terms of the GNU General Public License as published by | |
8 | - * the Free Software Foundation, either version 3 of the License, or | |
9 | - * (at your option) any later version. | |
10 | - * | |
11 | - * This program is distributed in the hope that it will be useful, | |
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - * GNU General Public License for more details. | |
15 | - * | |
16 | - * You should have received a copy of the GNU General Public License | |
17 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | - */ | |
19 | - | |
20 | -import {StyleSheet} from 'react-native'; | |
21 | -import {Dimensions as Dimens} from '../../../global-styles/dimens'; | |
22 | -import {Palette} from '../../../global-styles/palette'; | |
23 | - | |
24 | -export const styles = StyleSheet.create({ | |
25 | - container: { | |
26 | - backgroundColor: Palette.brand.voidBackground, | |
27 | - alignSelf: 'stretch', | |
28 | - flex: 1, | |
29 | - }, | |
30 | -}); | |
31 | - | |
32 | -export const iconProps = { | |
33 | - info: { | |
34 | - size: Dimens.iconSizeSmall, | |
35 | - color: Palette.brand.darkTextWeak, | |
36 | - }, | |
37 | -}; |
src/app/screens/central/sync-tab/view.ts | ||
---|---|---|
@@ -1,69 +1,0 @@ | ||
1 | -/** | |
2 | - * MMMMM is a mobile app for Secure Scuttlebutt networks | |
3 | - * | |
4 | - * Copyright (C) 2017 Andre 'Staltz' Medeiros | |
5 | - * | |
6 | - * This program is free software: you can redistribute it and/or modify | |
7 | - * it under the terms of the GNU General Public License as published by | |
8 | - * the Free Software Foundation, either version 3 of the License, or | |
9 | - * (at your option) any later version. | |
10 | - * | |
11 | - * This program is distributed in the hope that it will be useful, | |
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - * GNU General Public License for more details. | |
15 | - * | |
16 | - * You should have received a copy of the GNU General Public License | |
17 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | - */ | |
19 | - | |
20 | -import {Stream} from 'xstream'; | |
21 | -import {h} from '@cycle/react'; | |
22 | -import {ScrollView} from 'react-native'; | |
23 | -import {styles} from './styles'; | |
24 | -import {State} from './model'; | |
25 | -import InviteHeader from '../../../components/InviteHeader'; | |
26 | -import SyncChannelAccordion from '../../../components/SyncChannelAccordion'; | |
27 | - | |
28 | -export default function view(state$: Stream<State>) { | |
29 | - return state$.map(state => | |
30 | - h(ScrollView, {style: styles.container}, [ | |
31 | - h(InviteHeader, {sel: 'invites'}), | |
32 | - | |
33 | - // h(SyncChannelAccordion, { | |
34 | - // icon: 'bluetooth', | |
35 | - // name: 'Bluetooth', | |
36 | - // active: false, | |
37 | - // info: 'Connect with people very near', | |
38 | - // onPressActivate: () => {}, | |
39 | - // peers: state.peers.bluetooth, | |
40 | - // }), | |
41 | - | |
42 | - h(SyncChannelAccordion, { | |
43 | - sel: 'lan-peers', | |
44 | - icon: 'wifi', | |
45 | - name: 'Local network', | |
46 | - active: state.lanEnabled, | |
47 | - info: 'Connect with people in the same space', | |
48 | - peers: state.peers.lan, | |
49 | - }), | |
50 | - | |
51 | - // h(SyncChannelAccordion, { | |
52 | - // icon: 'account-network', | |
53 | - // name: 'Internet P2P', | |
54 | - // active: false, | |
55 | - // info: 'Connect with friends online now on the internet', | |
56 | - // peers: state.peers.dht, | |
57 | - // }), | |
58 | - | |
59 | - h(SyncChannelAccordion, { | |
60 | - sel: 'pub-peers', | |
61 | - icon: 'server-network', | |
62 | - name: 'Internet servers', | |
63 | - active: true, | |
64 | - info: 'Connect with community servers on the internet', | |
65 | - peers: state.peers.pub, | |
66 | - }), | |
67 | - ]), | |
68 | - ); | |
69 | -} |
Built with git-ssb-web