Skip to content

Commit

Permalink
update ui for tabbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Kien Tran committed Oct 11, 2018
1 parent 6ff05ca commit 32c0c8b
Show file tree
Hide file tree
Showing 22 changed files with 218 additions and 49 deletions.
2 changes: 1 addition & 1 deletion repositories/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './location'
export * from "./location";
7 changes: 6 additions & 1 deletion repositories/lib/location/LocationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ import { Location, LocationRepository } from "weather-domain";
// import {} from '@reactivex/rxjs'
// import 'rxjs/Rx'
export class DefaultLocationRepository implements LocationRepository {
private googleAPIKey: string;

public constructor(googleAPIKey: string) {
this.googleAPIKey = googleAPIKey;
}
public searchCity(searchText: string): RxJs.Observable<Location> {
return RxJs.Observable.create((observer) => {
const key = "AIzaSyDz8iOOAc-1NqzKRLl5n1qJFYY39NoL6EY";
const key = this.googleAPIKey;
const endcodedSearchText = encodeURI(searchText);
const uri = "https://maps.googleapis.com/maps/api/place/autocomplete/json?key=" + key
+ "&input=" + endcodedSearchText + "&types=(cities)";
Expand Down
2 changes: 1 addition & 1 deletion repositories/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "weather-repositories",
"version": "0.0.3",
"version": "0.0.4",
"description": "Repository",
"main": "./dist/index.js",
"scripts": {
Expand Down
14 changes: 14 additions & 0 deletions repositories/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"label-position": false,
"trailing-comma": false,
"object-literal-sort-keys": false,
"no-console": false
},
"rulesDirectory": []
}
2 changes: 1 addition & 1 deletion weather-ui
Submodule weather-ui updated from a9a0e8 to 506ac1
1 change: 0 additions & 1 deletion weather/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { Navigation } from "react-native-navigation";
import { Provider } from "react-redux";
import { applyMiddleware, combineReducers, createStore } from "redux";
import thunk from "redux-thunk";
import { Drawer } from "./src/Drawer/Drawer";
import Home from "./src/Home/Home";
import { reducer } from "./src/reducer/reducer";

Expand Down
2 changes: 1 addition & 1 deletion weather/config.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function registerScreens(store, provider) {
export function registerScreenVisibilityListener() {
new ScreenVisibilityListener({
willAppear: ({screen}) => console.log(`Displaying screen ${screen}`),
didAppear: ({screen, startTime, endTime, commandType}) => console.log('screenVisibility', `Screen ${screen} displayed in ${endTime - startTime} millis [${commandType}]`),
didAppear: ({screen, startTime, endTime, commandType}) => console.log('screenVisibility', `Screen ${screen} displayed in ${endTime - startTime} milliseconds [${commandType}]`),
willDisappear: ({screen}) => console.log(`Screen will disappear ${screen}`),
didDisappear: ({screen}) => console.log(`Screen disappeared ${screen}`)
}).register();
Expand Down
18 changes: 9 additions & 9 deletions weather/config.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ export function registerScreens(store, provider) {
}).register();
}

// registerScreenVisibilityListener();

// let middleware = [thunk];
// middleware = [...middleware];
export default function configureStore(initialState) {
return createStore(
reducer,
Expand All @@ -38,10 +34,7 @@ export default function configureStore(initialState) {
const store = configureStore();
registerScreens(store, Provider); // this is where you register all of your app's screens



// start the app

const navigatorStyle = {
statusBarColor: 'black',
statusBarTextColorScheme: 'light',
Expand All @@ -62,12 +55,19 @@ const navigatorStyle = {
Navigation.startTabBasedApp({
tabs: [
{
label: 'One',
label: 'Search',
screen: 'example.FirstTabScreen', // this is a registered name for a screen
title: 'Screen One',
icon: require('./src/Home/icon-home.png'), // for icon button, provide the local image asset name

}
},
{
label: 'Settings',
screen: 'example.FirstTabScreen', // this is a registered name for a screen
title: 'Screen One',
icon: require('./src/Home/icon-home.png'), // for icon button, provide the local image asset name

}
],
tabsStyle: {
tabBarButtonColor: '#ffff00', // change the color of the tab icons and text (also unselected)
Expand Down
2 changes: 1 addition & 1 deletion weather/index.android.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/* eslint-disable no-unused-vars */
import App from './config';
import App from './src/Navigation';
5 changes: 3 additions & 2 deletions weather/index.ios.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-unused-vars */
import App from './config';
import App from "./App";
import {} from "./src/Navigation/index.ios";

const app = new App();
// const app = new App();
12 changes: 10 additions & 2 deletions weather/ios/Weather.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,12 @@
TargetAttributes = {
00E356ED1AD99517003FC87E = {
CreatedOnToolsVersion = 6.2;
DevelopmentTeam = 3RJP5ULJ98;
TestTargetID = 13B07F861A680F5B00A75B9A;
};
13B07F861A680F5B00A75B9A = {
DevelopmentTeam = 3RJP5ULJ98;
};
2D02E47A1E0B4A5D006451C7 = {
CreatedOnToolsVersion = 8.2.1;
ProvisioningStyle = Automatic;
Expand Down Expand Up @@ -1324,6 +1328,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = 3RJP5ULJ98;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
Expand Down Expand Up @@ -1355,6 +1360,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
DEVELOPMENT_TEAM = 3RJP5ULJ98;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
Expand Down Expand Up @@ -1383,6 +1389,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = 3RJP5ULJ98;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
Expand All @@ -1395,7 +1402,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.ttkien.Weather;
PRODUCT_NAME = Weather;
VERSIONING_SYSTEM = "apple-generic";
};
Expand All @@ -1406,6 +1413,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 3RJP5ULJ98;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
Expand All @@ -1418,7 +1426,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.ttkien.Weather;
PRODUCT_NAME = Weather;
VERSIONING_SYSTEM = "apple-generic";
};
Expand Down
32 changes: 16 additions & 16 deletions weather/ios/Weather/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSLocationWhenInUseUsageDescription</key>
<string/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
Expand All @@ -53,6 +37,8 @@
</dict>
</dict>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
Expand All @@ -71,5 +57,19 @@
<string>SimpleLineIcons.ttf</string>
<string>Zocial.ttf</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
23 changes: 13 additions & 10 deletions weather/src/Home/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from "react";
import React from "react";
import { Image, Platform, SafeAreaView, Text, KeyboardAvoidingView } from "react-native";
import { Image, KeyboardAvoidingView, Platform, SafeAreaView, Text } from "react-native";
import { SearchBar } from "react-native-elements";
import { connect } from "react-redux";
import { SearchLocationList, SearchLocationListDataItem } from "weather-ui";
Expand Down Expand Up @@ -36,28 +36,26 @@ export class Home extends Component<Props> {
public func;
public onChangeText = (text: string) => {
this.props.searchLocation(text);
};
}

public onCancel = () => {
this.onChangeText("");
};
}
public isError(): boolean {
return this.props.error !== undefined && this.props.error !== null;
}

public render() {
let errorView;
if (this.isError()) {
if (this.isError() && this.props.error !== null) {
errorView = <Text>{this.props.error.message}</Text>;
} else {
errorView = <Text></Text>;
}

return (
<SafeAreaView style={{ flex: 1 }}>
<KeyboardAvoidingView
style = {{ flex: 1 }}
behavior="padding"
enabled
>

<SearchBar
platform="ios"
onChangeText={this.onChangeText}
Expand All @@ -66,6 +64,11 @@ export class Home extends Component<Props> {
placeholder="Enter location"
/>
{errorView}
<KeyboardAvoidingView
style = {{ flex: 1 }}
behavior="padding"
enabled
>
<SearchLocationList items={this.props.items} />
</KeyboardAvoidingView>
</SafeAreaView>
Expand All @@ -79,7 +82,7 @@ const mapStateToProps = (state: ISearchLocationState): Props => {

let locations: SearchLocationListDataItem[] = [];
if (searchLocation && searchLocation.locations) {
locations = searchLocation.locations.map(location => {
locations = searchLocation.locations.map((location) => {
return new SearchLocationListDataItem(location.name);
});
}
Expand Down
Binary file modified weather/src/Home/icon-home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added weather/src/Home/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added weather/src/Home/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions weather/src/Navigation/index.android.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Navigation, ScreenVisibilityListener } from "react-native-navigation";
import { Provider } from "react-redux";
import { applyMiddleware, createStore } from "redux";
import thunk from "redux-thunk";
import {
configureStore,
registerScreens,
registerScreenVisibilityListener
} from "./screens";

const store = configureStore();
registerScreens(store, Provider);
registerScreenVisibilityListener();

const navigatorStyle = {
statusBarColor: "black",
statusBarTextColorScheme: "light",
navigationBarColor: "black",
navBarBackgroundColor: "#0a0a0a",
navBarTextColor: "white",
navBarButtonColor: "white",
tabBarButtonColor: "red",
tabBarSelectedButtonColor: "red",
tabBarBackgroundColor: "white",
topBarElevationShadowEnabled: false,
navBarHideOnScroll: true,
tabBarHidden: true,
drawUnderTabBar: true
};

// start the app
Navigation.startTabBasedApp({
tabs: [
{
label: "Search",
screen: "weather.SearchLocation", // this is a registered name for a screen
title: "Screen One",
icon: require("../Home/icon-home.png") // for icon button, provide the local image asset name
},
{
label: "Settings",
screen: "weather.Settings", // this is a registered name for a screen
title: "Screen One",
icon: require("../Home/icon-home.png") // for icon button, provide the local image asset name
}
],
tabsStyle: {
tabBarButtonColor: "#ffff00" // change the color of the tab icons and text (also unselected)
}
});
Loading

0 comments on commit 32c0c8b

Please sign in to comment.