Skip to content

Commit 41f8e08

Browse files
committed
fix: resizing images, chat example
1 parent 9769561 commit 41f8e08

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

example/src/Screens/Chat.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
Image,
3+
KeyboardAvoidingView,
34
Platform,
45
ScrollView,
56
type ScrollViewProps,
@@ -22,7 +23,10 @@ export function Chat({
2223
}: Partial<ScrollViewProps & { bottom: boolean }>) {
2324
console.log(Platform.OS, ' Rendering Chat');
2425
return (
25-
<View style={styles.container}>
26+
<KeyboardAvoidingView
27+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
28+
style={styles.container}
29+
>
2630
<ScrollView
2731
style={styles.inverted}
2832
contentContainerStyle={styles.content}
@@ -64,10 +68,10 @@ export function Chat({
6468
/>
6569
{bottom ? (
6670
<View
67-
style={[styles.spacer, Platform.OS !== 'android' && { height: 80 }]}
71+
style={[styles.spacer, Platform.OS !== 'android' && { height: 90 }]}
6872
/>
6973
) : null}
70-
</View>
74+
</KeyboardAvoidingView>
7175
);
7276
}
7377

ios/TabViewProvider.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct TabData: Codable {
108108
}
109109
guard let image else { return }
110110
DispatchQueue.main.async {
111-
self.props.icons[index] = image
111+
self.props.icons[index] = image.resizeImageTo(size: self.iconSize)
112112
}
113113
})
114114
}
@@ -139,11 +139,21 @@ struct TabData: Codable {
139139
guard let configDict = dict as? [String: Any] else { return nil }
140140
let sidebarAdaptable = configDict["sidebarAdaptable"] as? Bool ?? false
141141
let labeled = configDict["labeled"] as? Bool ?? nil
142-
142+
143143
return TabViewConfig(
144144
sidebarAdaptable: sidebarAdaptable,
145145
labeled: labeled
146146
)
147147
}
148148

149149
}
150+
151+
extension UIImage {
152+
func resizeImageTo(size: CGSize) -> UIImage? {
153+
UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
154+
self.draw(in: CGRect(origin: CGPoint.zero, size: size))
155+
let resizedImage = UIGraphicsGetImageFromCurrentImageContext()!
156+
UIGraphicsEndImageContext()
157+
return resizedImage
158+
}
159+
}

0 commit comments

Comments
 (0)