[DE mobile] extended Search view

This commit is contained in:
Maxim Kadushkin 2021-01-23 00:20:31 +03:00
parent 8fbb7f75ec
commit ba1cff609d
5 changed files with 200 additions and 7 deletions

View file

@ -52,6 +52,12 @@
ul { ul {
border-radius: 0; border-radius: 0;
} }
li:first-child, li:last-child {
> label {
border-radius: 0;
}
}
} }
} }

View file

@ -0,0 +1,8 @@
import React from 'react';
import SearchView, {SearchSettingsView} from '../view/Search'
const SearchController = props => {
return <SearchView />
};
export {SearchController as Search, SearchSettingsView as SearchSettings};

View file

@ -4,8 +4,9 @@ import { Page, View, Navbar, NavLeft, NavRight, Link, Icon } from 'framework7-re
import EditOptions from '../view/edit/Edit'; import EditOptions from '../view/edit/Edit';
import AddOptions from '../view/add/Add'; import AddOptions from '../view/add/Add';
import Settings from '../view/settings/Settings'; import Settings from '../view/settings/Settings';
import SearchView from '../view/search';
import CollaborationView from '../../../../common/mobile/lib/view/Collaboration.jsx' import CollaborationView from '../../../../common/mobile/lib/view/Collaboration.jsx'
import { Device } from '../../../../common/mobile/utils/device'
import { Search, SearchSettings } from '../controller/Search';
export default class Home extends Component { export default class Home extends Component {
constructor(props) { constructor(props) {
@ -59,16 +60,19 @@ export default class Home extends Component {
<NavRight> <NavRight>
<Link id='btn-edit' icon='icon-edit-settings' href={false} onClick={e => this.handleClickToOpenOptions('edit')}></Link> <Link id='btn-edit' icon='icon-edit-settings' href={false} onClick={e => this.handleClickToOpenOptions('edit')}></Link>
<Link id='btn-add' icon='icon-plus' href={false} onClick={e => this.handleClickToOpenOptions('add')}></Link> <Link id='btn-add' icon='icon-plus' href={false} onClick={e => this.handleClickToOpenOptions('add')}></Link>
<Link icon='icon-search' searchbarEnable='.searchbar' href={false}></Link> { Device.phone ? null : <Link icon='icon-search' searchbarEnable='.searchbar' href={false}></Link> }
<Link href={false} icon='icon-collaboration' onClick={e => this.handleClickToOpenOptions('coauth')}></Link> <Link href={false} icon='icon-collaboration' onClick={e => this.handleClickToOpenOptions('coauth')}></Link>
<Link id='btn-settings' icon='icon-settings' href={false} onClick={e => this.handleClickToOpenOptions('settings')}></Link> <Link id='btn-settings' icon='icon-settings' href={false} onClick={e => this.handleClickToOpenOptions('settings')}></Link>
</NavRight> </NavRight>
<SearchView /> { Device.phone ? null : <Search /> }
</Navbar> </Navbar>
{/* Page content */} {/* Page content */}
<View id="editor_sdk"> <View id="editor_sdk">
</View> </View>
{
Device.phone ? null : <SearchSettings />
}
{ {
!this.state.editOptionsVisible ? null : !this.state.editOptionsVisible ? null :
<EditOptions onclosed={this.handleOptionsViewClosed.bind(this, 'edit')} /> <EditOptions onclosed={this.handleOptionsViewClosed.bind(this, 'edit')} />

View file

@ -0,0 +1,116 @@
import React, { Component } from 'react';
import { Searchbar, Popover, Popup, View, Page, List, ListItem, Navbar, NavRight, Link } from 'framework7-react';
import { f7ready, f7 } from 'framework7-react';
import { Device } from '../../../../common/mobile/utils/device';
const popoverStyle = {
height: '300px'
};
class SearchSettingsView extends Component {
constructor(props) {
super(props);
this.state = {
useReplace: false,
caseSensitive: false,
markResults: false
};
}
onFindReplaceClick(action) {
this.setState({
useReplace: action == 'replace'
});
}
render() {
const show_popover = true;
const navbar =
<Navbar title="Find and replace">
{!show_popover &&
<NavRight>
<Link popupClose=".search-settings-popup">Done</Link>
</NavRight>}
</Navbar>;
const content =
<View style={popoverStyle}>
<Page>
{navbar}
<List>
<ListItem radio title="Find" name="find-replace-checkbox" checked={!this.state.useReplace} onClick={e => this.onFindReplaceClick('find')}></ListItem>
<ListItem radio title="Find and replace" name="find-replace-checkbox" checked={this.state.useReplace} onClick={e => this.onFindReplaceClick('replace')}></ListItem>
</List>
</Page>
</View>;
return (
show_popover ?
<Popover id="idx-search-settings" className="popover__titled">{content}</Popover> :
<Popup id="idx-search-settings">{content}</Popup>
)
}
}
class SearchView extends Component {
constructor(props) {
super(props);
$$(document).on('page:init', (e, page) => {
if ( page.name == 'home' ) {
this.$f7.searchbar.create({
el: '.searchbar',
customSearch: true,
expandable: true,
backdrop: false,
on: {
search: (bar, curval, prevval) => {
console.log('on search results ' + curval);
}
}
});
}
});
this.onSettingsClick = this.onSettingsClick.bind(this);
}
componentDidMount(){
}
onSettingsClick(e) {
if ( Device.phone ) {
// f7.popup.open('.settings-popup');
} else this.$f7.popover.open('#idx-search-settings', '#idx-btn-search-settings');
}
render() {
return (
<form className="searchbar">
<div className="searchbar-bg"></div>
<div className="searchbar-inner">
<div className="buttons-row">
<a id="idx-btn-search-settings" className="link icon-only" onClick={this.onSettingsClick}>
<i className="icon icon-settings" />
</a>
</div>
<div className="searchbar-input-wrap">
<input placeholder="Search" type="search" />
<i className="searchbar-icon" />
<span className="input-clear-button" />
</div>
<div className="buttons-row">
<a className="link icon-only prev disabled">
<i className="icon icon-prev" />
</a>
<a className="link icon-only next disabled">
<i className="icon icon-next" />
</a>
</div>
<span className="searchbar-disable-button">Cancel</span>
</div>
</form>
)
}
}
export {SearchView as default, SearchSettingsView};

View file

@ -1,14 +1,63 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Searchbar, Link } from 'framework7-react'; import { Searchbar, Popover, Popup, View, Page, List, ListItem, Navbar, NavRight, Link } from 'framework7-react';
import { f7ready, f7 } from 'framework7-react'; import { f7ready, f7 } from 'framework7-react';
import { Device } from '../../../../common/mobile/utils/device';
export default class SearchView extends Component { const popoverStyle = {
height: '300px'
};
class SearchSettingsView extends Component {
constructor(props) {
super(props);
this.state = {
useReplace: false,
caseSensitive: false,
markResults: false
};
}
onFindReplaceClick(action) {
this.setState({
useReplace: action == 'replace'
});
}
render() {
const show_popover = true;
const navbar =
<Navbar title="Find and replace">
{!show_popover &&
<NavRight>
<Link popupClose=".search-settings-popup">Done</Link>
</NavRight>}
</Navbar>;
const content =
<View style={popoverStyle}>
<Page>
{navbar}
<List>
<ListItem radio title="Find" name="find-replace-checkbox" checked={!this.state.useReplace} onClick={e => this.onFindReplaceClick('find')}></ListItem>
<ListItem radio title="Find and replace" name="find-replace-checkbox" checked={this.state.useReplace} onClick={e => this.onFindReplaceClick('replace')}></ListItem>
</List>
</Page>
</View>;
return (
show_popover ?
<Popover id="idx-search-settings" className="popover__titled">{content}</Popover> :
<Popup id="idx-search-settings">{content}</Popup>
)
}
}
class SearchView extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
$$(document).on('page:init', (e, page) => { $$(document).on('page:init', (e, page) => {
if ( page.name == 'home' ) { if ( page.name == 'home' ) {
f7.searchbar.create({ this.$f7.searchbar.create({
el: '.searchbar', el: '.searchbar',
customSearch: true, customSearch: true,
expandable: true, expandable: true,
@ -21,18 +70,26 @@ export default class SearchView extends Component {
}); });
} }
}); });
this.onSettingsClick = this.onSettingsClick.bind(this);
} }
componentDidMount(){ componentDidMount(){
} }
onSettingsClick(e) {
if ( Device.phone ) {
// f7.popup.open('.settings-popup');
} else this.$f7.popover.open('#idx-search-settings', '#idx-btn-search-settings');
}
render() { render() {
return ( return (
<form className="searchbar"> <form className="searchbar">
<div className="searchbar-bg"></div> <div className="searchbar-bg"></div>
<div className="searchbar-inner"> <div className="searchbar-inner">
<div className="buttons-row"> <div className="buttons-row">
<a id="search-settings" className="link icon-only" onClick={e => console.log('search settings click')}> <a id="idx-btn-search-settings" className="link icon-only" onClick={this.onSettingsClick}>
<i className="icon icon-settings" /> <i className="icon icon-settings" />
</a> </a>
</div> </div>
@ -55,3 +112,5 @@ export default class SearchView extends Component {
) )
} }
} }
export {SearchView as default, SearchSettingsView};