Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/common/src/services/remote-config/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum FeatureFlags {
NOW_PLAYING_COMMENTS = 'now_playing_comments',
TRACK_TILE_WAVEFORM = 'track_tile_waveform',
NOW_PLAYING_WAVEFORM = 'now_playing_waveform',
NOW_PLAYING_VISUALIZER = 'now_playing_visualizer',
MOBILE_MANAGER_MODE = 'mobile_manager_mode',
BULK_TRACK_EDIT = 'bulk_track_edit',
WEEKLY_ARTIST_RECAP = 'weekly_artist_recap',
Expand All @@ -39,6 +40,7 @@ export const environmentFlagDefaults: Record<
[FeatureFlags.FAN_CLUB_TEXT_POST_POSTING]: true,
[FeatureFlags.TRACK_TILE_WAVEFORM]: true,
[FeatureFlags.NOW_PLAYING_WAVEFORM]: true,
[FeatureFlags.NOW_PLAYING_VISUALIZER]: true,
[FeatureFlags.MOBILE_MANAGER_MODE]: true,
[FeatureFlags.BULK_TRACK_EDIT]: true,
[FeatureFlags.WEEKLY_ARTIST_RECAP]: true,
Expand Down Expand Up @@ -70,6 +72,7 @@ export const flagDefaults: FlagDefaults = {
[FeatureFlags.NOW_PLAYING_COMMENTS]: true,
[FeatureFlags.TRACK_TILE_WAVEFORM]: false,
[FeatureFlags.NOW_PLAYING_WAVEFORM]: true,
[FeatureFlags.NOW_PLAYING_VISUALIZER]: false,
[FeatureFlags.MOBILE_MANAGER_MODE]: false,
[FeatureFlags.BULK_TRACK_EDIT]: false,
[FeatureFlags.WEEKLY_ARTIST_RECAP]: false,
Expand Down
3 changes: 3 additions & 0 deletions packages/mobile/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

# Vendored react-native-collapsible-tab-view 8.0.1, kept close to upstream
src/components/collapsible-tabs/**

# Generated by scripts/generate-visualizer-libs.js
src/components/now-playing-panel/visualizerLibs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
43C373D295154DA6B89272D5 /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 04F6B3542BF84180BC937315 /* Colors.xcassets */; };
5983D8FED74747CCA45F8FC4 /* AvenirNextLTPro-Medium.otf in Resources */ = {isa = PBXBuildFile; fileRef = 33E11CC84EEA4109B8A1AE2C /* AvenirNextLTPro-Medium.otf */; };
5CE1A0022EA1000000A1B2C3 /* SceneDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE1A0012EA1000000A1B2C3 /* SceneDelegate.mm */; };
5CE1B0022EA1000000A1B2C3 /* AudiusHinge.m in Sources */ = {isa = PBXBuildFile; fileRef = 5CE1B0012EA1000000A1B2C3 /* AudiusHinge.m */; };
7103C3ED2929C6B5002B9072 /* BootSplash.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7103C3EC2929C6B5002B9072 /* BootSplash.storyboard */; };
717F36E82733C73F0017511F /* AvenirNextLTPro-DemiBold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 717F36E72733C73F0017511F /* AvenirNextLTPro-DemiBold.otf */; };
838AABE023CE3813004B2DA3 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 838AABDF23CE3813004B2DA3 /* GoogleService-Info.plist */; };
Expand Down Expand Up @@ -78,6 +79,8 @@
453FC09EC343ACA359EB312C /* Pods-AudiusReactNative.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AudiusReactNative.release.xcconfig"; path = "Target Support Files/Pods-AudiusReactNative/Pods-AudiusReactNative.release.xcconfig"; sourceTree = "<group>"; };
5CE1A0002EA1000000A1B2C3 /* SceneDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SceneDelegate.h; path = AudiusReactNative/SceneDelegate.h; sourceTree = "<group>"; };
5CE1A0012EA1000000A1B2C3 /* SceneDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SceneDelegate.mm; path = AudiusReactNative/SceneDelegate.mm; sourceTree = "<group>"; };
5CE1B0002EA1000000A1B2C3 /* AudiusHinge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudiusHinge.h; path = AudiusReactNative/AudiusHinge.h; sourceTree = "<group>"; };
5CE1B0012EA1000000A1B2C3 /* AudiusHinge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AudiusHinge.m; path = AudiusReactNative/AudiusHinge.m; sourceTree = "<group>"; };
622045C334F0F16E3CF4011F /* libPods-AudiusReactNative.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AudiusReactNative.a"; sourceTree = BUILT_PRODUCTS_DIR; };
6F65A9A9BAD047FABD240C59 /* AvenirNextLTPro-Regular.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "AvenirNextLTPro-Regular.otf"; path = "../src/assets/fonts/AvenirNextLTPro-Regular.otf"; sourceTree = "<group>"; };
7103C3EC2929C6B5002B9072 /* BootSplash.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = BootSplash.storyboard; path = AudiusReactNative/BootSplash.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -145,6 +148,8 @@
13B07FB01A68108700A75B9A /* AppDelegate.mm */,
5CE1A0002EA1000000A1B2C3 /* SceneDelegate.h */,
5CE1A0012EA1000000A1B2C3 /* SceneDelegate.mm */,
5CE1B0002EA1000000A1B2C3 /* AudiusHinge.h */,
5CE1B0012EA1000000A1B2C3 /* AudiusHinge.m */,
13B07FB51A68108700A75B9A /* Images.xcassets */,
13B07FB61A68108700A75B9A /* Info.plist */,
7103C3EC2929C6B5002B9072 /* BootSplash.storyboard */,
Expand Down Expand Up @@ -475,6 +480,7 @@
253BCCFA2B324974007DC74C /* NSureSDK.m in Sources */,
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */,
5CE1A0022EA1000000A1B2C3 /* SceneDelegate.mm in Sources */,
5CE1B0022EA1000000A1B2C3 /* AudiusHinge.m in Sources */,
83F7359F23C55C2D0040A4C5 /* AirplayViewManager.m in Sources */,
13B32CE723D2782B002F0526 /* SampleSwiftFile.swift in Sources */,
83F735A523C64C950040A4C5 /* AirplayEvent.m in Sources */,
Expand Down
11 changes: 11 additions & 0 deletions packages/mobile/ios/AudiusReactNative/AudiusHinge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface AudiusHinge : NSObject

