Securrency-OSS / mirai

Mirai is a Server-Driven UI (SDUI) library for Flutter. Mirai allows you to build beautiful cross-platform applications with JSON in real time.
https://pub.dev/packages/mirai
MIT License
478 stars 58 forks source link

Feat: base implementation of google_map feature on framework #288

Open mtellect opened 2 months ago

mtellect commented 2 months ago

Description

This PR is intended to kickstart the process of adding a base implementation for google_maps support on framework

Create a .env file at the root of your project and add:

GOOGLE_MAP_KEY_ANDROID=YOUR_ANDROID_KEY
GOOGLE_MAP_KEY_IOS=YOUR_IOS_KEY

On Android Manifest add:

        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/GOOGLE_MAP_KEY_ANDROID"
            tools:replace="android:value" />

On iOS AppDelegate.swift add:

import UIKit
import Flutter

import flutter_config
import GoogleMaps

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {

        //[Google map key]
        let googleMapKey = FlutterConfigPlugin.env(for: "GOOGLE_MAP_KEY_IOS")
        GMSServices.provideAPIKey(googleMapKey!)

        GeneratedPluginRegistrant.register(with: self)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
}

Json example:

{
  "type": "scaffold",
  "appBar": {
    "type": "appBar",
    "title": {
      "type": "text",
      "data": "Google Map Example"
    }
  },
  "body": {
    "type": "googleMap",
    "initialCameraPosition": {
      "target": {
        "latitude": 37.42796133580664,
        "longitude": -122.085749655962
      },
      "zoom": 14.4746,
      "tilt": 10
    },
    "compassEnabled": true,
    "mapToolbarEnabled": true,
    "indoorViewEnabled": true,
    "trafficEnabled": true,
    "buildingsEnabled": true,
    "myLocationButtonEnabled": true,
    "padding": {
      "left": 50,
      "right": 10,
      "bottom": 20
    }
  }
}

Type of Change

divyanshub024 commented 1 month ago

Hey @mtellect, Thank you so much for this amazing contribution 🎉. By far this is probably the biggest single contribution. 🥇

I have one request. I don't want to make the main framework bloated. Cab we create a separate package for mirai_google_map in packages folder

mtellect commented 1 month ago

Hi @divyanshub024 , i'd refactor into packages.

divyanshub024 commented 1 month ago

Hey @mtellect, let me know if you have any questions or need any help. :)

mtellect commented 1 month ago

Hi @divyanshub024 i'd make updates soon as i get some bandwidth. cheers!