Phase 3 - Portfolio Screens (6 files):
- [id]/index.tsx: ViewWrapper → OS_Wrapper (detail dengan pull-to-refresh)
- [id]/edit.tsx: NewWrapper → OS_Wrapper (form + keyboard handling)
- [id]/edit-logo.tsx: ViewWrapper → OS_Wrapper (upload logo)
- [id]/edit-social-media.tsx: ViewWrapper → OS_Wrapper (form + keyboard handling)
- ViewListPortofolio.tsx: NewWrapper → OS_Wrapper (pagination list)
- ScreenPortofolioCreate.tsx: NewWrapper → OS_Wrapper (form + keyboard handling)
Phase 4 - Maps Screens (2 files):
- ScreenMapsCreate.tsx: NewWrapper → OS_Wrapper (form + keyboard handling)
- ScreenMapsEdit.tsx: ViewWrapper → OS_Wrapper (form + keyboard handling)
Bug Fixes:
- Perbaiki auto-scroll keyboard yang membuat input paling atas 'terlempar' keluar layar
- Gunakan UIManager.measure untuk mendapatkan posisi absolut input (pageY) secara akurat
- Logika conditional scroll:
* Jika input terlihat (di atas keyboard) → TIDAK SCROLL
* Jika input tertutup keyboard → Scroll secukupnya
- Helper cloneChildrenWithFocusHandler sekarang aktif menyuntikan onFocus handler ke semua TextInput/TextArea/PhoneInput/Select
- Hapus KeyboardAvoidingView dari AndroidWrapper static mode (tidak diperlukan lagi)
Pattern yang diterapkan:
- List screens: contentPaddingBottom=100 (default)
- Form screens: contentPaddingBottom={250} + enableKeyboardHandling
- NO PADDING_INLINE (sesuai preferensi user - mencegah box menyempit)
Dokumentasi:
- Update TASK-005 dengan status lengkap Phase 1-4 (27 files migrated)
- Tambahkan urutan phase baru: Event (Phase 5), Voting (Phase 6), Forum (Phase 7), Donation (Phase 8)
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
133 lines
3.2 KiB
TypeScript
133 lines
3.2 KiB
TypeScript
import {
|
|
BoxButtonOnFooter,
|
|
ButtonCustom,
|
|
OS_Wrapper,
|
|
TextInputCustom,
|
|
} from "@/components";
|
|
import {
|
|
apiGetOnePortofolio,
|
|
apiUpdatePortofolio,
|
|
} from "@/service/api-client/api-portofolio";
|
|
import { useLocalSearchParams, router } from "expo-router";
|
|
import { useEffect, useState } from "react";
|
|
import Toast from "react-native-toast-message";
|
|
|
|
export default function PortofolioEditSocialMedia() {
|
|
const { id } = useLocalSearchParams();
|
|
console.log("ID >>", id);
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
const [data, setData] = useState<any>({
|
|
facebook: "",
|
|
twitter: "",
|
|
instagram: "",
|
|
tiktok: "",
|
|
youtube: "",
|
|
});
|
|
|
|
useEffect(() => {
|
|
onLoadData(id as string);
|
|
}, [id]);
|
|
|
|
const onLoadData = async (id: string) => {
|
|
const response = await apiGetOnePortofolio({ id: id });
|
|
console.log(
|
|
"Response portofolio >>",
|
|
JSON.stringify(response.data.Portofolio_MediaSosial, null, 2)
|
|
);
|
|
const data = response.data.Portofolio_MediaSosial;
|
|
setData({
|
|
facebook: data.facebook,
|
|
twitter: data.twitter,
|
|
instagram: data.instagram,
|
|
tiktok: data.tiktok,
|
|
youtube: data.youtube,
|
|
});
|
|
};
|
|
|
|
const onSubmitUpdate = async () => {
|
|
try {
|
|
setIsLoading(true);
|
|
const response = await apiUpdatePortofolio({
|
|
id: id as string,
|
|
data: data,
|
|
category: "medsos",
|
|
});
|
|
|
|
if (!response.success) {
|
|
Toast.show({
|
|
type: "info",
|
|
text1: "Info",
|
|
text2: response.message,
|
|
});
|
|
|
|
return;
|
|
}
|
|
|
|
Toast.show({
|
|
type: "success",
|
|
text1: "Sukses",
|
|
text2: "Data media terupdate",
|
|
});
|
|
|
|
router.back();
|
|
} catch (error) {
|
|
console.log("Error onSubmitUpdate", error);
|
|
} finally {
|
|
setIsLoading(false);
|
|
}
|
|
};
|
|
|
|
const buttonFooter = (
|
|
<BoxButtonOnFooter>
|
|
<ButtonCustom
|
|
isLoading={isLoading}
|
|
disabled={isLoading}
|
|
onPress={onSubmitUpdate}
|
|
>
|
|
Update
|
|
</ButtonCustom>
|
|
</BoxButtonOnFooter>
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<OS_Wrapper
|
|
enableKeyboardHandling
|
|
contentPaddingBottom={250}
|
|
footerComponent={buttonFooter}
|
|
>
|
|
<TextInputCustom
|
|
value={data.tiktok}
|
|
onChangeText={(value) => setData({ ...data, tiktok: value })}
|
|
label="Tiktok"
|
|
placeholder="Masukkan tiktok"
|
|
/>
|
|
<TextInputCustom
|
|
value={data.instagram}
|
|
onChangeText={(value) => setData({ ...data, instagram: value })}
|
|
label="Instagram"
|
|
placeholder="Masukkan instagram"
|
|
/>
|
|
<TextInputCustom
|
|
value={data.facebook}
|
|
onChangeText={(value) => setData({ ...data, facebook: value })}
|
|
label="Facebook"
|
|
placeholder="Masukkan facebook"
|
|
/>
|
|
<TextInputCustom
|
|
value={data.twitter}
|
|
onChangeText={(value) => setData({ ...data, twitter: value })}
|
|
label="Twitter"
|
|
placeholder="Masukkan twitter"
|
|
/>
|
|
<TextInputCustom
|
|
value={data.youtube}
|
|
onChangeText={(value) => setData({ ...data, youtube: value })}
|
|
label="Youtube"
|
|
placeholder="Masukkan youtube"
|
|
/>
|
|
</OS_Wrapper>
|
|
</>
|
|
);
|
|
}
|