Here's the complete file structure you need to create:
TinTucVN/
├── config/
│ └── firebase.ts
├── src/
│ ├── components/
│ │ └── SeedDatabaseButton.tsx
│ ├── contexts/
│ │ └── AuthContext.tsx
│ ├── navigation/
│ │ └── AppNavigator.tsx
│ ├── screens/
│ │ ├── Auth/
│ │ │ ├── LoginScreen.tsx
│ │ │ └── RegisterScreen.tsx
│ │ ├── Main/
│ │ │ ├── HomeScreen.tsx
│ │ │ ├── ArticleDetailScreen.tsx
│ │ │ ├── SearchScreen.tsx
│ │ │ ├── ProfileScreen.tsx
│ │ │ ├── SavedArticlesScreen.tsx
│ │ │ └── SettingsScreen.tsx
│ │ └── SplashScreen.tsx
│ ├── types/
│ │ └── index.ts
│ └── utils/
│ └── seedFirebase.ts
├── App.tsx
├── app.json
└── package.json
npx create-expo-app@latest TinTucVN --template expo-template-blank-typescript
cd TinTucVN# Navigation
npx expo install @react-navigation/native @react-navigation/native-stack @react-navigation/bottom-tabs
npx expo install react-native-screens react-native-safe-area-context
# Firebase
npm install firebase
# UI & Icons
npm install @expo/vector-icons
# Storage
npx expo install @react-native-async-storage/async-storage
# Fonts
npx expo install expo-font @expo-google-fonts/playfair-display @expo-google-fonts/inter
# HTML Rendering
npm install react-native-render-html
# OAuth & Web Browser
npx expo install expo-web-browser expo-auth-session
# Install all in one go:
npx expo install @react-navigation/native @react-navigation/native-stack @react-navigation/bottom-tabs react-native-screens react-native-safe-area-context @react-native-async-storage/async-storage expo-font @expo-google-fonts/playfair-display @expo-google-fonts/inter expo-web-browser expo-auth-session && npm install firebase @expo/vector-icons react-native-render-htmlmkdir -p config
mkdir -p src/{components,contexts,navigation,screens/{Auth,Main},types,utils}Copy each file I provided into the correct location:
- config/firebase.ts - Firebase configuration
- src/types/index.ts - TypeScript types
- src/contexts/AuthContext.tsx - Authentication context
- src/navigation/AppNavigator.tsx - Navigation setup
- src/utils/seedFirebase.ts - Database seeding utility
- src/components/SeedDatabaseButton.tsx - Seed button component
- src/screens/SplashScreen.tsx - Splash screen
- src/screens/Auth/LoginScreen.tsx - Login screen
- src/screens/Auth/RegisterScreen.tsx - Register screen
- src/screens/Main/HomeScreen.tsx - Home screen
- src/screens/Main/ArticleDetailScreen.tsx - Article detail screen
- src/screens/Main/SearchScreen.tsx - Search screen
- src/screens/Main/ProfileScreen.tsx - Profile screen
- src/screens/Main/SavedArticlesScreen.tsx - Saved articles screen
- src/screens/Main/SettingsScreen.tsx - Settings screen
- App.tsx - Main app component
- Go to Firebase Console
- Create a new project "TinTucVN"
- Add a Web App
- Copy your Firebase config
- Update
config/firebase.tswith your credentials:
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_PROJECT.firebaseapp.com",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_PROJECT.appspot.com",
messagingSenderId: "YOUR_SENDER_ID",
appId: "YOUR_APP_ID",
};In Firebase Console:
-
Authentication
- Go to Authentication > Sign-in method
- Enable "Email/Password"
- Enable "Google"
-
Firestore Database
- Go to Firestore Database
- Click "Create database"
- Start in production mode
- Choose a location
-
Security Rules (Firestore > Rules)
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read: if true;
allow write: if request.auth != null && request.auth.uid == userId;
}
match /articles/{articleId} {
allow read: if true;
allow write: if request.auth != null;
}
}
}- Get your Web Client ID from Firebase Console > Authentication > Sign-in method > Google
- Update
src/contexts/AuthContext.tsx:
const [request, response, promptAsync] = Google.useAuthRequest({
expoClientId: "YOUR_EXPO_CLIENT_ID.apps.googleusercontent.com",
androidClientId: "YOUR_ANDROID_CLIENT_ID.apps.googleusercontent.com",
iosClientId: "YOUR_IOS_CLIENT_ID.apps.googleusercontent.com",
webClientId: "YOUR_WEB_CLIENT_ID.apps.googleusercontent.com",
});{
"expo": {
"name": "TinTucVN",
"slug": "tintucvn",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#000000"
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.yourcompany.tintucvn"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.yourcompany.tintucvn"
}
}
}# Start Expo
npx expo start
# Press 'i' for iOS simulator
# Press 'a' for Android emulator
# Press 'w' for web browser
# Or scan QR code with Expo Go app-
Create a test admin account in Firebase Console > Authentication
- Email: admin@news.vn
- Password: admin123
- Add custom claim:
role: "admin"(in Firestore users collection)
-
Login to the app with admin account
-
Go to Settings screen
-
Click "Thêm dữ liệu mẫu" button
-
Wait for seeding to complete
- ✅ Firebase Authentication (Email & Google)
- ✅ Firestore Database Integration
- ✅ Article Browse by Category
- ✅ Search Functionality
- ✅ Save/Bookmark Articles
- ✅ User Profile
- ✅ Settings Screen
- ✅ Database Seeding Tool
- ✅ Responsive Mobile Design
- ✅ TypeScript Support
npx expo install --fix- Check your firebaseConfig credentials
- Ensure you're connected to the internet
- Verify Firestore security rules
- Verify all OAuth client IDs are correct
- For Android: Add SHA-1 fingerprint to Firebase
- For iOS: Download and add GoogleService-Info.plist
npx expo start -cMake sure all screens are imported in AppNavigator.tsx
After seeding, create these accounts in Firebase Console:
Admin Account:
- Email: admin@news.vn
- Password: admin123
- Role: admin (in Firestore)
User Account:
- Email: user@news.vn
- Password: user123
- Role: user (in Firestore)
- ✅ Customize the app colors/theme
- ✅ Add more article categories
- ✅ Implement comments feature
- ✅ Add push notifications
- ✅ Implement admin dashboard
- ✅ Add offline mode
- ✅ Optimize images
- ✅ Add analytics
If you encounter any issues:
- Check the console for error messages
- Verify all dependencies are installed
- Ensure Firebase is configured correctly
- Check that all files are in the correct directories
Your app should now be running with:
- User authentication
- Article browsing
- Search functionality
- Saved articles
- Profile management
- Database seeding tool
Happy coding! 🚀