Skip to content

Commit

Permalink
fix: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KestasVenslauskas committed Oct 28, 2024
1 parent ad746de commit e1c9be1
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 13 deletions.
2 changes: 2 additions & 0 deletions app/Theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ interface Dictionary {
error_no_search_query: string;
daily_question_vote: string;
close: string;
stream_blocked_warning: string;
}

export const strings: Dictionary = {
Expand Down Expand Up @@ -92,6 +93,7 @@ export const strings: Dictionary = {
error_no_search_query: 'Įveskite paieškos tekstą',
daily_question_vote: 'BALSUOTI',
close: 'Uždaryti',
stream_blocked_warning: 'Transliacija internetu negalima dėl autorių teisių apribojimų.',
};
//#endregion

Expand Down
1 change: 1 addition & 0 deletions app/api/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export type VideoDataLiveStream = {
content: string;
content2?: string;
audio?: string;
restriction?: string;
};
};
};
Expand Down
22 changes: 21 additions & 1 deletion app/car/BaseListTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {CarPlay, ListTemplate} from 'react-native-carplay';
import {AlertTemplate, CarPlay, ListTemplate} from 'react-native-carplay';
import {PlayListItem} from './types';
import TrackPlayer, {PitchAlgorithm} from 'react-native-track-player';
import {carPlayNowPlayingTemplate} from './nowPlaying/createNowPlayingTemplate';
import {strings} from '../Theme';

export type PlaylistProvider = () => Promise<PlayListItem[]>;

Expand All @@ -12,6 +13,20 @@ export type BaseListTemplateOptions = {
id: string;
};

const streamWarningAlert = new AlertTemplate({
id: 'stream-blocked-alert',
onActionButtonPressed: async (_) => {
CarPlay.dismissTemplate();
},
titleVariants: [strings.stream_blocked_warning],
actions: [
{
id: 'close',
title: 'Uždaryti',
},
],
});

