Compare commits
6 Commits
v0.1.17
...
3a54a077f3
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a54a077f3 | |||
| cf88a9a371 | |||
| 5feb535cf3 | |||
| 2d23207497 | |||
| c7c5b3682d | |||
| 321a310add |
@@ -9,26 +9,70 @@ on:
|
|||||||
- main
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
actions: read
|
actions: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_apk:
|
calculate-version:
|
||||||
name: Build Flutter APK
|
name: Calculate Version
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
new_version: ${{ steps.version.outputs.new_version }}
|
||||||
|
bump_type: ${{ steps.version.outputs.bump_type }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
# - name: Cache pub deps
|
- name: Get commit message and determine version bump
|
||||||
# uses: actions/cache@v3
|
id: version
|
||||||
# with:
|
run: |
|
||||||
# path: ~/.pub-cache
|
COMMIT_MSG="${{ github.event.head_commit.message }}"
|
||||||
# key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
|
|
||||||
# restore-keys: ${{ runner.os }}-pub-
|
if [[ $COMMIT_MSG == [fix]* ]]; then
|
||||||
|
BUMP_TYPE="patch"
|
||||||
|
elif [[ $COMMIT_MSG == [feature]* ]]; then
|
||||||
|
BUMP_TYPE="minor"
|
||||||
|
elif [[ $COMMIT_MSG == [release]* ]]; then
|
||||||
|
BUMP_TYPE="major"
|
||||||
|
else
|
||||||
|
BUMP_TYPE="none"
|
||||||
|
fi
|
||||||
|
|
||||||
|
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||||
|
LATEST_TAG=${LATEST_TAG#v}
|
||||||
|
|
||||||
|
IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_TAG"
|
||||||
|
MAJOR=${MAJOR:-0}
|
||||||
|
MINOR=${MINOR:-0}
|
||||||
|
PATCH=${PATCH:-0}
|
||||||
|
|
||||||
|
if [ "$BUMP_TYPE" == "major" ]; then
|
||||||
|
((MAJOR++))
|
||||||
|
MINOR=0
|
||||||
|
PATCH=0
|
||||||
|
elif [ "$BUMP_TYPE" == "minor" ]; then
|
||||||
|
((MINOR++))
|
||||||
|
PATCH=0
|
||||||
|
elif [ "$BUMP_TYPE" == "patch" ]; then
|
||||||
|
((PATCH++))
|
||||||
|
fi
|
||||||
|
|
||||||
|
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
|
||||||
|
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
build_apk:
|
||||||
|
name: Build Flutter APK
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: calculate-version
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Java (Temurin 17)
|
- name: Setup Java (Temurin 17)
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
@@ -40,40 +84,68 @@ jobs:
|
|||||||
uses: android-actions/setup-android@v3
|
uses: android-actions/setup-android@v3
|
||||||
with:
|
with:
|
||||||
packages: "platform-tools platforms;android-36 build-tools;36.0.0"
|
packages: "platform-tools platforms;android-36 build-tools;36.0.0"
|
||||||
|
|
||||||
- name: Setup Flutter
|
- name: Setup Flutter
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
channel: stable
|
channel: stable
|
||||||
|
|
||||||
- run: flutter --version
|
- run: flutter --version
|
||||||
- run: flutter doctor
|
- run: flutter doctor
|
||||||
|
|
||||||
- name: Get dependencies
|
- name: Get dependencies
|
||||||
run: flutter pub get
|
run: flutter pub get
|
||||||
|
|
||||||
|
- name: Update pubspec.yaml with new version
|
||||||
|
run: |
|
||||||
|
sed -i "s/^version: .*/version: ${{ needs.calculate-version.outputs.new_version }}+${{ github.run_number }}/" pubspec.yaml
|
||||||
|
cat pubspec.yaml | grep version
|
||||||
|
|
||||||
- name: Build APK
|
- name: Build APK
|
||||||
run: flutter build apk --release
|
run: flutter build apk --release
|
||||||
|
|
||||||
- name: Upload APK artifact
|
- name: Upload APK artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: flutter-apk
|
name: flutter-apk
|
||||||
path: build/app/outputs/flutter-apk/app-release.apk
|
path: build/app/outputs/flutter-apk/app-release.apk
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
|
||||||
|
create-release:
|
||||||
|
name: Create Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [calculate-version, build_apk]
|
||||||
|
if: needs.calculate-version.outputs.bump_type != 'none'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Download APK artifact
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: flutter-apk
|
||||||
|
|
||||||
|
- name: Create Git tag
|
||||||
|
run: |
|
||||||
|
NEW_TAG="v${{ needs.calculate-version.outputs.new_version }}"
|
||||||
|
git config --local user.name "GitHub Actions"
|
||||||
|
git config --local user.email "actions@github.com"
|
||||||
|
git tag -a "$NEW_TAG" -m "Release ${{ needs.calculate-version.outputs.new_version }}"
|
||||||
|
git push origin "$NEW_TAG"
|
||||||
|
|
||||||
- name: Create Gitea release
|
- name: Create Gitea release
|
||||||
uses: akkuman/gitea-release-action@v1
|
uses: akkuman/gitea-release-action@v1
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.RUNNER_CREATE_RELEASE }}
|
GITEA_TOKEN: ${{ secrets.RUNNER_CREATE_RELEASE }}
|
||||||
with:
|
with:
|
||||||
# tag & name: adjust to your versioning
|
tag_name: "v${{ needs.calculate-version.outputs.new_version }}"
|
||||||
tag_name: "v0.1.${{ github.run_number }}"
|
name: "Flutter Android v${{ needs.calculate-version.outputs.new_version }}"
|
||||||
name: "Flutter Android v0.1.${{ github.run_number }}"
|
body: "Automated build from CI\n\nVersion bump type: ${{ needs.calculate-version.outputs.bump_type }}"
|
||||||
body: "Automated build from CI"
|
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
files: |
|
files: |
|
||||||
build/app/outputs/flutter-apk/app-release.apk
|
build/app/outputs/flutter-apk/app-release.apk
|
||||||
gitea_url: "https://git.skup.in"
|
gitea_url: "https://git.skup.in"
|
||||||
owner: "marco"
|
owner: "marco"
|
||||||
repo: "maps_bookmarks"
|
repo: "maps_bookmarks"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class CollectionsListPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _CollectionsListPageState extends State<CollectionsListPage> {
|
class _CollectionsListPageState extends State<CollectionsListPage> {
|
||||||
bool addingNewBookmark = false;
|
bool addingNewBookmark = false;
|
||||||
|
final bookmarkCountMap = Storage.loadPerCollectionBookmarkCount();
|
||||||
|
|
||||||
Widget bottomSheetBuilder(BuildContext context) {
|
Widget bottomSheetBuilder(BuildContext context) {
|
||||||
final titleTextFieldController = TextEditingController(
|
final titleTextFieldController = TextEditingController(
|
||||||
@@ -53,6 +54,11 @@ class _CollectionsListPageState extends State<CollectionsListPage> {
|
|||||||
title: Text(collection.name),
|
title: Text(collection.name),
|
||||||
onTap: () => navigateToCollection(collection.id),
|
onTap: () => navigateToCollection(collection.id),
|
||||||
onLongPress: () => onEditCollection(collection),
|
onLongPress: () => onEditCollection(collection),
|
||||||
|
leading: const Icon(Icons.list_rounded),
|
||||||
|
trailing: Text(
|
||||||
|
bookmarkCountMap[collection.id]?.toString() ?? '0',
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class SearchPage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
SearchBarWidget(
|
SearchBarWidget(
|
||||||
onEditingComplete: context.read<SearchProvider>().setSearchText,
|
onEditingComplete: context.read<SearchProvider>().setSearchText,
|
||||||
|
onResetSearch: context.read<SearchProvider>().removeSearchText,
|
||||||
),
|
),
|
||||||
Expanded(child: SearchResultsWidget()),
|
Expanded(child: SearchResultsWidget()),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -8,5 +8,10 @@ class SearchProvider extends ChangeNotifier {
|
|||||||
if (!silent) notifyListeners();
|
if (!silent) notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeSearchText({bool silent = false}) {
|
||||||
|
_searchText = '';
|
||||||
|
if (!silent) notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
String get searchText => _searchText;
|
String get searchText => _searchText;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ class Storage {
|
|||||||
return allBookmarks.where((b) => b.collectionId == collectionId).toList();
|
return allBookmarks.where((b) => b.collectionId == collectionId).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Map<int, int> loadPerCollectionBookmarkCount() {
|
||||||
|
return loadBookmarks().fold(<int, int>{}, (map, bookmark) {
|
||||||
|
map[bookmark.collectionId] ??= 0;
|
||||||
|
map[bookmark.collectionId] = map[bookmark.collectionId]! + 1;
|
||||||
|
return map;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static Future<void> addBookmark(Bookmark bookmark) async {
|
static Future<void> addBookmark(Bookmark bookmark) async {
|
||||||
final bookmarks = loadBookmarks();
|
final bookmarks = loadBookmarks();
|
||||||
bookmarks.add(bookmark);
|
bookmarks.add(bookmark);
|
||||||
|
|||||||
@@ -1,16 +1,34 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class SearchBarWidget extends StatelessWidget {
|
class SearchBarWidget extends StatelessWidget {
|
||||||
const SearchBarWidget({super.key, required this.onEditingComplete});
|
const SearchBarWidget({
|
||||||
|
super.key,
|
||||||
|
required this.onEditingComplete,
|
||||||
|
required this.onResetSearch,
|
||||||
|
});
|
||||||
|
|
||||||
final Function(String searchString) onEditingComplete;
|
final Function(String searchString) onEditingComplete;
|
||||||
|
final Function() onResetSearch;
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return TextField(onChanged: (text) => onChanged(text, context));
|
|
||||||
}
|
|
||||||
|
|
||||||
void onChanged(String text, BuildContext context) {
|
void onChanged(String text, BuildContext context) {
|
||||||
if (context.mounted) onEditingComplete(text);
|
if (context.mounted) onEditingComplete(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final searchTextController = TextEditingController();
|
||||||
|
return TextField(
|
||||||
|
controller: searchTextController,
|
||||||
|
onChanged: (text) => onChanged(text, context),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
searchTextController.clear();
|
||||||
|
onResetSearch();
|
||||||
|
},
|
||||||
|
icon: Icon(Icons.delete_outline_outlined),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ class SearchResultsWidget extends StatefulWidget {
|
|||||||
class _SearchResultsWidgetState extends State<SearchResultsWidget> {
|
class _SearchResultsWidgetState extends State<SearchResultsWidget> {
|
||||||
final List<Bookmark> allBookmarks = Storage.loadBookmarks();
|
final List<Bookmark> allBookmarks = Storage.loadBookmarks();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void deactivate() {
|
||||||
|
context.read<SearchProvider>().removeSearchText(silent: true);
|
||||||
|
super.deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
Widget bookmarkListItemBuilder(BuildContext context, int index) {
|
Widget bookmarkListItemBuilder(BuildContext context, int index) {
|
||||||
final bookmark = filteredBookmarks.elementAt(index);
|
final bookmark = filteredBookmarks.elementAt(index);
|
||||||
return ListTile(
|
return ListTile(
|
||||||
@@ -31,6 +37,12 @@ class _SearchResultsWidgetState extends State<SearchResultsWidget> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Iterable<Bookmark> get filteredBookmarks => allBookmarks.where(
|
||||||
|
(bookmark) => bookmark.name.toLowerCase().contains(
|
||||||
|
context.watch<SearchProvider>().searchText.toLowerCase(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (filteredBookmarks.isNotEmpty) {
|
if (filteredBookmarks.isNotEmpty) {
|
||||||
@@ -41,10 +53,4 @@ class _SearchResultsWidgetState extends State<SearchResultsWidget> {
|
|||||||
}
|
}
|
||||||
return Center(child: Text('Start searching'));
|
return Center(child: Text('Start searching'));
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterable<Bookmark> get filteredBookmarks => allBookmarks.where(
|
|
||||||
(bookmark) => bookmark.name.toLowerCase().contains(
|
|
||||||
context.watch<SearchProvider>().searchText.toLowerCase(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ description: "A new way to save google maps bookmarks"
|
|||||||
|
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 1.0.0+1
|
version: 0.0.0
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.9.2
|
sdk: ^3.9.2
|
||||||
|
|||||||
Reference in New Issue
Block a user