@umituz/react-native-ai-creations 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-creations",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "AI-generated creations gallery with filtering, sharing, and management for React Native apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -88,34 +88,24 @@ export function CreationsGalleryScreen({
88
88
  setSelectedCreation(creation);
89
89
  }, []);
90
90
 
91
- if (selectedCreation) {
92
- return (
93
- <CreationDetailScreen
94
- creation={selectedCreation}
95
- onClose={() => setSelectedCreation(null)}
96
- onShare={handleShare}
97
- onDelete={handleDelete}
98
- t={t}
99
- />
100
- );
101
- }
102
-
103
91
  const styles = useStyles(tokens);
104
92
 
105
- // 1. Loading State - Prevent header flash
106
- if (isLoading && (!creations || creations.length === 0)) {
107
- return (
108
- <View style={[styles.container, styles.center]}>
109
- <ActivityIndicator size="large" color={tokens.colors.primary} />
110
- </View>
111
- );
112
- }
113
-
114
- // 2. Pure Empty State - If no creations exist at all, don't show filters
115
- if (!creations || creations.length === 0) {
116
- return (
117
- <View style={styles.container}>
118
- <View style={[styles.container, { paddingTop: insets.top + tokens.spacing.md }]}>
93
+ // Define empty state content based on state
94
+ const renderEmptyComponent = useMemo(() => {
95
+ // 1. Loading State
96
+ if (isLoading && (!creations || creations?.length === 0)) {
97
+ return (
98
+ <View style={styles.centerContainer}>
99
+ <ActivityIndicator size="large" color={tokens.colors.primary} />
100
+ </View>
101
+ );
102
+ }
103
+
104
+ // 2. System Empty State (User has NO creations at all)
105
+ // We check 'creations' (the full list)
106
+ if (!creations || creations?.length === 0) {
107
+ return (
108
+ <View style={styles.centerContainer}>
119
109
  <EmptyState
120
110
  title={t(config.translations.empty)}
121
111
  description={t(config.translations.emptyDescription)}
@@ -123,54 +113,85 @@ export function CreationsGalleryScreen({
123
113
  onAction={onEmptyAction}
124
114
  />
125
115
  </View>
126
- </View>
127
- );
128
- }
129
-
130
- // 3. Gallery Content
131
- return (
132
- <View style={styles.container}>
133
- <GalleryHeader
134
- title={t(config.translations.title) || 'My Creations'}
135
- count={filtered.length}
136
- countLabel={t(config.translations.photoCount) || 'photos'}
137
- isFiltered={isFiltered}
138
- filterLabel={t(config.translations.filterLabel) || 'Filter'}
139
- onFilterPress={() => filterSheetRef.current?.present()}
140
- style={{ paddingTop: insets.top + tokens.spacing.md }}
141
- />
116
+ );
117
+ }
142
118
 
143
- {filtered.length === 0 ? (
119
+ // 3. Filter Empty State (User has creations, but filter returns none)
120
+ // We check 'filtered' (the displayed list)
121
+ return (
122
+ <View style={styles.centerContainer}>
144
123
  <EmptyState
145
124
  title={t("common.no_results") || "No results"}
146
125
  description={t("common.no_results_description") || "Try changing your filters"}
147
126
  actionLabel={t("common.clear_all") || "Clear All"}
148
127
  onAction={clearFilters}
149
128
  />
150
- ) : (
151
- <>
152
- <CreationsGrid
153
- creations={filtered}
154
- types={translatedTypes}
155
- isLoading={isLoading}
156
- onRefresh={refetch}
157
- onView={handleView}
158
- onShare={handleShare}
159
- onDelete={handleDelete}
160
- contentContainerStyle={{ paddingBottom: insets.bottom + tokens.spacing.xl }}
161
- />
162
- <CreationImageViewer
163
- creations={filtered}
164
- visible={viewerVisible}
165
- index={viewerIndex}
166
- onDismiss={() => setViewerVisible(false)}
167
- onIndexChange={setViewerIndex}
168
- enableEditing={enableEditing}
169
- onImageEdit={onImageEdit}
170
- />
171
- </>
129
+ </View>
130
+ );
131
+ }, [isLoading, creations, config, t, emptyActionLabel, onEmptyAction, clearFilters, styles.centerContainer, tokens.colors.primary]);
132
+
133
+ if (selectedCreation) {
134
+ return (
135
+ <CreationDetailScreen
136
+ creation={selectedCreation}
137
+ onClose={() => setSelectedCreation(null)}
138
+ onShare={handleShare}
139
+ onDelete={handleDelete}
140
+ t={t}
141
+ />
142
+ );
143
+ }
144
+
145
+ return (
146
+ <View style={styles.container}>
147
+ {/* Header is always shown unless we are in "System Empty" without data?
148
+ User requested: "herhangi bir creations yoksa buradaki no creations gözükmeli" (if no creations, show no creations).
149
+ Currently we show header always, except logic below might hide it.
150
+ Actually, let's keep header always visible IF we have creations.
151
+ If !creations, we pass `renderEmptyComponent`, but Grid has header support.
152
+
153
+ However, to match previous request "filter gözükebilir" (filter can be visible), we'll keep header outside.
154
+ BUT, if NO creations, showing filter header is weird.
155
+
156
+ Let's conditonally render header: Only if we have creations OR loading.
157
+ If loaded and 0 creations -> Hide header (Clean Empty State).
158
+ */}
159
+ {(!creations || creations?.length === 0) && !isLoading ? null : (
160
+ <GalleryHeader
161
+ title={t(config.translations.title) || 'My Creations'}
162
+ count={filtered.length}
163
+ countLabel={t(config.translations.photoCount) || 'photos'}
164
+ isFiltered={isFiltered}
165
+ filterLabel={t(config.translations.filterLabel) || 'Filter'}
166
+ onFilterPress={() => filterSheetRef.current?.present()}
167
+ style={{ paddingTop: insets.top + tokens.spacing.md }}
168
+ />
172
169
  )}
173
170
 
171
+ {/* Main Content Grid - handles empty/loading via ListEmptyComponent */}
172
+ <CreationsGrid
173
+ creations={filtered}
174
+ types={translatedTypes}
175
+ isLoading={isLoading}
176
+ onRefresh={refetch}
177
+ onView={handleView}
178
+ onShare={handleShare}
179
+ onDelete={handleDelete}
180
+ contentContainerStyle={{ paddingBottom: insets.bottom + tokens.spacing.xl }}
181
+ ListEmptyComponent={renderEmptyComponent}
182
+ />
183
+
184
+ <CreationImageViewer
185
+ creations={filtered}
186
+ visible={viewerVisible}
187
+ index={viewerIndex}
188
+ onDismiss={() => setViewerVisible(false)}
189
+ onIndexChange={setViewerIndex}
190
+ enableEditing={enableEditing}
191
+ onImageEdit={onImageEdit}
192
+ selectedCreationId={selectedCreation?.id}
193
+ />
194
+
174
195
  <FilterBottomSheet
175
196
  ref={filterSheetRef}
176
197
  categories={allCategories}
@@ -185,5 +206,11 @@ export function CreationsGalleryScreen({
185
206
 
186
207
  const useStyles = (tokens: any) => StyleSheet.create({
187
208
  container: { flex: 1, backgroundColor: tokens.colors.background },
188
- center: { justifyContent: 'center', alignItems: 'center' },
209
+ centerContainer: {
210
+ flex: 1,
211
+ justifyContent: 'center',
212
+ alignItems: 'center',
213
+ minHeight: 400,
214
+ paddingHorizontal: tokens.spacing.xl
215
+ },
189
216
  });