From 9134d03e8046cc1ea2c9e1fd69797f431f252630 Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Date: Thu, 25 Jan 2024 18:51:53 -0300 Subject: [PATCH 1/4] [menu-bar] Migrate ProgressIndicator to Expo Modules --- .../ProgressIndicatorManager.h | 12 --- .../ProgressIndicatorManager.m | 45 --------- .../ExpoMenuBar-macOS/ProgressIndicatorView.h | 10 -- .../ExpoMenuBar-macOS/ProgressIndicatorView.m | 98 ------------------- .../ExpoMenuBar.xcodeproj/project.pbxproj | 12 --- apps/menu-bar/macos/Podfile.lock | 6 ++ .../expo-module.config.json | 6 ++ .../modules/progress-indicator/index.ts | 3 + .../ios/ProgressIndicator.podspec | 21 ++++ .../ios/ProgressIndicatorModule.swift | 17 ++++ .../ios/ProgressIndicatorView.swift | 36 +++++++ .../src/ProgressIndicator.types.ts | 7 ++ .../src/ProgressIndicatorView.tsx | 50 ++++++++++ .../src/ProgressIndicatorView.web.tsx | 10 ++ .../components/ProgressIndicator/index.tsx | 44 --------- .../ProgressIndicator/index.web.tsx | 5 - apps/menu-bar/src/popover/BuildsSection.tsx | 2 +- 17 files changed, 157 insertions(+), 227 deletions(-) delete mode 100644 apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorManager.h delete mode 100644 apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorManager.m delete mode 100644 apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorView.h delete mode 100644 apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorView.m create mode 100644 apps/menu-bar/modules/progress-indicator/expo-module.config.json create mode 100644 apps/menu-bar/modules/progress-indicator/index.ts create mode 100644 apps/menu-bar/modules/progress-indicator/ios/ProgressIndicator.podspec create mode 100644 apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorModule.swift create mode 100644 apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorView.swift create mode 100644 apps/menu-bar/modules/progress-indicator/src/ProgressIndicator.types.ts create mode 100644 apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.tsx create mode 100644 apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.web.tsx delete mode 100644 apps/menu-bar/src/components/ProgressIndicator/index.tsx delete mode 100644 apps/menu-bar/src/components/ProgressIndicator/index.web.tsx diff --git a/apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorManager.h b/apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorManager.h deleted file mode 100644 index 1321005e..00000000 --- a/apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorManager.h +++ /dev/null @@ -1,12 +0,0 @@ -#import - -@interface RCTConvert (UIActivityIndicatorView) - -+ (UIActivityIndicatorViewStyle)UIActivityIndicatorViewStyle:(id)json; - -@end - -@interface ProgressIndicatorManager : RCTViewManager - -@end - diff --git a/apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorManager.m b/apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorManager.m deleted file mode 100644 index ff872c72..00000000 --- a/apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorManager.m +++ /dev/null @@ -1,45 +0,0 @@ -#import -#import -#import - -#import "ProgressIndicatorManager.h" -#import "ProgressIndicatorView.h" - -@implementation RCTConvert (UIActivityIndicatorView) - -RCT_ENUM_CONVERTER( - UIActivityIndicatorViewStyle, - (@{ - @"large" : @(UIActivityIndicatorViewStyleLarge), - @"small" : @(UIActivityIndicatorViewStyleMedium), - }), - UIActivityIndicatorViewStyleLarge, - integerValue) - -@end - -@implementation ProgressIndicatorManager - -RCT_EXPORT_MODULE() - -- (RCTPlatformView *)view -{ - return [ProgressIndicatorView new]; -} - -RCT_EXPORT_VIEW_PROPERTY(color, UIColor) -RCT_EXPORT_VIEW_PROPERTY(indeterminate, BOOL) -RCT_EXPORT_VIEW_PROPERTY(progress, double) -RCT_CUSTOM_VIEW_PROPERTY(size, UIActivityIndicatorViewStyle, ProgressIndicatorView) -{ - /* - Setting activityIndicatorViewStyle overrides the color, so restore the original color - after setting the indicator style. - */ - RCTUIColor *oldColor = view.color; - view.activityIndicatorViewStyle = - json ? [RCTConvert UIActivityIndicatorViewStyle:json] : defaultView.activityIndicatorViewStyle; - view.color = oldColor; -} - -@end diff --git a/apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorView.h b/apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorView.h deleted file mode 100644 index dd33aa98..00000000 --- a/apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorView.h +++ /dev/null @@ -1,10 +0,0 @@ -#import - -@interface ProgressIndicatorView : UIActivityIndicatorView - -@property(nonatomic, assign) UIActivityIndicatorViewStyle activityIndicatorViewStyle; -@property(nullable, readwrite, nonatomic, strong) RCTUIColor *color; -- (void)startAnimating; -- (void)stopAnimating; - -@end diff --git a/apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorView.m b/apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorView.m deleted file mode 100644 index f7149964..00000000 --- a/apps/menu-bar/macos/ExpoMenuBar-macOS/ProgressIndicatorView.m +++ /dev/null @@ -1,98 +0,0 @@ -#import -#import - -#import "ProgressIndicatorView.h" - -@implementation ProgressIndicatorView - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) { - self.style = NSProgressIndicatorStyleBar; - self.displayedWhenStopped = YES; - [self setMinValue:0.0]; - [self setMaxValue:100.0]; - } - return self; -} - -- (void)startAnimating -{ - [self setWantsLayer:YES]; - [super startAnimation:self]; -} - -- (void)stopAnimating -{ - [super stopAnimation:self]; -} - -- (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle -{ - _activityIndicatorViewStyle = activityIndicatorViewStyle; - - switch (activityIndicatorViewStyle) { - case UIActivityIndicatorViewStyleLarge: - self.controlSize = NSControlSizeRegular; - break; - case UIActivityIndicatorViewStyleMedium: - self.controlSize = NSControlSizeSmall; - break; - default: - break; - } -} - -- (void)setColor:(RCTUIColor*)color -{ - if (_color != color) { - _color = color; - [self setNeedsDisplay:YES]; - } -} - -- (void)updateLayer -{ - [super updateLayer]; - if (_color != nil) { - CGFloat r, g, b, a; - [[_color colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]] getRed:&r green:&g blue:&b alpha:&a]; - - CIFilter *colorPoly = [CIFilter filterWithName:@"CIColorPolynomial"]; - [colorPoly setDefaults]; - - CIVector *redVector = [CIVector vectorWithX:r Y:0 Z:0 W:0]; - CIVector *greenVector = [CIVector vectorWithX:g Y:0 Z:0 W:0]; - CIVector *blueVector = [CIVector vectorWithX:b Y:0 Z:0 W:0]; - [colorPoly setValue:redVector forKey:@"inputRedCoefficients"]; - [colorPoly setValue:greenVector forKey:@"inputGreenCoefficients"]; - [colorPoly setValue:blueVector forKey:@"inputBlueCoefficients"]; - - [[self layer] setFilters:@[colorPoly]]; - } else { - [[self layer] setFilters:nil]; - } -} - -- (void)setProgress:(double)progress -{ - [self setDoubleValue:progress]; - if(self.indeterminate){ - [super setIndeterminate:NO]; - } - - [self setNeedsDisplay:YES]; -} - -- (void)setIndeterminate:(BOOL)indeterminate -{ - [super setIndeterminate:indeterminate]; - if(indeterminate){ - [self startAnimating]; - }else{ - [self stopAnimating]; - } - -} - -@end diff --git a/apps/menu-bar/macos/ExpoMenuBar.xcodeproj/project.pbxproj b/apps/menu-bar/macos/ExpoMenuBar.xcodeproj/project.pbxproj index f2594358..551ce0a9 100644 --- a/apps/menu-bar/macos/ExpoMenuBar.xcodeproj/project.pbxproj +++ b/apps/menu-bar/macos/ExpoMenuBar.xcodeproj/project.pbxproj @@ -13,8 +13,6 @@ 514201552437B4B40078DB4F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 514201532437B4B40078DB4F /* Main.storyboard */; }; 514201582437B4B40078DB4F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 514201572437B4B40078DB4F /* main.m */; }; 77818F2A6E488E8B68D317B2 /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B02E22FAC6ED05060D31BB51 /* ExpoModulesProvider.swift */; }; - C0271C582A602CDE0065AB11 /* ProgressIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C0271C572A602CDE0065AB11 /* ProgressIndicatorManager.m */; }; - C0271C5B2A602FF60065AB11 /* ProgressIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = C0271C5A2A602FF60065AB11 /* ProgressIndicatorView.m */; }; C032EDB72A1FE6F300FBC597 /* orbit-cli-arm64 in Resources */ = {isa = PBXBuildFile; fileRef = C032EDB62A1FE6F300FBC597 /* orbit-cli-arm64 */; }; C051E6B62A83577800C6D615 /* orbit-cli-x64 in Resources */ = {isa = PBXBuildFile; fileRef = C051E6B52A83577800C6D615 /* orbit-cli-x64 */; }; C051E6BB2A991C4200C6D615 /* WebAuthenticationSession.m in Sources */ = {isa = PBXBuildFile; fileRef = C051E6BA2A991C4200C6D615 /* WebAuthenticationSession.m */; }; @@ -69,10 +67,6 @@ 9D32DFD059D5DB6DDEF38881 /* Pods-Shared-ExpoMenuBar-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Shared-ExpoMenuBar-iOS.debug.xcconfig"; path = "Target Support Files/Pods-Shared-ExpoMenuBar-iOS/Pods-Shared-ExpoMenuBar-iOS.debug.xcconfig"; sourceTree = ""; }; A82DFB63B157C65E5D698CA2 /* Pods-Shared-ExpoMenuBar-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Shared-ExpoMenuBar-iOS.release.xcconfig"; path = "Target Support Files/Pods-Shared-ExpoMenuBar-iOS/Pods-Shared-ExpoMenuBar-iOS.release.xcconfig"; sourceTree = ""; }; B02E22FAC6ED05060D31BB51 /* ExpoModulesProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExpoModulesProvider.swift; path = "Pods/Target Support Files/Pods-ExpoMenuBar-macOS/ExpoModulesProvider.swift"; sourceTree = ""; }; - C0271C562A602CCB0065AB11 /* ProgressIndicatorManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProgressIndicatorManager.h; sourceTree = ""; }; - C0271C572A602CDE0065AB11 /* ProgressIndicatorManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProgressIndicatorManager.m; sourceTree = ""; }; - C0271C592A602FEC0065AB11 /* ProgressIndicatorView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProgressIndicatorView.h; sourceTree = ""; }; - C0271C5A2A602FF60065AB11 /* ProgressIndicatorView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProgressIndicatorView.m; sourceTree = ""; }; C032EDB62A1FE6F300FBC597 /* orbit-cli-arm64 */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = "orbit-cli-arm64"; path = "../../cli/orbit-cli-arm64"; sourceTree = ""; }; C051E6B32A83408800C6D615 /* ExpoMenuBar-macOSRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "ExpoMenuBar-macOSRelease.entitlements"; sourceTree = ""; }; C051E6B42A8340AF00C6D615 /* AutoLauncherRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AutoLauncherRelease.entitlements; sourceTree = ""; }; @@ -205,10 +199,6 @@ C0523ECF2A55980D003371AF /* WindowWithDeallocCallback.m */, C08E65332A5D04910079E3A9 /* WindowNavigator.m */, C08E65352A5D0A580079E3A9 /* WindowNavigator.h */, - C0271C562A602CCB0065AB11 /* ProgressIndicatorManager.h */, - C0271C572A602CDE0065AB11 /* ProgressIndicatorManager.m */, - C0271C592A602FEC0065AB11 /* ProgressIndicatorView.h */, - C0271C5A2A602FF60065AB11 /* ProgressIndicatorView.m */, C051E6B92A991C0A00C6D615 /* WebAuthenticationSession.h */, C051E6BA2A991C4200C6D615 /* WebAuthenticationSession.m */, C051EC0D2AA227C600C6D615 /* SwifterWrapper.swift */, @@ -512,11 +502,9 @@ C06B8F8A2AAA9024009F2BB5 /* FileHandler.m in Sources */, C0523ED02A55980D003371AF /* WindowWithDeallocCallback.m in Sources */, C06B8F902AAB77D0009F2BB5 /* DragDropStatusItemView.m in Sources */, - C0271C582A602CDE0065AB11 /* ProgressIndicatorManager.m in Sources */, C0B36EA32A65E25A004F2D8C /* CheckboxManager.m in Sources */, C0C820022AB8E5EE003D75AF /* SparkleModule.m in Sources */, C06B8F8D2AAA9058009F2BB5 /* FileHandlerManager.m in Sources */, - C0271C5B2A602FF60065AB11 /* ProgressIndicatorView.m in Sources */, C051EC0E2AA227C600C6D615 /* SwifterWrapper.swift in Sources */, C051E6BB2A991C4200C6D615 /* WebAuthenticationSession.m in Sources */, C0523ECC2A550983003371AF /* WindowManager.m in Sources */, diff --git a/apps/menu-bar/macos/Podfile.lock b/apps/menu-bar/macos/Podfile.lock index e16724e6..133a69f9 100644 --- a/apps/menu-bar/macos/Podfile.lock +++ b/apps/menu-bar/macos/Podfile.lock @@ -39,6 +39,8 @@ PODS: - MMKV (1.3.0): - MMKVCore (~> 1.3.0) - MMKVCore (1.3.0) + - ProgressIndicator (1.0.0): + - ExpoModulesCore - RCT-Folly (2022.05.16.00): - boost - DoubleConversion @@ -1105,6 +1107,7 @@ DEPENDENCIES: - hermes-engine (from `../../../node_modules/react-native-macos/sdks/hermes-engine/hermes-engine.podspec`) - libevent (~> 2.1.12) - MenuBar (from `../modules/menu-bar/ios`) + - ProgressIndicator (from `../modules/progress-indicator/ios`) - RCT-Folly (from `../../../node_modules/react-native-macos/third-party-podspecs/RCT-Folly.podspec`) - RCT-Folly/Fabric (from `../../../node_modules/react-native-macos/third-party-podspecs/RCT-Folly.podspec`) - RCTRequired (from `../../../node_modules/react-native-macos/Libraries/RCTRequired`) @@ -1195,6 +1198,8 @@ EXTERNAL SOURCES: :tag: hermes-2023-11-17-RNv0.73.0-21043a3fc062be445e56a2c10ecd8be028dd9cc5 MenuBar: :path: "../modules/menu-bar/ios" + ProgressIndicator: + :path: "../modules/progress-indicator/ios" RCT-Folly: :podspec: "../../../node_modules/react-native-macos/third-party-podspecs/RCT-Folly.podspec" RCTRequired: @@ -1305,6 +1310,7 @@ SPEC CHECKSUMS: MenuBar: d81681b6da1a7ab4bb05a9b3d08357754b908d34 MMKV: 9c6c3fa4ddd849f28c7b9a5c9d23aab84f14ee35 MMKVCore: 9bb7440b170181ac5b81f542ac258103542e693d + ProgressIndicator: 3244d7c774e6f665494acef41a9937a93147ad43 RCT-Folly: 270f9eebb5a7d757382d0438ea993e4d7aa85932 RCTRequired: 47fe8eedbbc5a1869b4b6327daa196c740fbd644 RCTTypeSafety: 1b7ac43d753fa2957f693e129d7000f2f9df76a6 diff --git a/apps/menu-bar/modules/progress-indicator/expo-module.config.json b/apps/menu-bar/modules/progress-indicator/expo-module.config.json new file mode 100644 index 00000000..a0e7490e --- /dev/null +++ b/apps/menu-bar/modules/progress-indicator/expo-module.config.json @@ -0,0 +1,6 @@ +{ + "platforms": ["apple", "web"], + "apple": { + "modules": ["ProgressIndicatorModule"] + } +} diff --git a/apps/menu-bar/modules/progress-indicator/index.ts b/apps/menu-bar/modules/progress-indicator/index.ts new file mode 100644 index 00000000..d6db910c --- /dev/null +++ b/apps/menu-bar/modules/progress-indicator/index.ts @@ -0,0 +1,3 @@ +import ProgressIndicator from './src/ProgressIndicatorView'; + +export { ProgressIndicator }; diff --git a/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicator.podspec b/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicator.podspec new file mode 100644 index 00000000..fbbc0ce8 --- /dev/null +++ b/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicator.podspec @@ -0,0 +1,21 @@ +Pod::Spec.new do |s| + s.name = 'ProgressIndicator' + s.version = '1.0.0' + s.summary = 'A sample project summary' + s.description = 'A sample project description' + s.author = '' + s.homepage = 'https://docs.expo.dev/modules/' + s.platform = :osx, '10.15' + s.source = { git: '' } + s.static_framework = true + + s.dependency 'ExpoModulesCore' + + # Swift/Objective-C compatibility + s.pod_target_xcconfig = { + 'DEFINES_MODULE' => 'YES', + 'SWIFT_COMPILATION_MODE' => 'wholemodule' + } + + s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}" +end diff --git a/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorModule.swift b/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorModule.swift new file mode 100644 index 00000000..294a9819 --- /dev/null +++ b/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorModule.swift @@ -0,0 +1,17 @@ +import ExpoModulesCore + +public class ProgressIndicatorModule: Module { + public func definition() -> ModuleDefinition { + Name("ProgressIndicator") + + View(ProgressIndicatorView.self) { + Prop("indeterminate") { (view, isIndeterminate: Bool) in + view.setIndeterminate(isIndeterminate) + } + + Prop("progress") { (view, progress: Double) in + view.setProgress(progress) + } + } + } +} diff --git a/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorView.swift b/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorView.swift new file mode 100644 index 00000000..a1a36df9 --- /dev/null +++ b/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorView.swift @@ -0,0 +1,36 @@ +import ExpoModulesCore + +class ProgressIndicatorView: ExpoView { + let progressIndicatorView = NSProgressIndicator() + + required init(appContext: AppContext? = nil) { + super.init(appContext: appContext) + clipsToBounds = true + + progressIndicatorView.style = .bar + progressIndicatorView.maxValue = 0.0 + progressIndicatorView.maxValue = 100.0 + addSubview(progressIndicatorView) + } + + override func layoutSubviews() { + progressIndicatorView.frame = bounds + } + + func setIndeterminate(_ indeterminate: Bool) { + progressIndicatorView.isIndeterminate = indeterminate + if indeterminate { + progressIndicatorView.startAnimation(nil) + } else { + progressIndicatorView.stopAnimation(self) + } + } + + func setProgress(_ progress: Double) { + progressIndicatorView.doubleValue = progress + + if progressIndicatorView.isIndeterminate { + setIndeterminate(false) + } + } +} diff --git a/apps/menu-bar/modules/progress-indicator/src/ProgressIndicator.types.ts b/apps/menu-bar/modules/progress-indicator/src/ProgressIndicator.types.ts new file mode 100644 index 00000000..54b59c80 --- /dev/null +++ b/apps/menu-bar/modules/progress-indicator/src/ProgressIndicator.types.ts @@ -0,0 +1,7 @@ +import { ViewProps } from 'react-native'; + +export type ProgressIndicatorViewProps = ViewProps & { + progress?: number; + indeterminate?: boolean; + size?: 'small' | 'large'; +}; diff --git a/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.tsx b/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.tsx new file mode 100644 index 00000000..2608b20a --- /dev/null +++ b/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.tsx @@ -0,0 +1,50 @@ +import { requireNativeViewManager } from 'expo-modules-core'; +import * as React from 'react'; +import { StyleSheet } from 'react-native'; + +import { ProgressIndicatorViewProps } from './ProgressIndicator.types'; + +const NativeView: React.ComponentType = + requireNativeViewManager('ProgressIndicator'); + +export default function ProgressIndicatorView(props: ProgressIndicatorViewProps) { + const [key, setKey] = React.useState(0); + + React.useEffect(() => { + /** + * There is a bug in NSProgressIndicator where the progress animation does not + * work if we switch from a progress indicator (using doubleValue) to indeterminate. + * To work around this, we need to force a re-render of the component. + */ + setKey((key) => key + 1); + }, [props.indeterminate]); + return ( + + ); +} + +function getSizeStyle(size: ProgressIndicatorViewProps['size']) { + switch (size) { + case 'small': + return styles.sizeSmall; + case 'large': + default: + return styles.sizeLarge; + } +} + +const styles = StyleSheet.create({ + container: { + alignSelf: 'stretch', + }, + sizeSmall: { + height: 20, + }, + sizeLarge: { + height: 24, + }, +}); diff --git a/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.web.tsx b/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.web.tsx new file mode 100644 index 00000000..2aa123d6 --- /dev/null +++ b/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.web.tsx @@ -0,0 +1,10 @@ +import * as React from 'react'; + +import { ProgressIndicatorViewProps } from './ProgressIndicator.types'; + +export default function ProgressIndicatorView({ + progress, + indeterminate, +}: ProgressIndicatorViewProps) { + return ; +} diff --git a/apps/menu-bar/src/components/ProgressIndicator/index.tsx b/apps/menu-bar/src/components/ProgressIndicator/index.tsx deleted file mode 100644 index ab217cd3..00000000 --- a/apps/menu-bar/src/components/ProgressIndicator/index.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { ColorValue, requireNativeComponent, StyleProp, StyleSheet, ViewStyle } from 'react-native'; - -type NativeProps = { - color?: ColorValue; - size?: 'small' | 'large'; - style?: StyleProp; - indeterminate?: boolean; - progress?: number; -}; - -const NativeProgressIndicator = requireNativeComponent('ProgressIndicator'); - -const ProgressIndicator = (props: NativeProps) => { - return ( - - ); -}; - -function getSizeStyle(size: NativeProps['size']) { - switch (size) { - case 'small': - return styles.sizeSmall; - case 'large': - default: - return styles.sizeLarge; - } -} - -const styles = StyleSheet.create({ - container: { - alignSelf: 'stretch', - }, - sizeSmall: { - height: 20, - }, - sizeLarge: { - height: 24, - }, -}); - -export default ProgressIndicator; diff --git a/apps/menu-bar/src/components/ProgressIndicator/index.web.tsx b/apps/menu-bar/src/components/ProgressIndicator/index.web.tsx deleted file mode 100644 index d57575dd..00000000 --- a/apps/menu-bar/src/components/ProgressIndicator/index.web.tsx +++ /dev/null @@ -1,5 +0,0 @@ -const ProgressIndicator = ({ progress }: { progress: number }) => { - return ; -}; - -export default ProgressIndicator; diff --git a/apps/menu-bar/src/popover/BuildsSection.tsx b/apps/menu-bar/src/popover/BuildsSection.tsx index 7a297830..eb75e718 100644 --- a/apps/menu-bar/src/popover/BuildsSection.tsx +++ b/apps/menu-bar/src/popover/BuildsSection.tsx @@ -1,10 +1,10 @@ import Item from './Item'; import SectionHeader from './SectionHeader'; import * as FilePicker from '../../modules/file-picker'; +import { ProgressIndicator } from '../../modules/progress-indicator'; import Earth02Icon from '../assets/icons/earth-02.svg'; import File05Icon from '../assets/icons/file-05.svg'; import { Text, View } from '../components'; -import ProgressIndicator from '../components/ProgressIndicator'; import MenuBarModule from '../modules/MenuBarModule'; import { openProjectsSelectorURL } from '../utils/constants'; import { MenuBarStatus } from '../utils/helpers'; From 5ab0f9983345e2b8e4baf78f1104431b0970ec8c Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Dall'Agnol Date: Fri, 26 Jan 2024 14:19:10 +0100 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Alan Hughes <30924086+alanjhughes@users.noreply.github.com> --- .../progress-indicator/ios/ProgressIndicatorModule.swift | 8 ++++++-- .../progress-indicator/ios/ProgressIndicatorView.swift | 2 +- .../progress-indicator/src/ProgressIndicatorView.tsx | 8 +------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorModule.swift b/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorModule.swift index 294a9819..a445f641 100644 --- a/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorModule.swift +++ b/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorModule.swift @@ -5,8 +5,12 @@ public class ProgressIndicatorModule: Module { Name("ProgressIndicator") View(ProgressIndicatorView.self) { - Prop("indeterminate") { (view, isIndeterminate: Bool) in - view.setIndeterminate(isIndeterminate) + Prop("indeterminate") { (view, isIndeterminate: Bool?) in + if let isIndeterminate { + view.setIndeterminate(isIndeterminate) + } else { + view.setIndeterminate(false) + } } Prop("progress") { (view, progress: Double) in diff --git a/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorView.swift b/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorView.swift index a1a36df9..db9ed059 100644 --- a/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorView.swift +++ b/apps/menu-bar/modules/progress-indicator/ios/ProgressIndicatorView.swift @@ -8,7 +8,7 @@ class ProgressIndicatorView: ExpoView { clipsToBounds = true progressIndicatorView.style = .bar - progressIndicatorView.maxValue = 0.0 + progressIndicatorView.minValue = 0.0 progressIndicatorView.maxValue = 100.0 addSubview(progressIndicatorView) } diff --git a/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.tsx b/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.tsx index 2608b20a..e9c95e95 100644 --- a/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.tsx +++ b/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.tsx @@ -28,13 +28,7 @@ export default function ProgressIndicatorView(props: ProgressIndicatorViewProps) } function getSizeStyle(size: ProgressIndicatorViewProps['size']) { - switch (size) { - case 'small': - return styles.sizeSmall; - case 'large': - default: - return styles.sizeLarge; - } + return size === 'small' ? styles.Small : styles.sizeLarge; } const styles = StyleSheet.create({ From e84fa32af4dea6d493e14bc1adbdd87e592c90a4 Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Date: Fri, 26 Jan 2024 10:38:27 -0300 Subject: [PATCH 3/4] Add changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18ddba6a..319e244b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,6 @@ ### 🎉 New features -- Add support for launching Expo updates. ([#134](https://github.com/expo/orbit/pull/134), [#137](https://github.com/expo/orbit/pull/137), [#138](https://github.com/expo/orbit/pull/138), [#144](https://github.com/expo/orbit/pull/144) by [@gabrieldonadel](https://github.com/gabrieldonadel)) - Add support for launching Expo updates. ([#134](https://github.com/expo/orbit/pull/134), [#137](https://github.com/expo/orbit/pull/137), [#138](https://github.com/expo/orbit/pull/138), [#144](https://github.com/expo/orbit/pull/144), [#148](https://github.com/expo/orbit/pull/148) by [@gabrieldonadel](https://github.com/gabrieldonadel)) - Add support for Snack EAS Update URLs to support SDK 50. ([#147](https://github.com/expo/orbit/pull/147) by [@bycedric](https://github.com/byCedric)) @@ -20,6 +19,7 @@ - Migrate FilePicker to Expo Modules. ([#132](https://github.com/expo/orbit/pull/132) by [@gabrieldonadel](https://github.com/gabrieldonadel)) - Upgrade `react-native` to 0.73.2. ([#143](https://github.com/expo/orbit/pull/143) by [@gabrieldonadel](https://github.com/gabrieldonadel)) - Upgrade `react-native-svg` to 14.1.0. ([#143](https://github.com/expo/orbit/pull/143) by [@gabrieldonadel](https://github.com/gabrieldonadel)) +- Migrate ProgressIndicator to Expo Modules. ([#150](https://github.com/expo/orbit/pull/150) by [@gabrieldonadel](https://github.com/gabrieldonadel)) ## 1.0.2 — 2024-01-17 From b303b1f09dbacb8fc6b8f3e3b44e8a21bbd1c612 Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Date: Fri, 26 Jan 2024 10:44:03 -0300 Subject: [PATCH 4/4] Fix ProgressIndicatorView getSizeStyle --- .../modules/progress-indicator/src/ProgressIndicatorView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.tsx b/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.tsx index e9c95e95..8b592490 100644 --- a/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.tsx +++ b/apps/menu-bar/modules/progress-indicator/src/ProgressIndicatorView.tsx @@ -28,7 +28,7 @@ export default function ProgressIndicatorView(props: ProgressIndicatorViewProps) } function getSizeStyle(size: ProgressIndicatorViewProps['size']) { - return size === 'small' ? styles.Small : styles.sizeLarge; + return size === 'small' ? styles.sizeSmall : styles.sizeLarge; } const styles = StyleSheet.create({