Skip to content

Commit

Permalink
🎨 After Pull
Browse files Browse the repository at this point in the history
  • Loading branch information
Orca1110 committed Oct 26, 2022
2 parents 0b07463 + 32143b0 commit 0c82838
Show file tree
Hide file tree
Showing 12 changed files with 578 additions and 10 deletions.
2 changes: 2 additions & 0 deletions App.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import NotFound from './web/pages/NotFound.web';
import Home from './web/pages/Home.web';
import Info from './web/pages/Info.web';
import MessageScreen from './web/pages/MessageScreen.web';
import SearchScreen from './web/SearchScreen.web';

const queryClient = new QueryClient();

Expand All @@ -25,6 +26,7 @@ function App() {
path="/messages/:messageId/web"
element={<MessageScreen />}
/>
<Route path="/search" element={<SearchScreen />} />
</Routes>
</BrowserRouter>
</Provider>
Expand Down
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,26 @@

## Demo

**Authentication (Login/SignUp)**
**Authentication (SignUp/Login)**
<image src="https://user-images.githubusercontent.com/72551358/197339969-3f884440-128e-45f1-902b-54088f3a5dd1.gif" width="150px"/>
<image src="https://user-images.githubusercontent.com/72551358/197340008-d22c2c8d-1f1b-4c46-a8df-78e138a45d7d.gif" width="150px"/>

**Search Brand**
**Search Brand / Follow&UnFollow**
<image src="https://user-images.githubusercontent.com/72551358/197339992-f0f7d9f3-6032-4126-8ff1-4e346da88dce.gif" width="150px"/>

**Read Messages**
**Read Messages / Create Comment**
<image src="https://user-images.githubusercontent.com/72551358/197340006-2e55f7cb-5043-418d-b455-c3541c28c097.gif" width="150px"/>

**Create Comment**
**Brand Assign**
<image src="https://user-images.githubusercontent.com/72551358/197341212-86abe19d-2447-454e-b328-a767af815577.gif" width="150px"/>

**Receive Message(Push Alarm)**

**Brand Assign**
**Create Message**
<image src="https://user-images.githubusercontent.com/72551358/197340004-d5b0a7c8-bbee-4534-84a9-c9cf18283545.gif" width="150px"/>

**Create Message**
**Receive Message(Push Alarm)**

**Information Web**
<image src="https://user-images.githubusercontent.com/72551358/197341213-881ecc14-9a98-49df-8b54-8077a4a15247.gif" width="150px"/>

<br/>

Expand Down
14 changes: 13 additions & 1 deletion api/web/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import client from '../client';
import {Message} from '../message/types';
import {brand, brandProfile, getBrandWebMessageParams} from './types';
import {
brand,
brandProfile,
getBrandWebMessageParams,
AllBrandResult,
} from './types';

export async function getBrandWebProfile(brandId: number) {
const response = await client.get<brandProfile>(`/brand/${brandId}/web`);
Expand Down Expand Up @@ -28,3 +33,10 @@ export async function getRecentMessage() {
const response = await client.get<Message[]>('/messages/recommend/web');
return response.data;
}

export async function getAllBrand(params: number) {
const response = await client.get<AllBrandResult[]>(
`/brands/web?cursor=${params}`,
);
return response.data;
}
23 changes: 23 additions & 0 deletions api/web/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,26 @@ export interface brand extends brandProfile {
isLoginUser: boolean;
poolUserId: number;
}

export interface BrandResult {
brandUsername: string;
brandUserId: number;
brandInfo: string;
brandProfileImage: any;
}

export interface AllBrandResult extends BrandResult {
userInfoDto: {
poolUserId: any;
username: any;
nickName: any;
userStatus: any;
follow: boolean;
userFollowerCount: number;
userFollowingCount: number;
brandUserInfoDto: any;
};
poolUserId: number;
brandUserId: number;
isLoginUser: boolean;
}
237 changes: 237 additions & 0 deletions web/SearchScreen.web.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
import React, {useState, useCallback, useEffect} from 'react';
import {
View,
StyleSheet,
SafeAreaView,
FlatList,
ActivityIndicator,
Text,
Image,
TouchableOpacity,
} from 'react-native';
import SearchBar from './components/SearchBar';
import RecommandBrandUserContainer from './components/RecommandBrandUserContainer';
import RecommandSubTitle from '../components/search/RecommandSubTitle';
// import SearchResultBrandUserContainer from '../components/search/SearchResultBrandUserContainer';
import SearchResultSubTitle from '../components/search/SearchResultSubTitle';
import theme from '../assets/theme';
import {useQuery} from 'react-query';
import {getAllBrand} from '../api/web/index';
import {AllBrandResult} from '../api/web/types';
import Back from './assets/search/Back.png';
import {useNavigate} from 'react-router-dom';

// import {follow, unfollow} from '../api/follow';

const LENGTH = 10;

function SearchScreen() {
const navigation = useNavigate();
const [cursor, setCursor] = useState<number>(0);
const [Brands, setBrands] = useState<AllBrandResult[]>([]);
const [noMoreBrand, setNoMoreBrand] = useState<boolean>(false);
const [following, setFollowing] = useState(false);
const changeFollowing = () => setFollowing(!following);
const [searchText, setSearchText] = useState('');
const [refreshing, setRefreshing] = useState(false);
const [searchFilter, setSearchFilter] = useState<AllBrandResult[]>([]);
const onChangeText = (payload: string) => setSearchText(payload);
const {isLoading: isBrandLoading, refetch} = useQuery(
'getAllBrand',
() => getAllBrand(cursor),
{
refetchOnMount: 'always',
onSuccess: (data: AllBrandResult[]) => {
if (data.length < LENGTH) {
setNoMoreBrand(true);
}
if (data.length !== 0) {
if (cursor === 0) {
setBrands(data);
} else {
setBrands(Brands.concat(data));
}
setCursor(data[data.length - 1].brandUserId);
setRefreshing(false);
}
},
},
);

const onEndReached = () => {
if (!noMoreBrand) {
refetch();
}
};
// const onMount = useCallback(()=>{
// setRefreshing(true);
// refetch();
// setRefreshing(false);
// }, [refetch])
const onRefresh = useCallback(() => {
setRefreshing(true);
setCursor(0);
refetch();
setRefreshing(false);
}, [refetch]);
useEffect(() => {
onRefresh();
// onMount();
setSearchFilter(
Brands?.filter(brand =>
brand.brandUsername
.toUpperCase()
.includes(`${searchText.toUpperCase()}`),
),
);
// refetch();
}, [refetch, searchText, Brands, onRefresh]);
const RenderRecommandItem = ({item}) => {
return (
<RecommandBrandUserContainer
key={item.poolUserId}
changeFollowing={changeFollowing}
brandUsername={item.brandUsername}
brandInfo={item.brandInfo}
brandProfileImage={item.brandProfileImage}
follow={item.userInfoDto?.follow}
userFollowerCount={item.userInfoDto?.userFollowerCount}
brandUserId={item.brandUserId}
poolUserId={item.poolUserId}
isLoginUser={item.isLoginUser}
refetch={refetch}
searchText={searchText}
/>
);
};
// const searchFilter = Brands?.filter(brand =>
// brand.brandUsername.toUpperCase().includes(`${searchText.toUpperCase()}`),
// );

// const RenderSearchItem = ({item}) => {
// return (
// <SearchResultBrandUserContainer
// key={item.poolUserId}
// changeFollowing={changeFollowing}
// brandUsername={item.brandUsername}
// brandProfileImage={item.brandProfileImage}
// follow={item.userInfoDto?.follow}
// userFollowerCount={item.userInfoDto?.userFollowerCount}
// brandUserId={item.brandUserId}
// poolUserId={item.poolUserId}
// isLoginUser={item.isLoginUser}
// refetch={refetch}
// />
// );
// };

return (
<SafeAreaView style={styles.safeArea}>
<View style={styles.SearchScreenContainer}>
<View style={styles.Header}>
<TouchableOpacity onPress={() => navigation('/')}>
<Image source={Back} style={styles.Back} />
</TouchableOpacity>

<Text style={styles.HeaderText}>POOL에서 브랜드를 찾아보세요</Text>
<View style={styles.align} />
</View>
<View>
<SearchBar searchText={searchText} onChangeText={onChangeText} />
<View style={styles.line} />
</View>
<View style={styles.container}>
{searchFilter ? (
<FlatList
data={searchText !== '' ? searchFilter : Brands}
style={styles.flatList}
renderItem={
// searchText !== '' ? RenderSearchItem : RenderRecommandItem
RenderRecommandItem
}
showsVerticalScrollIndicator={false}
onEndReached={() => {
onEndReached();
}}
onEndReachedThreshold={0.6}
onRefresh={onRefresh}
refreshing={refreshing}
ListHeaderComponent={
searchText !== '' ? (
<SearchResultSubTitle searchCount={searchFilter?.length} />
) : (
<RecommandSubTitle />
)
}
ListFooterComponent={
<>{isBrandLoading && <ActivityIndicator />}</>
}
/>
) : (
<>
<SearchResultSubTitle searchCount={0} />
<View style={styles.noSearchTextContainer}>
<Text style={styles.noSearchText}>검색 결과가 없습니다</Text>
</View>
</>
)}
</View>
</View>
</SafeAreaView>
);
}

const styles = StyleSheet.create({
line: {
backgroundColor: theme.colors.Grey20,
height: 1,
width: '100%',
},
safeArea: {
backgroundColor: theme.colors.Grey10,
height: '100%',
},
flatList: {
backgroundColor: theme.colors.Grey10,
},
noSearchTextContainer: {
backgroundColor: theme.colors.Grey10,
alignItems: 'center',
padding: 4,
paddingTop: 32,
},
noSearchText: {
color: theme.colors.Grey40,
fontSize: theme.fontSize.P1,
fontFamily: theme.fontFamily.Pretendard,
},
container: {
height: '89%',
},
SearchScreenContainer: {
backgroundColor: theme.colors.Grey10,
},
Back: {
width: 32,
height: 32,
marginLeft: 10,
},
Header: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
flex: 1,
zIndex: 999,
paddingTop: 30,
backgroundColor: theme.colors.White,
paddingBottom: 10,
},
HeaderText: {
fontWeight: theme.fontWeight.Bold,
fontSize: theme.fontSize.H4,
fontFamily: theme.fontFamily.Pretendard,
},
align: {width: 32, height: 32, marginRight: 10},
});

export default SearchScreen;
Binary file added web/assets/search/Back.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 web/assets/search/Delete.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 web/assets/search/Search.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 web/assets/search/Search_OnFocus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0c82838

Please sign in to comment.