repo_name
stringlengths 5
122
| path
stringlengths 3
232
| text
stringlengths 6
1.05M
|
---|---|---|
raulrozza/Gametask_Mobile | src/modules/selectedGame/infra/controllers/useRequestAchievementUnlockController.ts | import { useCallback, useMemo, useState } from 'react';
import IRequestAchievementDTO from 'modules/selectedGame/domain/dtos/IRequestAchievementDTO';
import makeRequestAchievementUnlockService from 'modules/selectedGame/services/factories/makeRequestAchievementUnlockService';
import { useSessionContext, useToastContext } from 'shared/view/contexts';
interface UseRequestAchievementUnlockController {
loading: boolean;
requestAchievement(values: IRequestAchievementDTO): Promise<boolean>;
}
export default function useRequestAchievementUnlockController(): UseRequestAchievementUnlockController {
const [loading, setLoading] = useState(false);
const requestAchievementServoce = useMemo(
() => makeRequestAchievementUnlockService(),
[],
);
const session = useSessionContext();
const toast = useToastContext();
const requestAchievement = useCallback(
async (values: IRequestAchievementDTO) => {
setLoading(true);
const response = await requestAchievementServoce.execute(values);
setLoading(false);
if (response.shouldLogout) {
session.logout();
return false;
}
if (response.error) {
toast.showError(response.error);
return false;
}
return true;
},
[requestAchievementServoce, session, toast],
);
return {
loading,
requestAchievement,
};
}
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/domain/repositories/IGamesRepository.ts | <filename>src/modules/chooseGame/domain/repositories/IGamesRepository.ts
import IGame from 'shared/domain/entities/IGame';
export default interface IGamesRepository {
findById(id: string): Promise<IGame>;
}
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/view/pages/Profile/components/ImageInput/styles.ts | <filename>src/modules/chooseGame/view/pages/Profile/components/ImageInput/styles.ts
import styled from 'styled-components/native';
export const Image = styled.Image`
width: 120px;
height: 120px;
border-radius: 60px;
margin-bottom: ${({ theme }) => theme.layout.spacing(4)};
`;
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/services/factories/makeCreatePlayerService.ts | import makePlayersRepository from 'modules/chooseGame/infra/repositories/factories/makePlayersRepository';
import CreatePlayerService from 'modules/chooseGame/services/CreatePlayerService';
export default function makeCreatePlayerService(): CreatePlayerService {
const repository = makePlayersRepository();
return new CreatePlayerService(repository);
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/Activities/components/ActivityCard/styles.ts | <gh_stars>0
import { Typography } from 'shared/view/components';
import styled from 'styled-components/native';
export const Container = styled.View`
padding: ${({ theme }) => theme.layout.spacing(2)};
margin: ${({ theme }) => theme.layout.spacing(1)};
margin-bottom: ${({ theme }) => theme.layout.spacing(4)};
flex-direction: row;
border-width: 2px;
border-radius: ${({ theme }) => theme.layout.borderRadius.medium};
border-color: ${({ theme }) => theme.palette.secondary.dark};
background-color: ${({ theme }) => theme.palette.gray[0]};
`;
export const InfoContainer = styled.View`
width: 80%;
`;
export const Title = styled(Typography)`
font-weight: bold;
font-size: 16px;
margin-bottom: ${({ theme }) => theme.layout.spacing(2)};
color: ${({ theme }) => theme.palette.primary.contrast};
text-transform: uppercase;
`;
export const Description = styled(Typography)`
color: ${({ theme }) => theme.palette.primary.contrast};
`;
export const Experience = {
Container: styled.View`
width: 20%;
justify-content: center;
align-items: center;
margin: ${({ theme }) => theme.layout.spacing(0, 1)};
`,
Text: styled(Typography)`
font-weight: bold;
font-size: 18px;
text-align: center;
color: ${({ theme }) => theme.palette.secondary.light};
`,
};
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/infra/repositories/LeaderboardsRepository.ts | <reponame>raulrozza/Gametask_Mobile
import ILeaderboard from 'modules/selectedGame/domain/entities/ILeaderboard';
import ILeaderboardsRepository from 'modules/selectedGame/domain/repositories/ILeaderboardsRepository';
import makeHttpProvider from 'shared/infra/providers/factories/makeHttpProvider';
export default class LeaderboardsRepository implements ILeaderboardsRepository {
private httpProvider = makeHttpProvider();
public async findCurrent(): Promise<ILeaderboard | null> {
const response = await this.httpProvider.get<ILeaderboard | undefined>(
'leaderboards',
);
return response || null;
}
}
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/services/factories/makeUpdateUserService.ts | import makeUsersRepository from 'modules/chooseGame/infra/repositories/factories/makeUsersRepository';
import UpdateUserService from 'modules/chooseGame/services/UpdateUserService';
export default function makeUpdateUserService(): UpdateUserService {
const repository = makeUsersRepository();
return new UpdateUserService(repository);
}
|
raulrozza/Gametask_Mobile | src/shared/domain/entities/IGame.ts | import ILevelInfo from 'shared/domain/entities/ILevelInfo';
import IRank from 'shared/domain/entities/IRank';
export default interface IGame {
id: string;
name: string;
description: string;
image?: string;
image_url?: string;
levelInfo: ILevelInfo[] | null;
ranks: IRank[];
theme: {
primary: string;
secondary: string;
};
}
|
raulrozza/Gametask_Mobile | src/modules/authentication/services/factories/makeSignUserService.ts | <reponame>raulrozza/Gametask_Mobile<gh_stars>0
import makeUsersRepository from 'modules/authentication/infra/repositories/factories/makeUsersRepository';
import SignUserService from '../SignUserService';
export default function makeSignUserService(): SignUserService {
const usersRepository = makeUsersRepository();
const signUser = new SignUserService(usersRepository);
return signUser;
}
|
raulrozza/Gametask_Mobile | src/shared/view/components/index.ts | <reponame>raulrozza/Gametask_Mobile<gh_stars>0
export { default as Button } from './Button';
export { default as Input } from './Input';
export { default as RefreshControl } from './RefreshControl';
export { default as SubmitButton } from './SubmitButton';
export { default as Typography } from './Typography';
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/domain/repositories/ILeaderboardsRepository.ts | <gh_stars>0
import ILeaderboard from 'modules/selectedGame/domain/entities/ILeaderboard';
export default interface ILeaderboardsRepository {
findCurrent(): Promise<ILeaderboard | null>;
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/Feed/components/RankFeed/index.tsx | <filename>src/modules/selectedGame/view/pages/Feed/components/RankFeed/index.tsx<gh_stars>0
import React from 'react';
import IFeedPost from 'modules/selectedGame/domain/entities/IFeedPost';
import { RankChip } from 'modules/selectedGame/view/components';
import { getTextColor } from 'shared/view/helpers';
import FeedText from '../FeedText';
interface RankFeedProps {
post: IFeedPost;
}
const RankFeed: React.FC<RankFeedProps> = ({ post }) => (
<FeedText.Text>
<FeedText.Name>
{post.player.user.firstname}
{post.player.user.lastname && ` ${post.player.user.lastname}`}
{post.player.currentTitle && `, ${post.player.currentTitle?.name}`}
</FeedText.Name>
<FeedText.Text> conseguiu a patente </FeedText.Text>
<RankChip
backgroundColor={post.rank?.color}
color={getTextColor(post.rank?.color)}
>
{` ${post.rank?.tag} `}
</RankChip>
<FeedText.Text>!</FeedText.Text>
</FeedText.Text>
);
export default RankFeed;
|
raulrozza/Gametask_Mobile | src/shared/view/components/RefreshControl/index.tsx | import React from 'react';
// Libs
import { RefreshControl as RNRefresh, RefreshControlProps } from 'react-native';
import { useThemeContext } from 'shared/view/contexts';
const RefreshControl: React.FC<RefreshControlProps> = ({ ...props }) => {
const { theme } = useThemeContext();
return (
<RNRefresh
colors={[theme.palette.secondary.main]}
progressBackgroundColor={theme.palette.primary.main}
{...props}
/>
);
};
export default RefreshControl;
|
raulrozza/Gametask_Mobile | src/shared/infra/providers/AxiosHTTPProvider.ts | <reponame>raulrozza/Gametask_Mobile<filename>src/shared/infra/providers/AxiosHTTPProvider.ts
import Http from 'config/http';
import IHTTPProvider from 'shared/domain/providers/IHTTPProvider';
import RequestError from 'shared/infra/errors/RequestError';
export default class AxiosHTTPProvider implements IHTTPProvider {
public addHeader: IHTTPProvider['addHeader'] = (key, value) => {
Http.instance.defaults.headers[key] = value;
};
public removeHeader: IHTTPProvider['removeHeader'] = key => {
Reflect.deleteProperty(Http.instance.defaults.headers, key);
};
public delete: IHTTPProvider['delete'] = async (path, config) => {
try {
const response = await Http.instance.delete(path, config);
return response.data;
} catch (error) {
throw new RequestError(error);
}
};
public get: IHTTPProvider['get'] = async (path, config) => {
try {
const response = await Http.instance.get(path, config);
return response.data;
} catch (error) {
throw new RequestError(error);
}
};
public patch: IHTTPProvider['patch'] = async (path, body, config) => {
try {
const response = await Http.instance.patch(path, body, config);
return response.data;
} catch (error) {
throw new RequestError(error);
}
};
public post: IHTTPProvider['post'] = async (path, body, config) => {
try {
const response = await Http.instance.post(path, body, config);
return response.data;
} catch (error) {
throw new RequestError(error);
}
};
public put: IHTTPProvider['put'] = async (path, body, config) => {
try {
const response = await Http.instance.put(path, body, config);
return response.data;
} catch (error) {
throw new RequestError(error);
}
};
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/Feed/components/FeedPost/index.tsx | import React, { useMemo } from 'react';
import IFeedPost from 'modules/selectedGame/domain/entities/IFeedPost';
import { formatDate } from 'modules/selectedGame/view/helpers';
import AchievementFeed from '../AchievementFeed';
import ActivityFeed from '../ActivityFeed';
import LevelUpFeed from '../LevelUpFeed';
import RankFeed from '../RankFeed';
import { Container, Content, Image, Meta, Row } from './styles';
const FeedType = {
achievement: AchievementFeed,
activity: ActivityFeed,
level: LevelUpFeed,
rank: RankFeed,
};
interface FeedPostProps {
post: IFeedPost;
}
const FeedItem: React.FC<FeedPostProps> = ({ post }) => {
const FeedTextContent = useMemo(() => FeedType[post.type], [post]);
return (
<Container>
<Content>
<Image image={post.player.user.profile_url} />
<Row>
<FeedTextContent post={post} />
</Row>
</Content>
<Meta.Container>
<Meta.Text>{formatDate(post.date)}</Meta.Text>
</Meta.Container>
</Container>
);
};
export default FeedItem;
|
raulrozza/Gametask_Mobile | src/shared/view/components/Button/index.tsx | <filename>src/shared/view/components/Button/index.tsx
import React from 'react';
import { ActivityIndicator, StyleProp, ViewStyle } from 'react-native';
import {
DefaultTheme,
FlattenInterpolation,
StyledComponent,
ThemeProps,
} from 'styled-components';
import { useThemeContext } from 'shared/view/contexts';
import {
RectContainer,
StyledContainer,
TouchableContainer,
Text,
} from './styles';
type ButtonTypes = 'rect-button' | 'touchable-opacity';
const ButtonComponent: Record<
ButtonTypes,
StyledComponent<any, DefaultTheme>
> = {
'rect-button': RectContainer,
'touchable-opacity': TouchableContainer,
};
export interface ButtonProps {
outline?: boolean;
style?: StyleProp<ViewStyle>;
disabled?: boolean;
loading?: boolean;
activeOpacity?: number;
onPress?: () => void;
textStyle?: FlattenInterpolation<ThemeProps<DefaultTheme>>;
type?: 'rect-button' | 'touchable-opacity';
children: string;
}
const Button: React.FC<ButtonProps> = ({
outline = false,
disabled = false,
loading = false,
type = 'rect-button',
style,
activeOpacity,
onPress,
textStyle,
children,
}) => {
const { theme } = useThemeContext();
const Container = ButtonComponent[type];
return (
<Container
activeOpacity={activeOpacity}
disabled={disabled || loading}
onPress={onPress}
style={style}
>
<StyledContainer outline={outline} disabled={disabled || loading}>
{loading ? (
<ActivityIndicator
size="small"
color={
outline
? theme.palette.secondary.main
: theme.palette.secondary.contrast
}
/>
) : (
<Text outline={outline} textStyle={textStyle}>
{children}
</Text>
)}
</StyledContainer>
</Container>
);
};
export default Button;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/PlayerProfile/components/BasicLevelInfo/index.tsx | <reponame>raulrozza/Gametask_Mobile
import React, { useMemo } from 'react';
import { usePlayerProfileContext } from 'modules/selectedGame/view/contexts';
import ProgressBar from '../ProgressBar';
import TitleSelect from '../TitleSelect';
import { getPlayerNextLevel } from './helpers';
import {
BarContainer,
Container,
LevelInfo,
NextLevel,
Picture,
} from './styles';
const BasicLevelInfo: React.FC = () => {
const { player } = usePlayerProfileContext();
const playerNextLevel = useMemo(
() =>
player && getPlayerNextLevel(player.level, player.game?.levelInfo || []),
[player],
);
const progressToNextLevel = playerNextLevel
? player.experience / playerNextLevel.requiredExperience
: 1;
const missingExpToNextLevel = playerNextLevel
? playerNextLevel.requiredExperience - player.experience
: 0;
return (
<Container>
<Picture image={player.user.profile_url} />
<LevelInfo.View>
<LevelInfo.Text>{player.level}</LevelInfo.Text>
<LevelInfo.Exp>{player.experience} XP</LevelInfo.Exp>
</LevelInfo.View>
<BarContainer>
<ProgressBar progress={progressToNextLevel} />
</BarContainer>
<NextLevel.Container>
{missingExpToNextLevel > 0 && (
<NextLevel.Text>Faltam {missingExpToNextLevel} XP</NextLevel.Text>
)}
</NextLevel.Container>
<TitleSelect />
</Container>
);
};
export default BasicLevelInfo;
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/view/pages/Lobby/components/ModalContent/styles.ts | <filename>src/modules/chooseGame/view/pages/Lobby/components/ModalContent/styles.ts
import { Dimensions } from 'react-native';
import { MaterialIcons } from '@expo/vector-icons';
import { BarCodeScanner } from 'expo-barcode-scanner';
import styled, { css } from 'styled-components/native';
export const Wrapper = styled.View`
flex: 1;
justify-content: flex-end;
`;
export const Container = styled.View`
background-color: ${({ theme }) => theme.palette.primary.main};
width: 100%;
height: 60%;
border-top-left-radius: 16px;
border-top-right-radius: 16px;
align-items: center;
justify-content: center;
`;
export const PageTitle = styled.Text`
color: ${({ theme }) => theme.palette.secondary.main};
margin-bottom: ${({ theme }) => theme.layout.spacing(12)};
font-family: ${({ theme }) => theme.typography.family.title.bold};
font-size: 24px;
`;
export const PasteGroup = {
Container: styled.View`
flex-direction: row;
align-items: stretch;
height: 48px;
width: 80%;
max-width: 300px;
overflow: hidden;
border: 1px solid ${({ theme }) => theme.palette.secondary.main};
border-radius: ${({ theme }) => theme.layout.borderRadius.small};
margin-bottom: 48px;
`,
Input: styled.TextInput`
padding: ${({ theme }) => theme.layout.spacing(0, 3)};
flex: 1;
${({ theme }) => css`
background-color: ${theme.palette.primary.dark};
color: ${theme.palette.primary.contrast};
`}
`,
Button: styled.TouchableOpacity`
width: 48px;
display: flex;
justify-content: center;
align-items: center;
background-color: ${({ theme }) => theme.palette.primary.main};
`,
Icon: styled(MaterialIcons)`
font-size: 24px;
color: ${({ theme }) => theme.palette.secondary.main};
`,
};
export const ScannerContainer = styled.View`
${({ theme }) => css`
margin-bottom: ${theme.layout.spacing(4)};
`}
`;
export const CodeScanner = styled(BarCodeScanner)`
${({ theme }) => {
const { width, height } = Dimensions.get('window');
return css`
width: ${width}px;
height: ${height}px;
border-radius: ${theme.layout.borderRadius.medium};
border: 1px solid ${theme.palette.secondary.main};
`;
}}
`;
|
raulrozza/Gametask_Mobile | src/modules/authentication/infra/routes/index.tsx | <filename>src/modules/authentication/infra/routes/index.tsx
import React from 'react';
// Pages
import Login from 'modules/authentication/view/pages/Login';
const AuthenticationRoutes: React.FC = () => <Login />;
export default AuthenticationRoutes;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/services/GetCurrentLeaderboard.ts | import ILeaderboard from 'modules/selectedGame/domain/entities/ILeaderboard';
import ILeaderboardsRepository from 'modules/selectedGame/domain/repositories/ILeaderboardsRepository';
interface IExecute {
leaderboard?: ILeaderboard | null;
error?: string;
shouldLogout?: boolean;
}
export default class GetCurrentLeaderboard {
constructor(private leaderboardsRepository: ILeaderboardsRepository) {}
public async execute(): Promise<IExecute> {
try {
const leaderboard = await this.leaderboardsRepository.findCurrent();
return { leaderboard };
} catch (error) {
return { error: error.message, shouldLogout: error.shouldLogout };
}
}
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/Feed/components/RankTag/index.tsx | import React from 'react';
import { RankChip } from 'modules/selectedGame/view/components';
import IRank from 'shared/domain/entities/IRank';
import { getTextColor } from 'shared/view/helpers';
interface RankTagProps {
rank?: IRank;
}
const RankTag: React.FC<RankTagProps> = ({ rank }) => {
if (rank)
return (
<RankChip backgroundColor={rank.color} color={getTextColor(rank.color)}>
{` ${rank.tag} `}
</RankChip>
);
return null;
};
export default RankTag;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/PlayerProfile/components/AchievementList/helpers/addObtainedFieldToAchievements.ts | import IAchievement from 'modules/selectedGame/domain/entities/IAchievement';
import IPlayer from 'shared/domain/entities/IPlayer';
export default function addObtainedFieldToAchievements(
achievements: IAchievement[],
player: IPlayer,
): Array<IAchievement & { obtained: boolean }> {
if (!achievements || !player) return [];
const mappedAchievements = achievements.map(achievement => {
return {
...achievement,
obtained: player.achievements.includes(achievement.id),
};
});
return mappedAchievements;
}
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/view/pages/GameInvite/index.tsx | import React, { useCallback, useMemo } from 'react';
import { useRoute, useNavigation, RouteProp } from '@react-navigation/native';
import { ThemeProvider } from 'styled-components';
import useCreatePlayerController from 'modules/chooseGame/infra/controllers/useCreatePlayerController';
import useGetGameController from 'modules/chooseGame/infra/controllers/useGetGameController';
import useGetUserController from 'modules/chooseGame/infra/controllers/useGetUserController';
import Button from 'shared/view/components/Button';
import { useThemeContext, useToastContext } from 'shared/view/contexts';
import { Container, InviteTitle, GameContainer } from './styles';
type ParamList = {
GameInvite: {
gameId: string;
inviterId: string;
};
};
type IGameInviteRoute = RouteProp<ParamList, 'GameInvite'>;
const GameInvite: React.FC = () => {
const { params } = useRoute<IGameInviteRoute>();
const { game, loading: loadingGame } = useGetGameController({
gameId: params.gameId,
});
const { user, loading: loadingUser } = useGetUserController({
userId: params.inviterId,
});
const { createPlayer, loading: loadingCreate } = useCreatePlayerController();
const { navigate } = useNavigation();
const toast = useToastContext();
const { theme, createPallete } = useThemeContext();
const gameTheme = useMemo(
() =>
game.theme
? {
...theme,
palette: createPallete(game.theme),
}
: theme,
[createPallete, game.theme, theme],
);
const handleAcceptInvitation = useCallback(async () => {
const success = await createPlayer(game.id);
if (success) {
toast.showSuccess('Jogo adicionado!');
navigate('Lobby', { newGame: game.id });
}
}, [createPlayer, navigate, game.id, toast]);
if (loadingGame || loadingUser) return null;
return (
<Container>
<InviteTitle.Text>
Você foi convidado(a) por{' '}
<InviteTitle.Inviter>{user.firstname}</InviteTitle.Inviter> para
participar de <InviteTitle.Game>{game.name}</InviteTitle.Game>
</InviteTitle.Text>
<ThemeProvider theme={gameTheme}>
<GameContainer.Wrapper>
<GameContainer.Image url={game.image_url} />
<GameContainer.Description>
{game.description}
</GameContainer.Description>
<Button
onPress={handleAcceptInvitation}
loading={loadingCreate}
textStyle={GameContainer.buttonTextStyle}
>
Aceitar convite
</Button>
</GameContainer.Wrapper>
</ThemeProvider>
</Container>
);
};
export default GameInvite;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/components/RankChip/index.ts | <reponame>raulrozza/Gametask_Mobile
import styled, { css } from 'styled-components/native';
interface RankChipProps {
backgroundColor?: string;
color?: string;
}
const Rank = styled.Text<RankChipProps>`
${({ theme, backgroundColor, color }) => css`
padding: ${theme.layout.spacing(1)};
margin-right: ${theme.layout.spacing(1)};
border-radius: ${theme.layout.borderRadius.small};
background-color: ${backgroundColor || theme.palette.secondary.main};
color: ${color || theme.palette.secondary.contrast};
font-weight: bold;
`}
`;
export default Rank;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/domain/entities/IActivity.ts | import IGame from 'shared/domain/entities/IGame';
import IUser from 'shared/domain/entities/IUser';
export interface IActivityLog {
version: number;
log: Date;
changes: unknown;
userId: string | IUser;
}
export interface IHistory {
user: string | IUser;
log: Date;
}
export default interface IActivity {
id: string;
name: string;
description?: string;
experience: number;
dmRules?: string;
history: IHistory[];
changelog: IActivityLog[];
game: string | IGame;
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/contexts/PlayerProfileContext/index.ts | import usePlayerProfileContext from 'modules/selectedGame/view/contexts/PlayerProfileContext/hooks/usePlayerProfileContext';
import PlayerProfileContext from 'modules/selectedGame/view/contexts/PlayerProfileContext/implementations/DefaultPlayerProfileContext';
export { PlayerProfileContext, usePlayerProfileContext };
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/Feed/index.tsx | <reponame>raulrozza/Gametask_Mobile<filename>src/modules/selectedGame/view/pages/Feed/index.tsx<gh_stars>0
import React, { useCallback } from 'react';
import { useFocusEffect } from '@react-navigation/native';
import { FlatList } from 'react-native-gesture-handler';
import useGetFeedPostsController from 'modules/selectedGame/infra/controllers/useGetFeedPostsController';
import { RefreshControl } from 'shared/view/components';
import { EmptyList, FeedPost } from './components';
import { Container } from './styles';
const Feed: React.FC = () => {
const { loading, posts, getPosts } = useGetFeedPostsController();
useFocusEffect(
useCallback(() => {
getPosts();
}, [getPosts]),
);
return (
<Container>
<FlatList
refreshControl={
<RefreshControl refreshing={loading} onRefresh={getPosts} />
}
data={posts}
keyExtractor={post => post.id}
ListEmptyComponent={() => <EmptyList />}
renderItem={({ item }) => <FeedPost post={item} />}
/>
</Container>
);
};
export default Feed;
|
raulrozza/Gametask_Mobile | src/shared/view/components/Typography/index.ts | <gh_stars>0
import styled, { css } from 'styled-components/native';
interface TypographyProps {
variant?: 'body' | 'title';
fontBold?: 'main' | 'bold';
}
const Typography = styled.Text<TypographyProps>`
font-size: 16px;
${({ variant = 'body', theme, fontBold = 'main' }) => css`
font-family: ${variant === 'body'
? theme.typography.family.content[fontBold]
: theme.typography.family.title[fontBold]};
`}
`;
export default Typography;
|
raulrozza/Gametask_Mobile | src/shared/view/contexts/ThemeContext/hooks/useThemeContext.ts | <filename>src/shared/view/contexts/ThemeContext/hooks/useThemeContext.ts<gh_stars>0
import { createContext, useContext } from 'react';
import { isEmpty } from 'lodash';
import IThemeContext from 'shared/domain/providers/IThemeContext';
export const ThemeContextProvider = createContext<IThemeContext>(
{} as IThemeContext,
);
const useThemeContext = (): IThemeContext => {
const themeProvider = useContext(ThemeContextProvider);
if (isEmpty(themeProvider))
throw new Error(
'useThemeContext should be called inside a ThemeContextProvider',
);
return themeProvider;
};
export default useThemeContext;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/infra/repositories/AchievementsRepository.ts | <gh_stars>0
import IAchievement from 'modules/selectedGame/domain/entities/IAchievement';
import IAchievementsRepository from 'modules/selectedGame/domain/repositories/IAchievementsRepository';
import makeHttpProvider from 'shared/infra/providers/factories/makeHttpProvider';
export default class AchievementsRepository implements IAchievementsRepository {
private httpProvider = makeHttpProvider();
public async findAll(): Promise<IAchievement[]> {
return this.httpProvider.get('achievements');
}
}
|
raulrozza/Gametask_Mobile | src/shared/domain/providers/IJwtProvider.ts | <reponame>raulrozza/Gametask_Mobile<filename>src/shared/domain/providers/IJwtProvider.ts<gh_stars>0
export interface IJwtProvider {
decode<T = unknown>(token: string): Promise<T | null>;
}
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/services/GetGameService.ts | <reponame>raulrozza/Gametask_Mobile<gh_stars>0
import IGamesRepository from 'modules/chooseGame/domain/repositories/IGamesRepository';
import IGame from 'shared/domain/entities/IGame';
interface IExecute {
game?: IGame;
shouldLogout?: boolean;
error?: string;
}
export default class GetGameService {
constructor(private gamesRepository: IGamesRepository) {}
public async execute(id: string): Promise<IExecute> {
try {
const game = await this.gamesRepository.findById(id);
return { game };
} catch (error) {
return {
error: error.message,
shouldLogout: error.shouldLogout,
};
}
}
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/infra/repositories/factories/makeFeedPostsRepository.ts | import IFeedPostsRepository from 'modules/selectedGame/domain/repositories/IFeedPostsRepository';
import FeedPostsRepository from 'modules/selectedGame/infra/repositories/FeedPostsRepository';
export default function makeFeedPostsRepository(): IFeedPostsRepository {
return new FeedPostsRepository();
}
|
raulrozza/Gametask_Mobile | src/modules/authentication/view/validation/Login.ts | import * as Yup from 'yup';
const LoginSchema = Yup.object().shape({
email: Yup.string()
.email('Digite um e-mail válido')
.required('Digite seu email'),
password: Yup.string().required('Digite sua senha'),
});
export default LoginSchema;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/Activities/styles.ts | import { Typography } from 'shared/view/components';
import styled from 'styled-components/native';
export const Container = styled.SafeAreaView`
background-color: ${({ theme }) => theme.palette.primary.main};
flex: 1;
padding: ${({ theme }) => theme.layout.spacing(3)};
justify-content: flex-start;
align-items: center;
padding-bottom: 46px;
`;
export const PageTitle = styled(Typography)`
color: ${({ theme }) => theme.palette.primary.contrast};
font-weight: bold;
font-size: 24px;
height: 32px;
width: 100%;
`;
export const Description = styled(Typography)`
color: ${({ theme }) => theme.palette.primary.contrast};
margin: ${({ theme }) => theme.layout.spacing(4, 0)};
text-align: center;
`;
export const ActivityContainer = {
View: styled.View`
width: 100%;
`,
Title: styled(Typography)`
color: ${({ theme }) => theme.palette.secondary.main};
font-weight: bold;
text-align: center;
font-size: 18px;
`,
};
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/services/RequestActivityService.ts | <reponame>raulrozza/Gametask_Mobile
import IRequestActivityDTO from 'modules/selectedGame/domain/dtos/IRequestActivityDTO';
import IRequestsRepository from 'modules/selectedGame/domain/repositories/IRequestsRepository';
interface IExecute {
shouldLogout?: boolean;
error?: string;
}
export default class RequestActivityService {
constructor(private requestsRepository: IRequestsRepository) {}
public async execute(payload: IRequestActivityDTO): Promise<IExecute> {
try {
await this.requestsRepository.activity(payload);
return {};
} catch (error) {
return {
error: error.message,
shouldLogout: error.shouldLogout,
};
}
}
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/AchievementDetails/index.tsx | <gh_stars>0
import React from 'react';
import { useRoute, useNavigation, RouteProp } from '@react-navigation/native';
import IAchievement from 'modules/selectedGame/domain/entities/IAchievement';
import {
Container,
Picture,
Name,
Title,
Description,
BackButton,
RequestButton,
} from './styles';
type AchievementParams = RouteProp<
{
achievementDetails: {
achievement: IAchievement & { obtained: boolean };
};
},
'achievementDetails'
>;
const AchievementDetails: React.FC = () => {
const {
params: { achievement },
} = useRoute<AchievementParams>();
const { goBack, navigate } = useNavigation();
return (
<Container>
<Picture image={achievement.image_url} obtained={achievement.obtained} />
<Name>{achievement.name}</Name>
{achievement.title && (
<Title>Garante o Título: {achievement.title.name}</Title>
)}
<Description>{achievement.description}</Description>
{!achievement.obtained && (
<RequestButton
onPress={() =>
navigate('requestAchievementUnlock', {
achievement,
})
}
>
Requisitar desbloqueio
</RequestButton>
)}
<BackButton.Button onPress={goBack}>
<BackButton.Text>Voltar</BackButton.Text>
</BackButton.Button>
</Container>
);
};
export default AchievementDetails;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/infra/repositories/factories/makePlayersRepository.ts | <reponame>raulrozza/Gametask_Mobile
import IPlayersRepository from 'modules/selectedGame/domain/repositories/IPlayersRepository';
import PlayersRepository from 'modules/selectedGame/infra/repositories/PlayersRepository';
export default function makePlayersRepository(): IPlayersRepository {
return new PlayersRepository();
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/PlayerProfile/components/index.ts | export { default as AchievementCard } from './AchievementCard';
export { default as AchievementList } from './AchievementList';
export { default as BasicLevelInfo } from './BasicLevelInfo';
export { default as Header } from './Header';
export { default as Options } from './Options';
export { default as ProgressBar } from './ProgressBar';
export { default as TitleSelect } from './TitleSelect';
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/infra/repositories/factories/makePlayersRepository.ts | import IPlayersRepository from 'modules/chooseGame/domain/repositories/IPlayersRepository';
import PlayersRepository from 'modules/chooseGame/infra/repositories/PlayersRepository';
export default function makePlayersRepository(): IPlayersRepository {
return new PlayersRepository();
}
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/view/pages/Lobby/components/index.ts | export { default as EmptyList } from './EmptyList';
export { default as Footer } from './Footer';
export { default as GameInfo } from './GameInfo';
export { default as ModalContent } from './ModalContent';
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/services/GetAchievementsService.ts | import IAchievement from 'modules/selectedGame/domain/entities/IAchievement';
import IAchievementsRepository from 'modules/selectedGame/domain/repositories/IAchievementsRepository';
interface IExecute {
achievements?: IAchievement[];
shouldLogout?: boolean;
error?: string;
}
export default class GetAchievementsService {
constructor(private achievementsRepository: IAchievementsRepository) {}
public async execute(): Promise<IExecute> {
try {
const achievements = await this.achievementsRepository.findAll();
return { achievements };
} catch (error) {
return {
error: error.message,
shouldLogout: error.shouldLogout,
};
}
}
}
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/view/pages/Lobby/components/ModalContent/index.tsx | import React, { useCallback, useMemo, useState } from 'react';
import { Modal } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import { BarCodeScannedCallback } from 'expo-barcode-scanner';
import Clipboard from 'expo-clipboard';
import makeCryptoProvider from 'modules/chooseGame/infra/providers/factories/makeCryptoProvider';
import Button from 'shared/view/components/Button';
import { useToastContext } from 'shared/view/contexts';
import { useCodeScannerPermission } from './hooks';
import {
Container,
Wrapper,
PasteGroup,
PageTitle,
ScannerContainer,
CodeScanner,
} from './styles';
interface IInvitationData {
gameId: string;
inviter: string;
}
interface ModalContentProps {
closeModal(): void;
}
const QRCODE_TYPE = 256;
const ModalContent: React.FC<ModalContentProps> = ({ closeModal }) => {
const [code, setCode] = useState('');
const [inviteData, setInviteData] = useState<IInvitationData | null>(null);
const scannerPermission = useCodeScannerPermission();
const [showScanner, setShowScanner] = useState(false);
const { navigate } = useNavigation();
const toast = useToastContext();
const crypto = useMemo(() => makeCryptoProvider(), []);
const decryptCode = useCallback(
(encrypted: string): IInvitationData | undefined => {
const decrypted = crypto.decrypt<IInvitationData>(encrypted);
if (!decrypted || !decrypted.gameId || !decrypted.inviter) {
toast.showError('Código de jogo inválido.');
return undefined;
}
return decrypted;
},
[crypto, toast],
);
const handleCodeScan = useCallback<BarCodeScannedCallback>(
({ data, type }) => {
if (Number(type) !== QRCODE_TYPE) return;
setShowScanner(false);
const inviteData = decryptCode(data);
if (!inviteData) return setInviteData(null);
setCode(data);
return setInviteData(inviteData);
},
[decryptCode],
);
const handleCodePaste = useCallback(async () => {
const clipboardText = await Clipboard.getStringAsync();
const inviteData = decryptCode(clipboardText);
if (!inviteData) return setInviteData(null);
setCode(clipboardText);
return setInviteData(inviteData);
}, [decryptCode]);
const handleSubmitInvitation = useCallback(async () => {
if (code === '' || !inviteData) return;
closeModal();
return navigate('GameInvite', {
gameId: inviteData.gameId,
inviterId: inviteData.inviter,
});
}, [code, inviteData, closeModal, navigate]);
return (
<Wrapper>
<Container>
<PageTitle>Entrar em um Jogo</PageTitle>
<PasteGroup.Container>
<PasteGroup.Input
value={code}
editable={false}
placeholder="Clique para colar da área de transferência"
/>
<PasteGroup.Button onPress={handleCodePaste} activeOpacity={0.6}>
<PasteGroup.Icon name="content-paste" />
</PasteGroup.Button>
</PasteGroup.Container>
{scannerPermission === 'granted' && (
<ScannerContainer>
<Modal
visible={showScanner}
statusBarTranslucent={true}
supportedOrientations={['portrait']}
>
<CodeScanner onBarCodeScanned={handleCodeScan} />
</Modal>
<Button
outline
onPress={() => setShowScanner(true)}
type="touchable-opacity"
>
Ler Código QR
</Button>
</ScannerContainer>
)}
<Button onPress={handleSubmitInvitation} type="touchable-opacity">
ENTRAR
</Button>
</Container>
</Wrapper>
);
};
export default ModalContent;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/Ranking/components/EmptyList/index.tsx | import React from 'react';
import { Container, Text } from './styles';
const EmptyList: React.FC = () => (
<Container>
<Text>
Opa... parece que não temos nenhum pontuador ainda. Que tal ser o
primeiro?
</Text>
</Container>
);
export default EmptyList;
|
raulrozza/Gametask_Mobile | src/shared/infra/providers/factories/makeHttpProvider.ts | <gh_stars>0
import IHTTPProvider from 'shared/domain/providers/IHTTPProvider';
import AxiosHTTPProvider from 'shared/infra/providers/AxiosHTTPProvider';
export default function makeHttpProvider(): IHTTPProvider {
const httpProvider = new AxiosHTTPProvider();
return httpProvider;
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/services/factories/makeGetActivitiesService.ts | import makeActivitiesRepository from 'modules/selectedGame/infra/repositories/factories/makeActivitiesRepository';
import GetActivitiesService from 'modules/selectedGame/services/GetActivitiesService';
export default function makeGetActivitiesService(): GetActivitiesService {
const repository = makeActivitiesRepository();
return new GetActivitiesService(repository);
}
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/view/pages/Lobby/components/EmptyList/index.tsx | <filename>src/modules/chooseGame/view/pages/Lobby/components/EmptyList/index.tsx
import React from 'react';
import { Container, Text } from './styles';
const EmptyList: React.FC = () => (
<Container>
<Text>Você ainda não está cadastrado em nenhum jogo.</Text>
</Container>
);
export default EmptyList;
|
raulrozza/Gametask_Mobile | src/@types/styled-components.d.ts | import 'styled-components';
import theme from 'config/theme';
declare module 'styled-components' {
type MyDefaultTheme = typeof theme;
export interface DefaultTheme extends MyDefaultTheme {}
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/Ranking/styles.ts | <reponame>raulrozza/Gametask_Mobile<filename>src/modules/selectedGame/view/pages/Ranking/styles.ts<gh_stars>0
import { darken } from 'polished';
import styled from 'styled-components/native';
export const Container = styled.SafeAreaView`
flex: 1;
background-color: ${({ theme }) => darken(0.05, theme.palette.primary.main)};
padding: ${({ theme }) => theme.layout.spacing(2)};
align-items: center;
`;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/AchievementDetails/styles.ts | <reponame>raulrozza/Gametask_Mobile
import { AchievementImage } from 'modules/selectedGame/view/components';
import { Button, Typography } from 'shared/view/components';
import styled, { css } from 'styled-components/native';
interface PictureProps {
obtained: boolean;
}
export const Container = styled.View`
justify-content: center;
align-items: center;
flex: 1;
background-color: ${({ theme }) => theme.palette.primary.main};
padding: ${({ theme }) => theme.layout.spacing(4)};
`;
export const Picture = styled(AchievementImage)<PictureProps>`
height: 150px;
width: 150px;
border-radius: 75px;
margin-bottom: ${({ theme }) => theme.layout.spacing(2)};
${({ obtained }) =>
!obtained &&
css`
opacity: 0.3;
`}
`;
export const Name = styled(Typography)`
font-size: 36px;
font-weight: bold;
color: ${({ theme }) => theme.palette.secondary.main};
margin-bottom: ${({ theme }) => theme.layout.spacing(2)};
text-align: center;
`;
export const Title = styled(Typography)`
font-size: 22px;
font-weight: bold;
color: ${({ theme }) => theme.palette.primary.dark};
margin-bottom: ${({ theme }) => theme.layout.spacing(2)};
text-align: center;
`;
export const Description = styled(Typography)`
font-size: 18px;
color: ${({ theme }) => theme.palette.primary.contrast};
text-align: center;
`;
export const RequestButton = styled(Button)`
margin-top: ${({ theme }) => theme.layout.spacing(2)};
width: 200px;
`;
export const BackButton = {
Button: styled.TouchableOpacity`
margin: ${({ theme }) => theme.layout.spacing(4, 0)};
`,
Text: styled(Typography)`
color: ${({ theme }) => theme.palette.secondary.main};
`,
};
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/infra/controllers/useGetUserController.ts | import makeGetUserService from 'modules/chooseGame/services/factories/makeGetUserService';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useSessionContext } from 'shared/view/contexts';
import { useToastContext } from 'shared/view/contexts';
import IUser from 'shared/domain/entities/IUser';
interface UserParams {
userId: string;
}
interface UseGetUserController {
loading: boolean;
user: IUser;
getUser(id: string): Promise<void>;
}
export default function useGetUserController({
userId,
}: UserParams): UseGetUserController {
const [loading, setLoading] = useState(true);
const [user, setUser] = useState<IUser>({} as IUser);
const getUserService = useMemo(() => makeGetUserService(), []);
const session = useSessionContext();
const toast = useToastContext();
const getUser = useCallback(
async (id: string) => {
setLoading(true);
const response = await getUserService.execute(id);
setLoading(false);
if (response.shouldLogout) return session.logout();
if (response.error) return toast.showError(response.error);
if (response.user) setUser(response.user);
},
[getUserService, session, toast],
);
useEffect(() => {
getUser(userId);
}, [getUser]); // eslint-disable-line react-hooks/exhaustive-deps
return {
loading,
user,
getUser,
};
}
|
raulrozza/Gametask_Mobile | src/config/theme/typography.ts | const typography = {
family: {
content: {
main: 'Roboto_400Regular',
bold: 'Roboto_700Bold',
},
title: {
main: 'OpenSans_400Regular',
bold: 'OpenSans_700Bold',
},
},
};
export default typography;
|
raulrozza/Gametask_Mobile | src/config/theme/layout.ts | <reponame>raulrozza/Gametask_Mobile<filename>src/config/theme/layout.ts
type Space = number | string;
interface Spacing {
(value: Space): string;
(vertical: Space, horizontal: Space): string;
(top: Space, horizontal: Space, bottom: Space): string;
(top: Space, right: Space, bottom: Space, left: Space): string;
}
const valueToString = (value: Space, factor: number): string => {
if (typeof value === 'string') return value;
return `${value * factor}px`;
};
const spacing = (factor: number): Spacing => (...args: Space[]) => {
const argsToString = args.map(arg => valueToString(arg, factor));
const spacingString = argsToString.join(' ');
return spacingString;
};
const layout = {
spacing: spacing(4),
breakpoints: {
xs: '0',
sm: '576px',
md: '768px',
lg: '992px',
xl: '1200px',
},
borderRadius: {
small: '4px',
medium: '16px',
},
};
export default layout;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/PlayerProfile/components/AchievementList/index.tsx | import React, { useCallback, useMemo } from 'react';
import { ActivityIndicator } from 'react-native';
import { useFocusEffect } from '@react-navigation/core';
import useGetAchievementsController from 'modules/selectedGame/infra/controllers/useGetAchievementsController';
import { usePlayerProfileContext } from 'modules/selectedGame/view/contexts';
import AchievementCard from '../AchievementCard';
import { addObtainedFieldToAchievements } from './helpers';
import { Container, Title } from './styles';
const AchievementList: React.FC = () => {
const { player } = usePlayerProfileContext();
const {
loading,
achievements,
getAchievements,
} = useGetAchievementsController();
const achievementsWithObtainedFlag = useMemo(
() => addObtainedFieldToAchievements(achievements, player),
[player, achievements],
);
useFocusEffect(
useCallback(() => {
getAchievements();
}, [getAchievements]),
);
if (loading) return <ActivityIndicator />;
if (achievementsWithObtainedFlag.length <= 0) return null;
return (
<Container>
<Title>Conquistas</Title>
{achievementsWithObtainedFlag.map(achievement => (
<AchievementCard key={achievement.id} achievement={achievement} />
))}
</Container>
);
};
export default AchievementList;
|
raulrozza/Gametask_Mobile | src/modules/authentication/view/pages/Login/components/SignupForm/index.tsx | import React from 'react';
import { Input, SubmitButton } from 'shared/view/components';
import Form from '../Form';
// Libs
import { Formik } from 'formik';
import useSignupController from 'modules/authentication/infra/controllers/useSignupController';
import SignupSchema, {
passwordsMatchValidation,
} from 'modules/authentication/view/validation/Signup';
import { signInTextStyle } from './styles';
const initialValues = {
firstname: '',
lastname: '',
email: '',
password: '',
confirmPassword: '',
};
interface SignupFormProps {
active: boolean;
}
const SignupForm: React.FC<SignupFormProps> = ({ active }) => {
const { loading, onSubmit } = useSignupController();
return (
<Formik
initialValues={initialValues}
validationSchema={SignupSchema}
validate={passwordsMatchValidation}
onSubmit={onSubmit}
>
<Form active={active}>
<Input
name="firstname"
textContentType="name"
placeholder="Nome"
autoCapitalize="words"
required
/>
<Input
name="lastname"
textContentType="familyName"
placeholder="Sobrenome"
autoCapitalize="words"
/>
<Input
name="email"
textContentType="emailAddress"
keyboardType="email-address"
placeholder="E-mail"
autoCapitalize="none"
required
/>
<Input
name="password"
textContentType="password"
placeholder="<PASSWORD>"
secureTextEntry
required
/>
<Input
name="confirmPassword"
textContentType="password"
placeholder="<PASSWORD>me a <PASSWORD>"
secureTextEntry
required
/>
<SubmitButton textStyle={signInTextStyle} loading={loading}>
Cadastrar
</SubmitButton>
</Form>
</Formik>
);
};
export default SignupForm;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/services/GetFeedPostsService.ts | <filename>src/modules/selectedGame/services/GetFeedPostsService.ts
import IFeedPost from 'modules/selectedGame/domain/entities/IFeedPost';
import IFeedPostsRepository from 'modules/selectedGame/domain/repositories/IFeedPostsRepository';
interface IExecute {
posts?: IFeedPost[];
shouldLogout?: boolean;
error?: string;
}
export default class GetFeedPostsService {
constructor(private feedPostsRepository: IFeedPostsRepository) {}
public async execute(): Promise<IExecute> {
try {
const posts = await this.feedPostsRepository.findAll();
return { posts };
} catch (error) {
return {
error: error.message,
shouldLogout: error.shouldLogout,
};
}
}
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/Activities/components/index.ts | export { default as ActivityCard } from './ActivityCard';
export { default as EmptyList } from './EmptyList';
|
raulrozza/Gametask_Mobile | src/shared/domain/providers/IStorageProvider.ts | <reponame>raulrozza/Gametask_Mobile
export default interface IStorageProvider {
clear(): Promise<void>;
delete(key: string): Promise<void>;
get<T = unknown>(key: string): Promise<T | null>;
store(key: string, data: unknown): Promise<void>;
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/contexts/PlayerProfileContext/hooks/usePlayerProfileContext.ts | import { createContext, useContext } from 'react';
import { isEmpty } from 'lodash';
import IPlayer from 'shared/domain/entities/IPlayer';
export interface IPlayerProfileContext {
player: IPlayer;
}
export const PlayerProfileContextProvider = createContext<IPlayerProfileContext>(
{} as IPlayerProfileContext,
);
const usePlayerProfileContext = (): IPlayerProfileContext => {
const playerProfileProvider = useContext(PlayerProfileContextProvider);
if (isEmpty(playerProfileProvider))
throw new Error(
'usePlayerProfileContext should be called inside a PlayerProfileContextProvider',
);
return playerProfileProvider;
};
export default usePlayerProfileContext;
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/Feed/components/FeedText/index.ts | <filename>src/modules/selectedGame/view/pages/Feed/components/FeedText/index.ts
import styled from 'styled-components/native';
const FeedText = {
Text: styled.Text`
color: ${({ theme }) => theme.palette.primary.contrast};
line-height: 24px;
flex-wrap: wrap;
`,
Name: styled.Text`
color: ${({ theme }) => theme.palette.secondary.dark};
font-weight: bold;
`,
Activity: styled.Text`
color: ${({ theme }) => theme.palette.secondary.main};
font-weight: bold;
text-transform: uppercase;
flex-wrap: wrap;
`,
Bold: styled.Text`
font-weight: bold;
`,
};
export default FeedText;
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/services/factories/makeGetGameService.ts | import makeGamesRepository from 'modules/chooseGame/infra/repositories/factories/makeGamesRepository';
import GetGameService from 'modules/chooseGame/services/GetGameService';
export default function makeGetGameService(): GetGameService {
const repository = makeGamesRepository();
return new GetGameService(repository);
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/PlayerProfile/components/BasicLevelInfo/helpers/getPlayerNextLevel.ts | <reponame>raulrozza/Gametask_Mobile<gh_stars>0
import ILevelInfo from 'shared/domain/entities/ILevelInfo';
export default function getPlayerNextLevel(
currentLevel: number,
levelInfo: ILevelInfo[],
): ILevelInfo | undefined {
const descSortedLevelInfo = levelInfo.sort((a, b) => a.level - b.level);
const nextLevelToGain = descSortedLevelInfo.find(
info => currentLevel < info.level,
);
return nextLevelToGain;
}
|
raulrozza/Gametask_Mobile | src/modules/selectedGame/view/pages/PlayerProfile/components/BasicLevelInfo/styles.ts | <filename>src/modules/selectedGame/view/pages/PlayerProfile/components/BasicLevelInfo/styles.ts
import { UserImage } from 'modules/selectedGame/view/components';
import { Typography } from 'shared/view/components';
import styled from 'styled-components/native';
export const Container = styled.View`
width: 100%;
align-items: center;
`;
export const Picture = styled(UserImage)`
border-radius: 75px;
border-width: 6px;
border-color: ${({ theme }) => theme.palette.primary.dark};
width: 150px;
height: 150px;
margin-top: ${({ theme }) => theme.layout.spacing(3)};
`;
export const LevelInfo = {
View: styled.View`
min-width: 64px;
max-width: 128px;
margin-top: ${({ theme }) => theme.layout.spacing(4)};
background-color: gold;
border-width: 6px;
border-top-color: darkgoldenrod;
border-left-color: darkgoldenrod;
border-bottom-color: goldenrod;
border-right-color: goldenrod;
padding: ${({ theme }) => theme.layout.spacing(1)};
justify-content: center;
align-items: center;
`,
Text: styled(Typography)`
color: goldenrod;
font-weight: bold;
font-size: 36px;
`,
Exp: styled(Typography)`
text-align: center;
`,
};
export const BarContainer = styled.View`
margin-top: ${({ theme }) => theme.layout.spacing(4)};
width: 80%;
`;
export const NextLevel = {
Container: styled.View`
width: 80%;
flex-direction: row;
justify-content: flex-end;
padding: ${({ theme }) => theme.layout.spacing(0, 3)};
margin-bottom: ${({ theme }) => theme.layout.spacing(4)};
`,
Text: styled(Typography)`
color: ${({ theme }) => theme.palette.primary.contrast};
`,
};
|
raulrozza/Gametask_Mobile | src/modules/chooseGame/services/factories/makeGetUserService.ts | import makeUsersRepository from 'modules/chooseGame/infra/repositories/factories/makeUsersRepository';
import GetUserService from 'modules/chooseGame/services/GetUserService';
export default function makeGetUserService(): GetUserService {
const repository = makeUsersRepository();
return new GetUserService(repository);
}
|