+ (void)observeHingeForView:(UIView *)view;

@end

NS_ASSUME_NONNULL_END
108 changes: 108 additions & 0 deletions packages/mobile/ios/AudiusReactNative/AudiusHinge.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#import "AudiusHinge.h"

#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>

static NSString *const AudiusHingeDidChangeNotification = @"AudiusHingeDidChange";
static NSDictionary *latestHingeState = nil;

@interface AudiusHingeEmitter : RCTEventEmitter <RCTBridgeModule>
@end

@implementation AudiusHinge

+ (void)observeHingeForView:(UIView *)view
{
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 270100
if (@available(iOS 27.1, *)) {
UIHingeInteraction *interaction = [[UIHingeInteraction alloc]
initWithUpdateHandler:^(UIHingeInteraction *_, UIHingeInteractionUpdate *update) {
UIHinge *hinge = update.hinge;
NSDictionary *state;
if (hinge == nil) {
state = @{@"available" : @NO};
} else {
NSString *status;
switch (hinge.status) {
case UIHingeStatusClosed:
status = @"closed";
break;
case UIHingeStatusPartiallyOpen:
status = @"partiallyOpen";
break;
case UIHingeStatusFullyOpen:
status = @"fullyOpen";
break;
default:
status = @"unknown";
break;
}
state = @{
@"available" : @YES,
@"status" : status,
@"angle" : @(hinge.angle * 180.0 / M_PI)
};
}
latestHingeState = state;
[[NSNotificationCenter defaultCenter] postNotificationName:AudiusHingeDidChangeNotification
object:nil
userInfo:state];
}];
[view addInteraction:interaction];
}
#endif
}

@end

@implementation AudiusHingeEmitter {
BOOL _hasListeners;
}

RCT_EXPORT_MODULE(AudiusHinge);

+ (BOOL)requiresMainQueueSetup
{
return YES;
}

- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}

- (NSArray<NSString *> *)supportedEvents
{
return @[ @"hingeChanged" ];
}

- (void)startObserving
{
_hasListeners = YES;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(hingeDidChange:)
name:AudiusHingeDidChangeNotification
object:nil];
}

- (void)stopObserving
{
_hasListeners = NO;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)hingeDidChange:(NSNotification *)notification
{
if (_hasListeners) {
[self sendEventWithName:@"hingeChanged" body:notification.userInfo];
}
}

RCT_EXPORT_METHOD(getState
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject)
{
resolve(latestHingeState ?: @{@"available" : @NO});
}