export class BaseListTemplate {
playlistProvider: PlaylistProvider;
options: BaseListTemplateOptions;
Expand All @@ -24,6 +39,11 @@ export class BaseListTemplate {

async onItemSelectHandler(item: PlayListItem, allItems: PlayListItem[]) {
console.log('### onItemSelect', item.id);

if (item.isDisabled) {
CarPlay.presentTemplate(streamWarningAlert);
return;
}
const index = allItems.indexOf(item);

await TrackPlayer.setQueue(
Expand Down
3 changes: 2 additions & 1 deletion app/car/live/LiveTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class LiveTemplate extends BaseListTemplate {
const items: PlayListItem[] = data.map((stream) => ({
id: stream.mediaId,
text: stream.channelTitle ?? stream.title,
// detailText: stream.title,
// detailText: stream.isBlocked ? strings.stream_blocked_warning : undefined,
imgUrl: getImageByChannelId(stream.poster),
streamUrl: stream.streamUri,
isDisabled: stream.isBlocked,
isLiveStream: true,
}));
return items;
Expand Down
1 change: 1 addition & 0 deletions app/car/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export type PlayListItem = {
imgUrl?: string;
streamUrl: string;
isLiveStream?: boolean;
isDisabled?: boolean;
};
11 changes: 5 additions & 6 deletions app/components/article/article/ArticleComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ const ArticleComponent: React.FC<React.PropsWithChildren<Props>> = ({
</View>
<View style={style.categoryTitleContainer}>
{mediaIcon}
<View style={style.dateContainer}>
<TextComponent style={style.categoryTitle}>{article.category_title}</TextComponent>
{date}
</View>
<TextComponent style={style.categoryTitle}>{article.category_title}</TextComponent>
{date}
</View>
{badge}

Expand Down Expand Up @@ -167,7 +165,7 @@ const styles = StyleSheet.create({
marginEnd: 4,
},
categoryTitle: {
fontSize: 12,
fontSize: 12.5,
paddingEnd: 6,
},
categoryTitleContainer: {
Expand All @@ -182,14 +180,15 @@ const styles = StyleSheet.create({
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
flexWrap: 'wrap',
},
title: {
marginTop: 4,
fontSize: 22,
},
subtitle: {
marginTop: 8,
fontSize: 13.5,
fontSize: 14.5,
},
mediaIndicator: {
position: 'absolute',
Expand Down
4 changes: 2 additions & 2 deletions app/components/article/articleFeedItem/ArticleFeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const styles = StyleSheet.create({
width: 110,
},
categoryTitle: {
fontSize: 11,
fontSize: 12,
paddingEnd: 6,
},
dateContainer: {
Expand All @@ -97,6 +97,6 @@ const styles = StyleSheet.create({
alignItems: 'center',
},
subtitle: {
fontSize: 11,
fontSize: 12,
},
});
2 changes: 2 additions & 0 deletions app/components/videoComponent/fetchStreamData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const fetchStreamData = ({
poster: poster,
mediaId: data.content,
offset: undefined,
isBlocked: !!data.restriction,
};
return streamData;
} else {
Expand All @@ -42,6 +43,7 @@ export const fetchStreamData = ({
title: response.title,
offset: response.offset,
poster: poster ?? playlist_item.image ? BASE_IMG_URL + playlist_item.image : undefined,
isBlocked: false,
tracks: playlist_item.tracks?.map((track) => ({
...track,
src: track.src.startsWith('http') ? track.src : BASE_IMG_URL + track.src,
Expand Down
1 change: 1 addition & 0 deletions app/components/videoComponent/useStreamData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type StreamData = {
poster?: string;
mediaType?: MediaType;
tracks?: VideoTextTrack[];
isBlocked?: boolean;
};

type VideoState = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {EVENT_SELECT_CATEGORY_INDEX} from '../../../../constants';
import {MainStackParamList} from '../../../../navigation/MainStack';
import {useTheme} from '../../../../Theme';
import {PagingState} from '../../../../state/article_store';
import {useSafeAreaInsets} from 'react-native-safe-area-context';

interface Props {
data: PagingState;
Expand All @@ -40,6 +41,8 @@ const SimpleArticleScreenContent: React.FC<React.PropsWithChildren<Props>> = ({
const navigation = useNavigation<StackNavigationProp<MainStackParamList>>();
const listRef = useRef<FlashList<any>>(null);

const insets = useSafeAreaInsets();

useEffect(() => {
//Scroll to top when it's finished refreshing
if (!isRefreshing) {
Expand Down Expand Up @@ -110,6 +113,7 @@ const SimpleArticleScreenContent: React.FC<React.PropsWithChildren<Props>> = ({
showsVerticalScrollIndicator={false}
//style={styles.container}
data={articles}
contentContainerStyle={{paddingBottom: insets.bottom}}
ListHeaderComponent={showTitle ? renderTitle() : null}
//windowSize={4}
estimatedItemSize={320}
Expand Down
6 changes: 3 additions & 3 deletions app/state/article_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export const useArticleStore = create<ArticleStore>((set, get) => ({
);
try {
const data = await fetchPopularApi(page, count);
const formattedArticles = formatArticles(-1, data.articles);
const formattedArticles = formatArticles(-1, data.articles, false);
const articles = withOverride ? formattedArticles : get().popular.articles.concat(formattedArticles);
set({
popular: {
Expand Down Expand Up @@ -288,7 +288,7 @@ export const useArticleStore = create<ArticleStore>((set, get) => ({
);
try {
const data = await fetchNewestApi(page, count, date_max, not_id);
const formattedArticles = formatArticles(-1, data.articles);
const formattedArticles = formatArticles(-1, data.articles, false);
const articles = withOverride ? formattedArticles : get().newest.articles.concat(formattedArticles);
set({
newest: {
Expand Down Expand Up @@ -333,7 +333,7 @@ export const useArticleStore = create<ArticleStore>((set, get) => ({

try {
const data = await fetchCategoryApi(categoryId, page, count, date_max, not_id);
const formattedArticles = formatArticles(-1, data.articles);
const formattedArticles = formatArticles(-1, data.articles, false);

const categoryArticles: Article[][] = get().categories[categoryId]?.articles ?? [];
const newCategoryarticles = withOverride
Expand Down

0 comments on commit e1c9be1

Please sign in to comment.