Просмотр исходного кода

Merge branch 'feature/diaria-kay-notificação-chamativa' of Softpar/sfp_front_vue_diarista_prestador into development

zntt 7 часов назад
Родитель
Сommit
e2a063b8de

Разница между файлами не показана из-за своего большого размера
+ 710 - 4
package-lock.json


+ 2 - 1
package.json

@@ -12,7 +12,7 @@
     "test": "echo \"No test specified\" && exit 0",
     "dev": "cross-env APP_ENV=dev quasar dev",
     "dev:staging": "APP_ENV=staging quasar dev",
-    "dev:android": "APP_ENV=dev quasar dev -m capacitor -T android",
+    "dev:android": "cross-env APP_ENV=dev quasar dev -m capacitor -T android",
     "dev:ios": "APP_ENV=dev quasar dev -m capacitor -T ios",
     "build": "APP_ENV=prod quasar build",
     "build:dev": "APP_ENV=dev quasar build",
@@ -49,6 +49,7 @@
   "devDependencies": {
     "@bufbuild/buf": "^1.54.0",
     "@bufbuild/protoc-gen-es": "^2.5.1",
+    "@capacitor/cli": "^7.6.8",
     "@capacitor/keyboard": "^7.0.1",
     "@capacitor/preferences": "^7.0.1",
     "@capacitor/status-bar": "^7.0.1",

+ 39 - 0
src-capacitor/android/app/src/main/java/br/com/diarista/provider/MainActivity.java

@@ -3,6 +3,11 @@ package br.com.diarista.provider;
 import android.graphics.Color;
 import android.os.Bundle;
 import android.webkit.WebView;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.media.AudioAttributes;
+import android.net.Uri;
+import android.os.Build;
 
 import com.getcapacitor.BridgeActivity;
 
@@ -14,6 +19,9 @@ public class MainActivity extends BridgeActivity {
         // WebView, então o WebView precisa ser transparente onde o mapa é exibido.
         // (O background do body cobre isso nas telas normais — só o LocationMapDialog
         //  torna a cadeia html/body/#q-app transparente para revelar o mapa.)
+
+        createNotificationChannel();
+
         getBridge().getWebView().setBackgroundColor(Color.TRANSPARENT);
     }
 
@@ -23,4 +31,35 @@ public class MainActivity extends BridgeActivity {
         WebView webview = getBridge().getWebView();
         webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
     }
+
+    private void createNotificationChannel() {
+    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+
+        Uri sound = Uri.parse(
+                "android.resource://" + getPackageName() + "/" + R.raw.diaria
+        );
+
+        AudioAttributes audioAttributes = new AudioAttributes.Builder()
+                .setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
+                .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
+                .build();
+
+        NotificationChannel channel = new NotificationChannel(
+                "diaria",
+                "Novas Diárias",
+                NotificationManager.IMPORTANCE_HIGH
+        );
+
+        channel.setDescription("Canal para novas solicitações de diária");
+        channel.setShowBadge(true);
+        channel.enableLights(true);
+        channel.enableVibration(true);
+        channel.setSound(sound, audioAttributes);
+
+        NotificationManager notificationManager =
+                getSystemService(NotificationManager.class);
+
+        notificationManager.createNotificationChannel(channel);
+    }
+}
 }

BIN
src-capacitor/android/app/src/main/res/raw/diaria.wav


+ 1 - 0
src-capacitor/package-lock.json

@@ -98,6 +98,7 @@
       "resolved": "https://registry.npmjs.org/@capacitor/core/-/core-7.6.8.tgz",
       "integrity": "sha512-x1xfxvNcTSnj6OoYaAB0n0a0HRvi5f2YjcVnMLxpMhbHDgGDAzzN9z8cnPCYV+SKTvqGF1hezHm82Op32XaAGg==",
       "license": "MIT",
+      "peer": true,
       "dependencies": {
         "tslib": "^2.1.0"
       }

+ 18 - 3
src/App.vue

@@ -17,6 +17,7 @@ defineOptions({
 const { locale } = useI18n();
 
 const $q = useQuasar();
+
 const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches
   ? "dark"
   : "light";
@@ -37,13 +38,27 @@ watch(
 
 onBeforeMount(async () => {
   const isNative = Capacitor.isNativePlatform();
-  if (isNative) await StatusBar.show();
+
   const { value: themePref } = await Preferences.get({ key: "theme" });
   const theme = themePref || systemTheme;
-  if (isNative) await StatusBar.setStyle({ style: Style.Dark });
+
+  if (isNative) {
+  await StatusBar.show();
+
+  await StatusBar.setBackgroundColor({
+    color: "#FFFFFF",
+  });
+
+  await StatusBar.setStyle({
+    style: Style.Dark,
+  });
+}
+
   const { value: localePref } = await Preferences.get({ key: "locale" });
   const userLocale = localePref || window.navigator.language;
+
   console.log(theme, userLocale);
-  $q.dark.set(theme == "dark");
+
+  $q.dark.set(theme === "dark");
 });
 </script>

+ 2 - 0
src/i18n/locales/pt.json

@@ -531,6 +531,8 @@
     "placeholder_name": "Digite seu nome",
     "placeholder_email": "Digite seu e-mail",
     "placeholder_phone": "Digite seu telefone",
+    "notifications": "Notificações",
+    "push_notifications": "Receber notificações",
     "bank_data": {
       "title": "Dados bancários",
       "description": "Contas para receber seus pagamentos",

+ 35 - 0
src/pages/profile/ProfileEditDialog.vue

@@ -134,6 +134,24 @@
                 :options="translatedGenderOptions"
               />
             </div>
+
+            <!-- NOVA SEÇÃO -->
+            <div>
+              <div class="font12 fontbold q-mb-sm text-grey-8">
+                {{ $t("profile.notifications") }}
+              </div>
+
+              <div class="notification-card">
+                <span class="font14 text-text">
+                  {{ $t("profile.push_notifications") }}
+                </span>
+
+                <q-toggle
+                  v-model="form.push_notifications_enabled"
+                  color="primary"
+                />
+              </div>
+            </div>
           </div>
 
           <q-space />
@@ -194,6 +212,7 @@ const { form, getUpdatedFields, hasUpdatedFields, setUpdateFormAsOriginal } =
     gender: "",
     name: "",
     phone: "",
+    push_notifications_enabled: false,
   });
 
 const capturingPhoto = ref(false);
@@ -288,6 +307,7 @@ const submitUpdate = async () => {
 
   try {
     const userData = { ...getUpdatedFields.value };
+    console.log("Campos atualizados:", userData);
 
     let data = null;
 
@@ -328,6 +348,7 @@ onMounted(() => {
   form.gender = data.gender || "";
   form.name = data.name || "";
   form.phone = data.phone || "";
+  form.push_notifications_enabled = data.push_notifications_enabled ?? false;
   profilePhoto.value = data.profile_photo || null;
   providerId.value = data.provider_id || data.provider?.id || null;
   userId.value = data.id;
@@ -348,4 +369,18 @@ onMounted(() => {
 .gender-options :deep(.q-radio__inner--falsy) {
   color: rgba(0, 0, 0, 0.62);
 }
+
+.notification-card {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+
+  min-height: 56px;
+  padding: 0 16px;
+
+  border: 1px solid #e0e0e0;
+  border-radius: 8px;
+
+  background: #fff;
+}
 </style>

Некоторые файлы не были показаны из-за большого количества измененных файлов