Skip to content

Commit

Permalink
chore: fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Dec 5, 2021
1 parent 6d6b6b2 commit 748d5fd
Show file tree
Hide file tree
Showing 31 changed files with 160 additions and 146 deletions.
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# Anchr for Android
<p align="center">
<img src="https://anchr.io/images/logo.png" width="150">
</p>

![GitHub package.json version](https://badges.fw-web.space/f-droid/v/io.muetsch.anchrandroid.svg?style=flat-square)
[![](http://badges.fw-web.space/liberapay/receives/muety.svg?logo=liberapay&style=flat-square)](https://liberapay.com/muety/)
![](https://badges.fw-web.space/github/license/muety/anchr-android?style=flat-square)
<h2 align="center">Anchr for Android</h2>

---
<img src="https://anchr.io/images/logo.png" height="128px">

Android client for Anchr.io link collections, built with **[Flutter](https://flutter.dev)**. This project is in an **early development phase** and therefore not yet feature-complete or free of bugs.
<h3 align="center">
Android client for Anchr.io link collections, built with Flutter
</h3>

<p align="center">
<img src="https://badges.fw-web.space/github/license/muety/anchr-android">
<img src="https://badges.fw-web.space/endpoint?url=https://wakapi.dev/api/compat/shields/v1/n1try/interval:any/project:anchr-android&color=blue&label=time">
<img src="https://badges.fw-web.space/github/languages/code-size/muety/wakapi">
</p>

<p align="center">
<a href="https://play.google.com/store/apps/details?id=io.muetsch.anchrandroid&utm_source=github"><img src="https://anchr.io/i/sdr1N.png" width="150"></a>
</p>

[![F-Droid](https://anchr.io/i/QHjVF.png)](https://f-droid.org/en/packages/io.muetsch.anchrandroid)
[![Google Play](https://anchr.io/i/sdr1N.png)](https://play.google.com/store/apps/details?id=io.muetsch.anchrandroid&utm_source=github)

## Prerequisites
* A hosted instance of [Anchr](https://github.com/n1try/anchr) and a registered account.
Expand Down Expand Up @@ -70,5 +78,3 @@ Feel free to contribute!

## License
GNU General Public License v3 (GPL-3) @ [Ferdinand Mütsch](https://muetsch.io)

[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://buymeacoff.ee/n1try)
8 changes: 8 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include: package:lints/recommended.yaml

analyzer:
exclude: [build/**]

linter:
rules:
avoid_catching_errors: true
2 changes: 1 addition & 1 deletion android/local.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sdk.dir=/media/ferdinand/HDD/android/sdk
flutter.sdk=/opt/flutter
flutter.versionName=1.2.2
flutter.buildMode=release
flutter.buildMode=debug
flutter.versionCode=30
15 changes: 9 additions & 6 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class AnchrApp extends StatefulWidget {
}

class _AnchrAppState extends AnchrState<AnchrApp> with AnchrActions {
static const platform = const MethodChannel('app.channel.shared.data');
static const platform = MethodChannel('app.channel.shared.data');

Map<dynamic, dynamic> sharedData = Map();
Map<dynamic, dynamic> sharedData = {};
bool initialized = false;
bool isLoggedIn = false;

Expand Down Expand Up @@ -70,10 +70,10 @@ class _AnchrAppState extends AnchrState<AnchrApp> with AnchrActions {
});
}

Future<Map> _getSharedData() async => await platform.invokeMethod('getSharedData');
Future<dynamic> _getSharedData() async => await platform.invokeMethod('getSharedData');

_handleSharedData(data) {
if (data.isEmpty) return;
if (data.isEmpty != null) return;
Navigator.of(appState.currentContext).pushNamedAndRemoveUntil(AddLinkPage.routeName, (Route<dynamic> route) => route.settings.name != AddLinkPage.routeName, arguments: data);
}

Expand Down Expand Up @@ -106,7 +106,7 @@ class _AnchrAppState extends AnchrState<AnchrApp> with AnchrActions {
if (initialized) {
if (!isLoggedIn) {
startingPage = defaultLoginPage;
} else if (linkData != null && linkData.length > 0) {
} else if (linkData != null && linkData.isNotEmpty) {
startingPage = defaultAddLinkPage;
sharedData.clear();
} else {
Expand All @@ -121,7 +121,10 @@ class _AnchrAppState extends AnchrState<AnchrApp> with AnchrActions {
return MaterialApp(
title: Strings.title,
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.teal, accentColor: Color(0xFFDD5237)),
theme: ThemeData(
colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.teal)
.copyWith(secondary: Color(0xFFDD5237))
),
home: getPage(),
routes: <String, WidgetBuilder>{
//5
Expand Down
16 changes: 8 additions & 8 deletions lib/database/collection_db_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:anchr_android/models/link_collection.dart';
import 'package:sqflite/sqflite.dart';

class CollectionDbHelper extends DatabaseHelper {
static final CollectionDbHelper _helper = new CollectionDbHelper._internal();
static final CollectionDbHelper _helper = CollectionDbHelper._internal();
static const int _schemaVersion = 1;
static const String tableName = 'collection';
static const String columnId = '_id';
Expand Down Expand Up @@ -37,18 +37,18 @@ class CollectionDbHelper extends DatabaseHelper {
}
}

Future insert(LinkCollection collection) async {
Future<void> insert(LinkCollection collection) async {
Map<String, dynamic> collectionMap = collection.toJson();
await db.insert(tableName, collectionMap, conflictAlgorithm: ConflictAlgorithm.replace);
}

Future insertBatch(List<LinkCollection> collections) async {
Future<void> insertBatch(List<LinkCollection> collections) async {
final batch = db.batch();
collections.forEach((c) {
for (var c in collections) {
Map<String, dynamic> collectionMap = c.toJson();
collectionMap.remove('links');
batch.insert(tableName, collectionMap, conflictAlgorithm: ConflictAlgorithm.replace);
});
}
await batch.commit();
}

Expand All @@ -63,17 +63,17 @@ class CollectionDbHelper extends DatabaseHelper {
where: '$columnId = ?',
whereArgs: [id]);

if (maps.length > 0) {
if (maps.isNotEmpty) {
return LinkCollection.fromJson(maps.first);
}
return null;
}

Future deleteById(String id) async {
Future<dynamic> deleteById(String id) async {
await db.delete(tableName, where: '$columnId = ?', whereArgs: [id]);
}

Future deleteAll() async {
Future<dynamic> deleteAll() async {
await db.delete(tableName);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/database/database_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import 'package:sqflite/sqflite.dart';
abstract class DatabaseHelper {
Database db;

Future open(String path) async {
Future<dynamic> open(String path) async {
db = await openDatabase(path, version: schemaVersion, onCreate: onCreate, onUpgrade: onUpgrade);
}

Future delete() async {
Future<dynamic> delete() async {
if (db != null) {
return db.delete(table);
}
Expand Down
16 changes: 8 additions & 8 deletions lib/database/link_db_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:anchr_android/models/link.dart';
import 'package:sqflite/sqflite.dart';

class LinkDbHelper extends DatabaseHelper {
static final LinkDbHelper _helper = new LinkDbHelper._internal();
static final LinkDbHelper _helper = LinkDbHelper._internal();
static const int _schemaVersion = 1;
static const String tableName = 'link';
static const String columnId = '_id';
Expand Down Expand Up @@ -39,19 +39,19 @@ class LinkDbHelper extends DatabaseHelper {
}
}

Future insert(Link link, String collectionId) async {
Future<dynamic> insert(Link link, String collectionId) async {
Map<String, dynamic> linkMap = link.toJson();
linkMap[columnCollectionId] = collectionId;
await db.insert(tableName, linkMap, conflictAlgorithm: ConflictAlgorithm.replace);
}

Future insertBatch(List<Link> links, String collectionId) async {
Future<dynamic> insertBatch(List<Link> links, String collectionId) async {
final batch = db.batch();
links.forEach((l) {
for (var l in links) {
Map<String, dynamic> linkMap = l.toJson();
linkMap[columnCollectionId] = collectionId;
batch.insert(tableName, linkMap, conflictAlgorithm: ConflictAlgorithm.replace);
});
}
await batch.commit();
}

Expand All @@ -68,15 +68,15 @@ class LinkDbHelper extends DatabaseHelper {
return maps.map((l) => Link.fromJson(l)).toList();
}

Future deleteAllByCollection(String collectionId) async {
Future<dynamic> deleteAllByCollection(String collectionId) async {
await db.delete(tableName, where: '$columnCollectionId = ?', whereArgs: [collectionId]);
}

Future deleteById(String id) async {
Future<dynamic> deleteById(String id) async {
await db.delete(tableName, where: '$columnId = ?', whereArgs: [id]);
}

Future deleteAll() async {
Future<dynamic> deleteAll() async {
await db.delete(tableName);
}

Expand Down
5 changes: 0 additions & 5 deletions lib/models/args/collection_page_args.dart

This file was deleted.

4 changes: 2 additions & 2 deletions lib/models/exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ class WebServiceException implements Exception {
String message;

WebServiceException({String message}) {
this.message = message;
message = message;
}

@override
String toString() {
return this.message;
return message;
}
}

Expand Down
9 changes: 4 additions & 5 deletions lib/models/link.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Link with Comparable {
class Link with Comparable<Link> {
String id;
String url;
String description;
Expand All @@ -7,8 +7,7 @@ class Link with Comparable {
Link({this.id, this.url, this.description, this.date});

factory Link.fromJson(Map<String, dynamic> json) {
return Link(
id: json['_id'], url: json['url'], description: json['description'], date: DateTime.parse(json['date']));
return Link(id: json['_id'], url: json['url'], description: json['description'], date: DateTime.parse(json['date']));
}

Map<String, dynamic> toJson() {
Expand All @@ -17,7 +16,7 @@ class Link with Comparable {

@override
int compareTo(other) {
if (!(other is Link)) return -1;
return (this.date.compareTo((other as Link).date)) * -1;
if (other is! Link) return -1;
return (date.compareTo((other).date)) * -1;
}
}
9 changes: 4 additions & 5 deletions lib/models/link_collection.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import 'package:anchr_android/models/link.dart';

class LinkCollection with Comparable {
class LinkCollection with Comparable<LinkCollection> {
String id;
String name;
List<Link> links;

LinkCollection({this.id, this.name, this.links});

factory LinkCollection.fromJson(Map<String, dynamic> json) {
List<Link> links =
json.containsKey('links') ? (json['links'] as List<dynamic>).map((l) => Link.fromJson(l)).toList() : List();
List<Link> links = json.containsKey('links') ? (json['links'] as List<Map<String, dynamic>>).map((l) => Link.fromJson(l)).toList() : [];
links.sort();

return LinkCollection(
Expand All @@ -24,7 +23,7 @@ class LinkCollection with Comparable {

@override
int compareTo(other) {
if (!(other is LinkCollection)) return -1;
return name.compareTo((other as LinkCollection).name);
if (other is! LinkCollection) return -1;
return name.compareTo((other).name);
}
}
10 changes: 5 additions & 5 deletions lib/models/types.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:anchr_android/models/link.dart';
import 'package:anchr_android/models/link_collection.dart';

typedef DeleteLink(Link link);
typedef DeleteCollection(LinkCollection collection);
typedef AddCollection(String name);
typedef OnLogout();
typedef OnUnauthorized();
typedef DeleteLink = Function(Link link);
typedef DeleteCollection = Function(LinkCollection collection);
typedef AddCollection = Function(String name);
typedef OnLogout = Function();
typedef OnUnauthorized = Function();
4 changes: 2 additions & 2 deletions lib/pages/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class AboutPage extends StatelessWidget {
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
RaisedButton(
ElevatedButton(
child: const Text(Strings.labelViewCodeButton),
onPressed: () => Utils.launchURL(Strings.urlGithub),
),
RaisedButton(
ElevatedButton(
child: const Text(Strings.labelViewLegal),
onPressed: () => Utils.launchURL(Strings.urlLegal),
)
Expand Down
Loading

0 comments on commit 748d5fd

Please sign in to comment.