PBAR
Browse files
src/App.svelte
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
import { authStore } from './lib/stores/auth';
|
4 |
import { uiStore } from './lib/stores/ui';
|
5 |
import AppHeader from './lib/components/Layout/AppHeader.svelte';
|
|
|
6 |
import TabBar, { type TabId } from './lib/components/Layout/TabBar.svelte';
|
7 |
import Scanner from './lib/components/Pages/Scanner.svelte';
|
8 |
import Encounters from './lib/components/Pages/Encounters.svelte';
|
@@ -122,6 +123,7 @@
|
|
122 |
|
123 |
<div class="app">
|
124 |
{#if !isDetailPageOpen}
|
|
|
125 |
<AppHeader {hfAuth} currentTab={tabNames[activeTab]} />
|
126 |
{/if}
|
127 |
|
|
|
3 |
import { authStore } from './lib/stores/auth';
|
4 |
import { uiStore } from './lib/stores/ui';
|
5 |
import AppHeader from './lib/components/Layout/AppHeader.svelte';
|
6 |
+
import ProgressBar from './lib/components/Layout/ProgressBar.svelte';
|
7 |
import TabBar, { type TabId } from './lib/components/Layout/TabBar.svelte';
|
8 |
import Scanner from './lib/components/Pages/Scanner.svelte';
|
9 |
import Encounters from './lib/components/Pages/Encounters.svelte';
|
|
|
123 |
|
124 |
<div class="app">
|
125 |
{#if !isDetailPageOpen}
|
126 |
+
<ProgressBar />
|
127 |
<AppHeader {hfAuth} currentTab={tabNames[activeTab]} />
|
128 |
{/if}
|
129 |
|
src/lib/components/Layout/ProgressBar.svelte
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { onMount } from 'svelte';
|
3 |
+
import { getOrCreateGameState } from '$lib/db/gameState';
|
4 |
+
import type { GameState } from '$lib/db/schema';
|
5 |
+
|
6 |
+
let gameState: GameState | null = $state(null);
|
7 |
+
|
8 |
+
// Progress bar color based on progress
|
9 |
+
const progressColor = $derived(getProgressColor(gameState?.progressPoints || 0));
|
10 |
+
|
11 |
+
function getProgressColor(points: number): string {
|
12 |
+
const progress = points / 1000;
|
13 |
+
if (progress < 0.2) return '#4caf50'; // green
|
14 |
+
if (progress < 0.4) return '#ffc107'; // yellow
|
15 |
+
if (progress < 0.6) return '#ff9800'; // orange
|
16 |
+
if (progress < 0.8) return '#f44336'; // red
|
17 |
+
return '#9c27b0'; // purple
|
18 |
+
}
|
19 |
+
|
20 |
+
onMount(async () => {
|
21 |
+
// Load game state
|
22 |
+
gameState = await getOrCreateGameState();
|
23 |
+
|
24 |
+
// Refresh game state periodically
|
25 |
+
const interval = setInterval(async () => {
|
26 |
+
gameState = await getOrCreateGameState();
|
27 |
+
}, 5000); // Update every 5 seconds
|
28 |
+
|
29 |
+
return () => clearInterval(interval);
|
30 |
+
});
|
31 |
+
</script>
|
32 |
+
|
33 |
+
{#if gameState}
|
34 |
+
<div class="progress-container">
|
35 |
+
<div class="progress-bar">
|
36 |
+
<div class="progress-fill" style="width: {(gameState.progressPoints / 1000) * 100}%; background-color: {progressColor}"></div>
|
37 |
+
</div>
|
38 |
+
<span class="progress-stats">👥 {gameState.trainersDefeated} 📷 {gameState.picletsCapured}</span>
|
39 |
+
</div>
|
40 |
+
{/if}
|
41 |
+
|
42 |
+
<style>
|
43 |
+
.progress-container {
|
44 |
+
display: flex;
|
45 |
+
align-items: center;
|
46 |
+
gap: 0.75rem;
|
47 |
+
padding: 0.5rem 1rem;
|
48 |
+
background: white;
|
49 |
+
border-bottom: 1px solid #f0f0f0;
|
50 |
+
}
|
51 |
+
|
52 |
+
.progress-bar {
|
53 |
+
flex: 1;
|
54 |
+
background: #f0f0f0;
|
55 |
+
height: 6px;
|
56 |
+
border-radius: 3px;
|
57 |
+
overflow: hidden;
|
58 |
+
}
|
59 |
+
|
60 |
+
.progress-fill {
|
61 |
+
height: 100%;
|
62 |
+
transition: width 0.8s ease;
|
63 |
+
}
|
64 |
+
|
65 |
+
.progress-stats {
|
66 |
+
font-size: 0.875rem;
|
67 |
+
color: #666;
|
68 |
+
font-weight: 500;
|
69 |
+
white-space: nowrap;
|
70 |
+
}
|
71 |
+
</style>
|
src/lib/components/Pages/Encounters.svelte
CHANGED
@@ -9,7 +9,6 @@
|
|
9 |
import Battle from './Battle.svelte';
|
10 |
|
11 |
let encounters: Encounter[] = [];
|
12 |
-
let gameState: GameState | null = null;
|
13 |
let isLoading = true;
|
14 |
let isRefreshing = false;
|
15 |
|
@@ -26,9 +25,6 @@
|
|
26 |
async function loadEncounters() {
|
27 |
isLoading = true;
|
28 |
try {
|
29 |
-
// Load game state
|
30 |
-
gameState = await getOrCreateGameState();
|
31 |
-
|
32 |
// Get current encounters
|
33 |
const currentEncounters = await EncounterService.getCurrentEncounters();
|
34 |
|
@@ -107,7 +103,6 @@
|
|
107 |
try {
|
108 |
await EncounterService.forceEncounterRefresh();
|
109 |
encounters = await EncounterService.generateEncounters();
|
110 |
-
gameState = await getOrCreateGameState();
|
111 |
} catch (error) {
|
112 |
console.error('Error refreshing encounters:', error);
|
113 |
}
|
@@ -258,14 +253,6 @@
|
|
258 |
/>
|
259 |
{:else}
|
260 |
<div class="encounters-page">
|
261 |
-
<div class="header">
|
262 |
-
{#if gameState}
|
263 |
-
<div class="progress-bar">
|
264 |
-
<div class="progress-fill" style="width: {(gameState.progressPoints / 1000) * 100}%"></div>
|
265 |
-
<span class="progress-text">{gameState.progressPoints}/1000</span>
|
266 |
-
</div>
|
267 |
-
{/if}
|
268 |
-
</div>
|
269 |
|
270 |
{#if isLoading}
|
271 |
<div class="loading">
|
@@ -345,41 +332,6 @@
|
|
345 |
padding-bottom: 5rem;
|
346 |
}
|
347 |
|
348 |
-
.header {
|
349 |
-
margin-bottom: 1.5rem;
|
350 |
-
}
|
351 |
-
|
352 |
-
.header h1 {
|
353 |
-
margin: 0 0 1rem;
|
354 |
-
font-size: 1.75rem;
|
355 |
-
font-weight: 700;
|
356 |
-
color: #1a1a1a;
|
357 |
-
}
|
358 |
-
|
359 |
-
.progress-bar {
|
360 |
-
background: #e0e0e0;
|
361 |
-
height: 24px;
|
362 |
-
border-radius: 12px;
|
363 |
-
overflow: hidden;
|
364 |
-
position: relative;
|
365 |
-
}
|
366 |
-
|
367 |
-
.progress-fill {
|
368 |
-
background: linear-gradient(90deg, #4caf50, #66bb6a);
|
369 |
-
height: 100%;
|
370 |
-
transition: width 0.3s ease;
|
371 |
-
}
|
372 |
-
|
373 |
-
.progress-text {
|
374 |
-
position: absolute;
|
375 |
-
top: 50%;
|
376 |
-
left: 50%;
|
377 |
-
transform: translate(-50%, -50%);
|
378 |
-
font-size: 0.75rem;
|
379 |
-
font-weight: 600;
|
380 |
-
color: #333;
|
381 |
-
}
|
382 |
-
|
383 |
.loading, .empty-state {
|
384 |
display: flex;
|
385 |
flex-direction: column;
|
|
|
9 |
import Battle from './Battle.svelte';
|
10 |
|
11 |
let encounters: Encounter[] = [];
|
|
|
12 |
let isLoading = true;
|
13 |
let isRefreshing = false;
|
14 |
|
|
|
25 |
async function loadEncounters() {
|
26 |
isLoading = true;
|
27 |
try {
|
|
|
|
|
|
|
28 |
// Get current encounters
|
29 |
const currentEncounters = await EncounterService.getCurrentEncounters();
|
30 |
|
|
|
103 |
try {
|
104 |
await EncounterService.forceEncounterRefresh();
|
105 |
encounters = await EncounterService.generateEncounters();
|
|
|
106 |
} catch (error) {
|
107 |
console.error('Error refreshing encounters:', error);
|
108 |
}
|
|
|
253 |
/>
|
254 |
{:else}
|
255 |
<div class="encounters-page">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
|
257 |
{#if isLoading}
|
258 |
<div class="loading">
|
|
|
332 |
padding-bottom: 5rem;
|
333 |
}
|
334 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
.loading, .empty-state {
|
336 |
display: flex;
|
337 |
flex-direction: column;
|