Compare commits
4 Commits
v0.1.18
...
77a647d17d
| Author | SHA1 | Date | |
|---|---|---|---|
| 77a647d17d | |||
| cf88a9a371 | |||
| 5feb535cf3 | |||
| 2d23207497 |
@@ -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
|
||||||
@@ -45,12 +89,18 @@ jobs:
|
|||||||
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
|
||||||
|
|
||||||
@@ -61,15 +111,37 @@ jobs:
|
|||||||
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: |
|
||||||
|
|||||||
3
l10n.yaml
Normal file
3
l10n.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
arb-dir: lib/l10n
|
||||||
|
template-arb-file: app_en.arb
|
||||||
|
output-localization-file: app_localizations.dart
|
||||||
16
lib/l10n/app_de.arb
Normal file
16
lib/l10n/app_de.arb
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"@@locale": "de",
|
||||||
|
"addToCollection": "Speichern in {collection_name}",
|
||||||
|
"@addToCollection": {
|
||||||
|
"placeholders": {
|
||||||
|
"collection_name" : {
|
||||||
|
"type": "String"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cancel": "Abbrechen",
|
||||||
|
"chooseCollection": "Sammlung auswählen",
|
||||||
|
"collections": "Sammlungen",
|
||||||
|
"tipCreateCollections": "Erstelle deine erste Sammlung!",
|
||||||
|
"search": "Suche"
|
||||||
|
}
|
||||||
16
lib/l10n/app_en.arb
Normal file
16
lib/l10n/app_en.arb
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"@@locale": "en",
|
||||||
|
"addToCollection": "Add to {collection_name}",
|
||||||
|
"@addToCollection": {
|
||||||
|
"placeholders": {
|
||||||
|
"collection_name" : {
|
||||||
|
"type": "String"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"chooseCollection": "Choose Collection",
|
||||||
|
"collections": "Collections",
|
||||||
|
"tipCreateCollections": "Create your first Collection to get started!",
|
||||||
|
"search": "Search"
|
||||||
|
}
|
||||||
170
lib/l10n/app_localizations.dart
Normal file
170
lib/l10n/app_localizations.dart
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
import 'package:intl/intl.dart' as intl;
|
||||||
|
|
||||||
|
import 'app_localizations_de.dart';
|
||||||
|
import 'app_localizations_en.dart';
|
||||||
|
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
|
||||||
|
/// Callers can lookup localized strings with an instance of AppLocalizations
|
||||||
|
/// returned by `AppLocalizations.of(context)`.
|
||||||
|
///
|
||||||
|
/// Applications need to include `AppLocalizations.delegate()` in their app's
|
||||||
|
/// `localizationDelegates` list, and the locales they support in the app's
|
||||||
|
/// `supportedLocales` list. For example:
|
||||||
|
///
|
||||||
|
/// ```dart
|
||||||
|
/// import 'l10n/app_localizations.dart';
|
||||||
|
///
|
||||||
|
/// return MaterialApp(
|
||||||
|
/// localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||||
|
/// supportedLocales: AppLocalizations.supportedLocales,
|
||||||
|
/// home: MyApplicationHome(),
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// ## Update pubspec.yaml
|
||||||
|
///
|
||||||
|
/// Please make sure to update your pubspec.yaml to include the following
|
||||||
|
/// packages:
|
||||||
|
///
|
||||||
|
/// ```yaml
|
||||||
|
/// dependencies:
|
||||||
|
/// # Internationalization support.
|
||||||
|
/// flutter_localizations:
|
||||||
|
/// sdk: flutter
|
||||||
|
/// intl: any # Use the pinned version from flutter_localizations
|
||||||
|
///
|
||||||
|
/// # Rest of dependencies
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// ## iOS Applications
|
||||||
|
///
|
||||||
|
/// iOS applications define key application metadata, including supported
|
||||||
|
/// locales, in an Info.plist file that is built into the application bundle.
|
||||||
|
/// To configure the locales supported by your app, you’ll need to edit this
|
||||||
|
/// file.
|
||||||
|
///
|
||||||
|
/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file.
|
||||||
|
/// Then, in the Project Navigator, open the Info.plist file under the Runner
|
||||||
|
/// project’s Runner folder.
|
||||||
|
///
|
||||||
|
/// Next, select the Information Property List item, select Add Item from the
|
||||||
|
/// Editor menu, then select Localizations from the pop-up menu.
|
||||||
|
///
|
||||||
|
/// Select and expand the newly-created Localizations item then, for each
|
||||||
|
/// locale your application supports, add a new item and select the locale
|
||||||
|
/// you wish to add from the pop-up menu in the Value field. This list should
|
||||||
|
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
|
||||||
|
/// property.
|
||||||
|
abstract class AppLocalizations {
|
||||||
|
AppLocalizations(String locale)
|
||||||
|
: localeName = intl.Intl.canonicalizedLocale(locale.toString());
|
||||||
|
|
||||||
|
final String localeName;
|
||||||
|
|
||||||
|
static AppLocalizations? of(BuildContext context) {
|
||||||
|
return Localizations.of<AppLocalizations>(context, AppLocalizations);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const LocalizationsDelegate<AppLocalizations> delegate =
|
||||||
|
_AppLocalizationsDelegate();
|
||||||
|
|
||||||
|
/// A list of this localizations delegate along with the default localizations
|
||||||
|
/// delegates.
|
||||||
|
///
|
||||||
|
/// Returns a list of localizations delegates containing this delegate along with
|
||||||
|
/// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
|
||||||
|
/// and GlobalWidgetsLocalizations.delegate.
|
||||||
|
///
|
||||||
|
/// Additional delegates can be added by appending to this list in
|
||||||
|
/// MaterialApp. This list does not have to be used at all if a custom list
|
||||||
|
/// of delegates is preferred or required.
|
||||||
|
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
|
||||||
|
<LocalizationsDelegate<dynamic>>[
|
||||||
|
delegate,
|
||||||
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
GlobalCupertinoLocalizations.delegate,
|
||||||
|
GlobalWidgetsLocalizations.delegate,
|
||||||
|
];
|
||||||
|
|
||||||
|
/// A list of this localizations delegate's supported locales.
|
||||||
|
static const List<Locale> supportedLocales = <Locale>[
|
||||||
|
Locale('de'),
|
||||||
|
Locale('en'),
|
||||||
|
];
|
||||||
|
|
||||||
|
/// No description provided for @addToCollection.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Add to {collection_name}'**
|
||||||
|
String addToCollection(String collection_name);
|
||||||
|
|
||||||
|
/// No description provided for @cancel.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Cancel'**
|
||||||
|
String get cancel;
|
||||||
|
|
||||||
|
/// No description provided for @chooseCollection.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Choose Collection'**
|
||||||
|
String get chooseCollection;
|
||||||
|
|
||||||
|
/// No description provided for @collections.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Collections'**
|
||||||
|
String get collections;
|
||||||
|
|
||||||
|
/// No description provided for @tipCreateCollections.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Create your first Collection to get started!'**
|
||||||
|
String get tipCreateCollections;
|
||||||
|
|
||||||
|
/// No description provided for @search.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Search'**
|
||||||
|
String get search;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AppLocalizationsDelegate
|
||||||
|
extends LocalizationsDelegate<AppLocalizations> {
|
||||||
|
const _AppLocalizationsDelegate();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<AppLocalizations> load(Locale locale) {
|
||||||
|
return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool isSupported(Locale locale) =>
|
||||||
|
<String>['de', 'en'].contains(locale.languageCode);
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldReload(_AppLocalizationsDelegate old) => false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppLocalizations lookupAppLocalizations(Locale locale) {
|
||||||
|
// Lookup logic when only language code is specified.
|
||||||
|
switch (locale.languageCode) {
|
||||||
|
case 'de':
|
||||||
|
return AppLocalizationsDe();
|
||||||
|
case 'en':
|
||||||
|
return AppLocalizationsEn();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw FlutterError(
|
||||||
|
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
|
||||||
|
'an issue with the localizations generation tool. Please file an issue '
|
||||||
|
'on GitHub with a reproducible sample app and the gen-l10n configuration '
|
||||||
|
'that was used.',
|
||||||
|
);
|
||||||
|
}
|
||||||
30
lib/l10n/app_localizations_de.dart
Normal file
30
lib/l10n/app_localizations_de.dart
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
// ignore: unused_import
|
||||||
|
import 'package:intl/intl.dart' as intl;
|
||||||
|
import 'app_localizations.dart';
|
||||||
|
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
|
||||||
|
/// The translations for German (`de`).
|
||||||
|
class AppLocalizationsDe extends AppLocalizations {
|
||||||
|
AppLocalizationsDe([String locale = 'de']) : super(locale);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String addToCollection(String collection_name) {
|
||||||
|
return 'Speichern in $collection_name';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get cancel => 'Abbrechen';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get chooseCollection => 'Sammlung auswählen';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get collections => 'Sammlungen';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get tipCreateCollections => 'Erstelle deine erste Sammlung!';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get search => 'Suche';
|
||||||
|
}
|
||||||
31
lib/l10n/app_localizations_en.dart
Normal file
31
lib/l10n/app_localizations_en.dart
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// ignore: unused_import
|
||||||
|
import 'package:intl/intl.dart' as intl;
|
||||||
|
import 'app_localizations.dart';
|
||||||
|
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
|
||||||
|
/// The translations for English (`en`).
|
||||||
|
class AppLocalizationsEn extends AppLocalizations {
|
||||||
|
AppLocalizationsEn([String locale = 'en']) : super(locale);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String addToCollection(String collection_name) {
|
||||||
|
return 'Add to $collection_name';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get cancel => 'Cancel';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get chooseCollection => 'Choose Collection';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get collections => 'Collections';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get tipCreateCollections =>
|
||||||
|
'Create your first Collection to get started!';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get search => 'Search';
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'l10n/app_localizations.dart';
|
||||||
import 'pages/collection_page.dart';
|
import 'pages/collection_page.dart';
|
||||||
import 'pages/collections_list_page.dart';
|
import 'pages/collections_list_page.dart';
|
||||||
import 'pages/search_page.dart';
|
import 'pages/search_page.dart';
|
||||||
@@ -66,6 +68,13 @@ class _MapsBookmarksState extends State<MapsBookmarks>
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
|
localizationsDelegates: [
|
||||||
|
AppLocalizations.delegate,
|
||||||
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
GlobalWidgetsLocalizations.delegate,
|
||||||
|
GlobalCupertinoLocalizations.delegate,
|
||||||
|
],
|
||||||
|
supportedLocales: [Locale('en'), Locale('de')],
|
||||||
navigatorKey: _navigatorKey,
|
navigatorKey: _navigatorKey,
|
||||||
theme: lightTheme,
|
theme: lightTheme,
|
||||||
darkTheme: darkTheme,
|
darkTheme: darkTheme,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../l10n/app_localizations.dart';
|
||||||
import '../model/bookmark.dart';
|
import '../model/bookmark.dart';
|
||||||
import '../model/maps_link_metadata.dart';
|
import '../model/maps_link_metadata.dart';
|
||||||
import '../service/bookmarks_provider.dart';
|
import '../service/bookmarks_provider.dart';
|
||||||
@@ -89,13 +90,15 @@ class _CollectionPageState extends State<CollectionPage> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: selectedMapsLink != null
|
title: selectedMapsLink != null
|
||||||
? Text('Add to ${collection.name}')
|
? Text(
|
||||||
|
AppLocalizations.of(context)!.addToCollection(collection.name),
|
||||||
|
)
|
||||||
: Text(collection.name),
|
: Text(collection.name),
|
||||||
actions: [
|
actions: [
|
||||||
if (selectedMapsLink != null)
|
if (selectedMapsLink != null)
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => provider.removeCurrentMapsLink(),
|
onPressed: () => provider.removeCurrentMapsLink(),
|
||||||
child: Text('Cancel'),
|
child: Text(AppLocalizations.of(context)!.cancel),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../l10n/app_localizations.dart';
|
||||||
import '../model/collection.dart';
|
import '../model/collection.dart';
|
||||||
import '../service/bookmarks_provider.dart';
|
import '../service/bookmarks_provider.dart';
|
||||||
import '../service/shared_link_provider.dart';
|
import '../service/shared_link_provider.dart';
|
||||||
@@ -20,6 +21,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 +55,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,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,13 +89,13 @@ class _CollectionsListPageState extends State<CollectionsListPage> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: addingNewBookmark
|
title: addingNewBookmark
|
||||||
? Text('Choose Collection')
|
? Text(AppLocalizations.of(context)!.chooseCollection)
|
||||||
: Text('Collections'),
|
: Text(AppLocalizations.of(context)!.collections),
|
||||||
actions: [
|
actions: [
|
||||||
if (addingNewBookmark)
|
if (addingNewBookmark)
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => provider.removeCurrentMapsLink(),
|
onPressed: () => provider.removeCurrentMapsLink(),
|
||||||
child: Text('Cancel'),
|
child: Text(AppLocalizations.of(context)!.cancel),
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
IconButton(
|
IconButton(
|
||||||
@@ -110,7 +117,9 @@ class _CollectionsListPageState extends State<CollectionsListPage> {
|
|||||||
),
|
),
|
||||||
itemCount: collections.length,
|
itemCount: collections.length,
|
||||||
)
|
)
|
||||||
: Center(child: Text('Create your first Collection to get started!')),
|
: Center(
|
||||||
|
child: Text(AppLocalizations.of(context)!.tipCreateCollections),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import '../l10n/app_localizations.dart';
|
||||||
import '../service/search_provider.dart';
|
import '../service/search_provider.dart';
|
||||||
import '../widgets/search_widgets/search_bar_widget.dart';
|
import '../widgets/search_widgets/search_bar_widget.dart';
|
||||||
import '../widgets/search_widgets/search_results_widget.dart';
|
import '../widgets/search_widgets/search_results_widget.dart';
|
||||||
@@ -12,7 +13,7 @@ class SearchPage extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: Text('Search')),
|
appBar: AppBar(title: Text(AppLocalizations.of(context)!.search)),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
SearchBarWidget(
|
SearchBarWidget(
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
13
pubspec.lock
13
pubspec.lock
@@ -102,6 +102,11 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.0"
|
version: "6.0.0"
|
||||||
|
flutter_localizations:
|
||||||
|
dependency: "direct main"
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -136,6 +141,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.1.2"
|
version: "4.1.2"
|
||||||
|
intl:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: intl
|
||||||
|
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.20.2"
|
||||||
leak_tracker:
|
leak_tracker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -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.18
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.9.2
|
sdk: ^3.9.2
|
||||||
@@ -18,6 +18,9 @@ dependencies:
|
|||||||
provider: ^6.1.5+1
|
provider: ^6.1.5+1
|
||||||
metadata_fetch: ^0.4.2
|
metadata_fetch: ^0.4.2
|
||||||
url_launcher: ^6.3.2
|
url_launcher: ^6.3.2
|
||||||
|
flutter_localizations:
|
||||||
|
sdk: flutter
|
||||||
|
intl: any
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
@@ -26,5 +29,5 @@ dev_dependencies:
|
|||||||
flutter_lints: ^6.0.0
|
flutter_lints: ^6.0.0
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
|
generate: true
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
Reference in New Issue
Block a user