Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add auto deploy, update example app, update readme #19

Merged
merged 4 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "flutter-map-plugins"
}
}
79 changes: 79 additions & 0 deletions .github/workflows/on-commit-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Test & Build `main`
on:
push:
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
name: Build Android
steps:
- name: Checkout project
uses: actions/checkout@v3
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Install melos
run: dart pub global activate melos
- name: Install coverde
run: dart pub global activate coverde
- name: Bootstrap melos
run: melos bootstrap
- name: Run tests with coverage
run: melos run test_with_coverage --no-select
- name: Run Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build-android:
runs-on: ubuntu-latest
name: Build Android
needs: [ test ]
steps:
- name: Checkout project
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '21'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Build APK
working-directory: example
run: flutter build apk
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: apk
path: example/build/app/outputs/flutter-apk/app-release.apk
build-web:
runs-on: ubuntu-latest
needs: [ test ]
if: github.repository == 'josxha/flutter_map_plugins'
defaults:
run:
working-directory: ./example
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Build Web
run: flutter build web
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_FLUTTER_MAP_PLUGINS }}'
channelId: live
projectId: flutter-map-plugins

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Test & Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
Expand Down
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# Plugins for the flutter_map ecosystem

This repository contains multiple flutter packages that extend the
functionality of [flutter_map](https://pub.dev/packages/flutter_map).

A combined example app can be found under
[./example](https://github.com/josxha/flutter_map_plugins).

[![stars](https://badgen.net/github/stars/josxha/flutter_map_plugins?label=stars&color=green&icon=github)](https://github.com/josxha/flutter_map_plugins/stargazers)
[![codecov](https://codecov.io/gh/josxha/flutter_map_plugins/graph/badge.svg?token=5045489G7X)](https://codecov.io/gh/josxha/flutter_map_plugins)

[![GitHub last commit](https://img.shields.io/github/last-commit/josxha/flutter_map_plugins)](https://github.com/josxha/flutter_map_plugins)
[![Issues](https://img.shields.io/github/issues/josxha/flutter_map_plugins)](https://github.com/josxha/flutter_map_plugins/issues)
[![Open PRs](https://badgen.net/github/open-prs/josxha/flutter_map_cache?label=Open+PRs&color=green)](https://GitHub.com/josxha/flutter_map_plugins/pulls)

### [flutter_map_cache](https://pub.dev/packages/flutter_map_cache)
A combined example app can be found under
[./example](https://github.com/josxha/flutter_map_plugins).

## [flutter_map_cache](https://pub.dev/packages/flutter_map_cache)

[![Pub Version](https://img.shields.io/pub/v/flutter_map_cache)](https://pub.dev/packages/flutter_map_cache)
[![likes](https://img.shields.io/pub/likes/flutter_map_cache?logo=flutter)](https://pub.dev/packages/flutter_map_cache)
[![Pub Popularity](https://img.shields.io/pub/popularity/flutter_map_cache)](https://pub.dev/packages/flutter_map_cache)

A slim yet powerful caching plugin for flutter_map tile layers. Supports any
storage backend you would possibly want.
Expand All @@ -21,7 +26,11 @@ storage backend you would possibly want.
and flutter_map.
- Support for tile cancellation

### [flutter_map_pmtiles](https://pub.dev/packages/flutter_map_pmtiles)
## [flutter_map_pmtiles](https://pub.dev/packages/flutter_map_pmtiles)

[![Pub Version](https://img.shields.io/pub/v/flutter_map_pmtiles)](https://pub.dev/packages/flutter_map_pmtiles)
[![likes](https://img.shields.io/pub/likes/flutter_map_pmtiles?logo=flutter)](https://pub.dev/packages/flutter_map_pmtiles)
[![Pub Popularity](https://img.shields.io/pub/popularity/flutter_map_pmtiles)](https://pub.dev/packages/flutter_map_pmtiles)

This package provides the `PmTilesTileProvider` that can be used with
flutter_map tile layers.
Expand All @@ -33,7 +42,11 @@ flutter_map tile layers.
learn more about
PMTiles.

### [vector_map_tiles_pmtiles](https://pub.dev/packages/vector_map_tiles_pmtiles)
## [vector_map_tiles_pmtiles](https://pub.dev/packages/vector_map_tiles_pmtiles)

[![Pub Version](https://img.shields.io/pub/v/vector_map_tiles_pmtiles)](https://pub.dev/packages/vector_map_tiles_pmtiles)
[![likes](https://img.shields.io/pub/likes/vector_map_tiles_pmtiles?logo=flutter)](https://pub.dev/packages/vector_map_tiles_pmtiles)
[![Pub Popularity](https://img.shields.io/pub/popularity/vector_map_tiles_pmtiles)](https://pub.dev/packages/vector_map_tiles_pmtiles)

This package provides the `PmTilesVectorTileProvider` that can be used with
the [vector_map_tiles](https://pub.dev/packages/vector_map_tiles) which itself
Expand Down
87 changes: 60 additions & 27 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_map_plugins_example/flutter_map_cache/page.dart';
import 'package:flutter_map_plugins_example/flutter_map_pmtiles/page.dart';
import 'package:flutter_map_plugins_example/vector_map_tiles_pmtiles/page.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:url_strategy/url_strategy.dart';

void main() {
setPathUrlStrategy();
runApp(const MyApp());
}

Expand All @@ -17,7 +22,13 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.white),
),
home: const Material(child: SelectionPage()),
initialRoute: '/',
routes: <String, WidgetBuilder>{
'/': (context) => const SelectionPage(),
'flutter_map_cache': (context) => const FlutterMapCachePage(),
'flutter_map_pmtiles': (context) => const FlutterMapPmTilesPage(),
'vector_map_tiles_pmtiles': (context) => VectorMapTilesPmTilesPage(),
},
);
}
}
Expand All @@ -27,67 +38,89 @@ class SelectionPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
final children = [
const children = [
SelectionItemWidget(
title: 'flutter_map_cache',
desc: 'A slim yet powerful caching plugin for flutter_map '
'tile layers.',
pageBuilder: (context) => const FlutterMapCachePage(),
routeName: 'flutter_map_cache',
),
SelectionItemWidget(
title: 'flutter_map_pmtiles',
desc: 'PMTiles for flutter_map',
pageBuilder: (context) => const FlutterMapPmTilesPage(),
routeName: 'flutter_map_pmtiles',
),
SelectionItemWidget(
title: 'vector_map_tiles_pmtiles',
desc: 'PMTiles for vector_map_files / flutter_map',
pageBuilder: (context) => VectorMapTilesPmTilesPage(),
routeName: 'vector_map_tiles_pmtiles',
),
];

final size = MediaQuery.sizeOf(context);

if (size.width > 900) {
return Padding(
padding: const EdgeInsets.all(8),
child: GridView.count(
crossAxisCount: 2,
childAspectRatio: 5,
children: children,
final width = MediaQuery.sizeOf(context).width;
final githubButton = width < 350
? IconButton(onPressed: _openGithub, icon: const Icon(Icons.link))
: TextButton(
onPressed: _openGithub,
child: const Text('Source Code'),
);
return Scaffold(
appBar: AppBar(
title: const Text('flutter_map_plugins'),
actions: [githubButton],
),
body: ColoredBox(
color: Colors.blueGrey.withOpacity(0.3),
child: Padding(
padding: const EdgeInsets.all(8),
child: GridView.count(
crossAxisCount: max(width ~/ 250, 1),
childAspectRatio: 2,
children: children,
),
),
);
}
return Padding(
padding: const EdgeInsets.all(8),
child: ListView(
children: children,
),
);
}

void _openGithub() => launchUrlString(
'https://github.com/josxha/flutter_map_plugins',
);
}

class SelectionItemWidget extends StatelessWidget {
static const _titleStyle = TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
);
final String title;
final String desc;
final WidgetBuilder pageBuilder;
final String routeName;

const SelectionItemWidget({
super.key,
required this.title,
required this.desc,
required this.pageBuilder,
required this.routeName,
});

@override
Widget build(BuildContext context) {
return Card(
color: Colors.white,
child: InkWell(
onTap: () =>
Navigator.of(context).push(MaterialPageRoute(builder: pageBuilder)),
child: ListTile(
title: Text(title),
subtitle: Text(desc),
onTap: () => Navigator.of(context).pushNamed(routeName),
child: Padding(
padding: const EdgeInsets.all(12),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(title, style: _titleStyle, textAlign: TextAlign.center),
const Spacer(),
Text(desc, textAlign: TextAlign.center),
const Spacer(),
],
),
),
),
);
Expand Down
4 changes: 4 additions & 0 deletions example/linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
#include "generated_plugin_registrant.h"

#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
}
1 change: 1 addition & 0 deletions example/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

list(APPEND FLUTTER_PLUGIN_LIST
sqlite3_flutter_libs
url_launcher_linux
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
Expand Down
2 changes: 2 additions & 0 deletions example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import Foundation
import connectivity_plus
import path_provider_foundation
import sqlite3_flutter_libs
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
2 changes: 2 additions & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ dependencies:
# commom packages
flutter_map: ^6.0.0
latlong2: ^0.9.0
url_launcher: ^6.2.4
url_strategy: ^0.2.0

# flutter_map_cache specific packages
flutter_map_cache:
Expand Down
Loading
Loading