@end
2 changes: 2 additions & 0 deletions packages/mobile/ios/AudiusReactNative/SceneDelegate.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "SceneDelegate.h"
#import "AppDelegate.h"
#import "AudiusHinge.h"

#import <React/RCTLinkingManager.h>
#import <TiktokOpensdkReactNative-Bridging-Header.h>
Expand All @@ -16,6 +17,7 @@ - (void)scene:(UIScene *)scene

AppDelegate *appDelegate = (AppDelegate *)UIApplication.sharedApplication.delegate;
self.window = [appDelegate loadReactNativeWindowInScene:(UIWindowScene *)scene connectionOptions:connectionOptions];
[AudiusHinge observeHingeForView:self.window];

// React Native reads the launch URL from launchOptions. TikTok still needs
// to see it here.
Expand Down
22 changes: 22 additions & 0 deletions packages/mobile/scripts/generate-visualizer-libs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const fs = require('fs')
const path = require('path')

const read = (request) =>
fs
.readFileSync(require.resolve(request), 'utf8')
.replace(/<\/script/gi, '<\\/script')

const output = path.resolve(
__dirname,
'../src/components/now-playing-panel/visualizerLibs.ts'
)

fs.writeFileSync(
output,
[
`export const butterchurnSource = ${JSON.stringify(read('butterchurn/lib/butterchurn.min.js'))}`,
'',
`export const butterchurnPresetsSource = ${JSON.stringify(read('butterchurn-presets/lib/butterchurnPresetsMinimal.min.js'))}`,
''
].join('\n')
)
27 changes: 11 additions & 16 deletions packages/mobile/src/components/bottom-tab-bar/BottomTabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import type {
BottomTabBarProps as RNBottomTabBarProps
} from '@react-navigation/bottom-tabs'
import type { NavigationHelpers, ParamListBase } from '@react-navigation/native'
import {
Animated,
Pressable,
StyleSheet,
useWindowDimensions
} from 'react-native'
import { Animated, Pressable, StyleSheet } from 'react-native'
import type { SharedValue } from 'react-native-reanimated'
import Reanimated, {
interpolate,
Expand All @@ -24,8 +19,9 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { Flex, IconSearch } from '@audius/harmony-native'
import { GlassSurface } from 'app/components/core/Screen/GlassSurface'
import { LiquidGlassView } from 'app/components/core/Screen/LiquidGlass'
import { FULL_DRAWER_HEIGHT } from 'app/components/drawer'
import { useFullDrawerHeight } from 'app/components/drawer'
import { PLAY_BAR_HEIGHT } from 'app/components/now-playing-drawer'
import { useContentWidth } from 'app/hooks/useContentWidth'
import {
useIsTabBarCollapsed,
useTabBarHiddenProgress
Expand Down Expand Up @@ -61,18 +57,16 @@ export const bottomTabBarButtons = {

const interpolatePostion = (
translationAnim: Animated.Value,
bottomInset: number
bottomInset: number,
fullDrawerHeight: number
) => ({
transform: [
{
translateY: translationAnim.interpolate({
inputRange: [
0,
FULL_DRAWER_HEIGHT -
bottomInset -
BOTTOM_BAR_HEIGHT -
PLAY_BAR_HEIGHT,
FULL_DRAWER_HEIGHT
fullDrawerHeight - bottomInset - BOTTOM_BAR_HEIGHT - PLAY_BAR_HEIGHT,
fullDrawerHeight
],
outputRange: [bottomInset + BOTTOM_BAR_HEIGHT, 0, 0]
})
Expand All @@ -97,6 +91,7 @@ export const BottomTabBar = (props: BottomTabBarProps) => {
const { translationAnim, navigation, state } = props
const { routes, index: activeIndex } = state
const insets = useSafeAreaInsets()
const fullDrawerHeight = useFullDrawerHeight()
const floating = useFloatingTabBar()

const handlePress = useCallback(
Expand Down Expand Up @@ -153,7 +148,7 @@ export const BottomTabBar = (props: BottomTabBarProps) => {
style={[
styles.floatingRoot,
{ height: BOTTOM_BAR_HEIGHT + insets.bottom },
interpolatePostion(translationAnim, insets.bottom)
interpolatePostion(translationAnim, insets.bottom, fullDrawerHeight)
]}
>
<FloatingPill
Expand All @@ -172,7 +167,7 @@ export const BottomTabBar = (props: BottomTabBarProps) => {
<Animated.View
style={[
{ zIndex: 4, elevation: 4 },
interpolatePostion(translationAnim, insets.bottom)
interpolatePostion(translationAnim, insets.bottom, fullDrawerHeight)
]}
>
{/*
Expand Down Expand Up @@ -207,7 +202,7 @@ const FloatingPill = (props: FloatingPillProps) => {
const { bottom, activeIndex, tabCount, onPressSearch, children } = props
const isDarkMode = isDarkTheme(useThemeVariant())
const colorScheme = isDarkMode ? 'dark' : 'light'
const { width: windowWidth } = useWindowDimensions()
const windowWidth = useContentWidth()
const hidden = useTabBarHiddenProgress()
const isCollapsed = useIsTabBarCollapsed()
const index = useSharedValue(activeIndex)
Expand Down
5 changes: 3 additions & 2 deletions packages/mobile/src/components/collapsible-tabs/Container.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { StyleSheet, useWindowDimensions, View } from 'react-native'
import { StyleSheet, View } from 'react-native'
import PagerView from 'react-native-pager-view'
import Animated, {
useAnimatedReaction,
Expand Down Expand Up @@ -32,6 +32,7 @@ import {
IndexChangeEventData,
TabName
} from './types'
import { useContentWidth } from 'app/hooks/useContentWidth'

const AnimatedPagerView = Animated.createAnimatedComponent(PagerView)

Expand Down Expand Up @@ -67,7 +68,7 @@ export const Container = React.memo(

const [refMap, setRef] = useAnimatedDynamicRefs()

const windowWidth = useWindowDimensions().width
const windowWidth = useContentWidth()
const width = customWidth ?? windowWidth

const [containerHeight, getContainerLayoutHeight] = useLayoutHeight()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useLayoutEffect } from 'react'
import {
StyleSheet,
useWindowDimensions,
LayoutChangeEvent
} from 'react-native'
import Animated, {
Expand All @@ -18,6 +17,7 @@ import { Indicator } from './Indicator'
import { MaterialTabItem } from './TabItem'
import { MaterialTabBarProps, ItemLayout } from './types'
import { TabName } from '../types'
import { useContentWidth } from 'app/hooks/useContentWidth'

export const TABBAR_HEIGHT = 48

Expand All @@ -41,7 +41,7 @@ const MaterialTabBar = <T extends TabName = TabName>({
keepActiveTabCentered
}: MaterialTabBarProps<T>): React.ReactElement => {
const tabBarRef = useAnimatedRef<Animated.ScrollView>()
const windowWidth = useWindowDimensions().width
const windowWidth = useContentWidth()
const width = customWidth ?? windowWidth
const isFirstRender = React.useRef(true)
const itemLayoutGathering = React.useRef(new Map<T, ItemLayout>())
Expand Down
10 changes: 7 additions & 3 deletions packages/mobile/src/components/drawer/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { makeStyles } from 'app/styles'
import { attachToDy } from 'app/utils/animation'

import { DrawerHeader } from './DrawerHeader'
import { FULL_DRAWER_HEIGHT } from './constants'
import { getFullDrawerHeight, useFullDrawerHeight } from './constants'

const MAX_SHADOW_OPACITY = 0.15
const ON_MOVE_RESPONDER_DY = 10
Expand Down Expand Up @@ -152,8 +152,10 @@ export const springToValue = ({
friction = 25
break
case DrawerAnimationStyle.SPRINGY:
tension = 70 + 60 * (1 - Math.min(drawerHeight / FULL_DRAWER_HEIGHT, 1))
friction = 10 + 2 * (1 - Math.min(drawerHeight / FULL_DRAWER_HEIGHT, 1))
tension =
70 + 60 * (1 - Math.min(drawerHeight / getFullDrawerHeight(), 1))
friction =
10 + 2 * (1 - Math.min(drawerHeight / getFullDrawerHeight(), 1))
break
}
Animated.spring(animation, {
Expand Down Expand Up @@ -203,6 +205,7 @@ export const Drawer: DrawerComponent = ({
}: DrawerProps) => {
const styles = useStyles()
const insets = useSafeAreaInsets()
const FULL_DRAWER_HEIGHT = useFullDrawerHeight()

const [drawerHeight, setDrawerHeight] = useState(
isFullscreen ? FULL_DRAWER_HEIGHT : 0
Expand Down Expand Up @@ -506,6 +509,7 @@ export const Drawer: DrawerComponent = ({
}
}),
[
FULL_DRAWER_HEIGHT,
translationAnim,
drawerHeight,
initialOffsetOpenPosition,
Expand Down
Loading
Loading