Skip to content

Commit

Permalink
flutter analyze, contributing & update of metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
BhasherBEL committed Jun 14, 2023
1 parent 4accbd5 commit d0ad1c6
Show file tree
Hide file tree
Showing 39 changed files with 200 additions and 179 deletions.
1 change: 1 addition & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exec flutter analyze
47 changes: 47 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Contributing to Splitr

Thank you for considering contributing to Splitr! :heart: We welcome contributions from the community to help improve and enhance the app. To ensure a smooth and consistent contribution process, please follow the guidelines outlined below.

If you like the project, but just don't have time to contribute, there are other easy ways to support the project and show your appreciation, which we would also be very happy about:
- Use the application
- Star the project
- Mention the project to your surroundings

## I have an issue

Before asking a question or submitting a new bug report, it is best to search for existing [Issues](https://github.com/BhasherBEL/Splitr/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write in this issue.

If you then still feel the need to ask a question and need clarification, we recommend the following:

- Make sure that you use the latest version of the application.
- Open an [Issue](https://github.com/BhasherBEL/Splitr/issues/new).
- Provide as much context as you can about what you're running into.
- Provide project and platform versions, depending on what seems relevant.

## I want to contribute

### Legal notice

When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.

### Code Style

Please ensure that your code follows the existing code style conventions. We use the Dart language and follow the effective Dart guidelines. To maintain code consistency, consider using the Dart formatter to format your code automatically.

Some hooks are also provided. To use them automatically, run
```sh
chmod +x .githooks/*
git config core.hooksPath .githooks
```

### Submitting changes

Here are the recommands steps to follow to submit your changes.

1. Fork the splitr repository on GitHub.
2. Create a new branch from the `master` branch with a descriptive name for your changes.
3. Ensure to follow the current guidelines.
4. Open a pull request (PR) against the `master` branch.
5. Provide a detailed description of your changes in the PR, including any relevant information or context.

Thank you for your contribution! We appreciate your effort in making Splitr better.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This is currently a beta version. To get the app, you have to build it yourself

| | | |
|:-------------------------:|:-------------------------:|:-------------------------:|
![Project](https://raw.githubusercontent.com/BhasherBEL/Splitr/master/metadata/en-US/images/phoneScreenshots/1.png) | ![Refund](https://raw.githubusercontent.com/BhasherBEL/Splitr/master/metadata/en-US/images/phoneScreenshots/2.png) | ![New project](https://raw.githubusercontent.com/BhasherBEL/Splitr/master/metadata/en-US/images/phoneScreenshots/3.png) |
![Project](metadata/en-US/images/phoneScreenshots/1.png) | ![Refund](metadata/en-US/images/phoneScreenshots/2.png) | ![New project](metadata/en-US/images/phoneScreenshots/3.png) |

## Features

Expand Down
27 changes: 2 additions & 25 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
prefer_single_quotes: true

2 changes: 1 addition & 1 deletion lib/data/local/item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LocalItem extends LocalGeneric {
item.itemParts = (await AppData.db.query(
tableItemParts,
columns: ItemPartFields.values,
where: "${ItemPartFields.itemId} = ?",
where: '${ItemPartFields.itemId} = ?',
whereArgs: [item.localId],
))
.map((e) => ItemPart.fromJson(e, item))
Expand Down
16 changes: 8 additions & 8 deletions lib/data/pocketbase/item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import '../../models/project.dart';
import 'item_part.dart';

class PocketBaseItemsFields {
static const String id = "id";
static const String title = "title";
static const String emitterId = "emitter_id";
static const String projectId = "project_id";
static const String amount = "amount";
static const String date = "date";
static const String deleted = "deleted";
static const String id = 'id';
static const String title = 'title';
static const String emitterId = 'emitter_id';
static const String projectId = 'project_id';
static const String amount = 'amount';
static const String date = 'date';
static const String deleted = 'deleted';
}

class PocketBaseItem {
Expand Down Expand Up @@ -70,7 +70,7 @@ class PocketBaseItem {
}

static Future<bool> sync(PocketBase pb, Project project) async {
RecordService collection = pb.collection("items");
RecordService collection = pb.collection('items');

// Get new dist records
List<RecordModel> records = await collection.getFullList(
Expand Down
14 changes: 7 additions & 7 deletions lib/data/pocketbase/item_part.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import '../../models/item_part.dart';
import '../../models/participant.dart';

class PocketBaseItemPartsFields {
static const String id = "id";
static const String itemId = "item_id";
static const String participantId = "participant_id";
static const String rate = "rate";
static const String amount = "amount";
static const String deleted = "deleted";
static const String id = 'id';
static const String itemId = 'item_id';
static const String participantId = 'participant_id';
static const String rate = 'rate';
static const String amount = 'amount';
static const String deleted = 'deleted';
}

class PocketBaseItemPart {
Expand Down Expand Up @@ -62,7 +62,7 @@ class PocketBaseItemPart {
}

static Future<bool> sync(PocketBase pb, Item item) async {
RecordService collection = pb.collection("itemParts");
RecordService collection = pb.collection('itemParts');

// Get new dist records
List<RecordModel> records = await collection.getFullList(
Expand Down
10 changes: 5 additions & 5 deletions lib/data/pocketbase/participant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import '../../models/participant.dart';
import '../../models/project.dart';

class PocketBaseParticipantFields {
static const String id = "id";
static const String pseudo = "pseudo";
static const String projectId = "project_id";
static const String deleted = "deleted";
static const String id = 'id';
static const String pseudo = 'pseudo';
static const String projectId = 'project_id';
static const String deleted = 'deleted';
}

class PocketBaseParticipant {
Expand Down Expand Up @@ -51,7 +51,7 @@ class PocketBaseParticipant {
}

static Future<bool> sync(PocketBase pb, Project project) async {
RecordService collection = pb.collection("participants");
RecordService collection = pb.collection('participants');

// Get new dist records
List<RecordModel> records = await collection.getFullList(
Expand Down
12 changes: 6 additions & 6 deletions lib/data/pocketbase/project.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import 'package:splitr/utils/ext/record_service.dart';
import '../../models/project.dart';

class PocketBaseProjectFields {
static const String name = "name";
static const String code = "code";
static const String deleted = "deleted";
static const String name = 'name';
static const String code = 'code';
static const String deleted = 'deleted';
}

class PocketBaseProject {
static Future<bool> sync(PocketBase pb, Project project) async {
RecordService collection = pb.collection("projects");
RecordService collection = pb.collection('projects');

if (project.remoteId != null) {
RecordModel record = await collection.getOne(project.remoteId!);
Expand Down Expand Up @@ -49,9 +49,9 @@ class PocketBaseProject {
}

static Future<bool> join(PocketBase pb, Project project) async {
RecordService collection = pb.collection("projects");
RecordService collection = pb.collection('projects');
RecordModel record =
await collection.getFirstListItem("code = \"${project.name}\"");
await collection.getFirstListItem('code = "${project.name}"');
project.code = project.name;
project.name = record.getStringValue(PocketBaseProjectFields.name);
project.remoteId = record.id;
Expand Down
1 change: 0 additions & 1 deletion lib/data/pocketbase/provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:pocketbase/pocketbase.dart';

import '../../models/instance.dart';
import '../../models/item.dart';
import '../../models/item_part.dart';
import '../../models/project.dart';
import '../provider.dart';
import 'item.dart';
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'screens/project/project_page.dart';
import 'screens/projects_list/projects_list_page.dart';
import 'models/app_data.dart';
import 'screens/project/new_project.dart';
import 'screens/new_project/new_project.dart';
import 'utils/helper/theme.dart';

void main() async {
Expand All @@ -27,7 +27,7 @@ class SplashScreen extends StatelessWidget {
darkTheme: defaultDarkTheme,
home: const Scaffold(
body: Center(
child: Text("Starting up Splitr ..."),
child: Text('Starting up Splitr ...'),
),
),
);
Expand Down
18 changes: 9 additions & 9 deletions lib/models/app_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:splitr/data/local/project.dart';
import 'package:splitr/utils/ext/set.dart';
import 'package:sqflite/sqflite.dart';

import '../screens/project/new_project.dart';
import '../screens/new_project/new_project.dart';
import '../services/database.dart';
import '../utils/helper/theme.dart';
import 'instance.dart';
Expand All @@ -27,7 +27,7 @@ class AppData {

static set firstRun(bool v) {
_firstRun = v;
sharedPreferences.setBool("firstRun", v);
sharedPreferences.setBool('firstRun', v);
}

static Project? get current {
Expand All @@ -36,10 +36,10 @@ class AppData {

static set current(Project? project) {
if (project == null) {
sharedPreferences.remove("lastProject");
sharedPreferences.remove('lastProject');
} else {
sharedPreferences.setString(
"lastProject",
'lastProject',
project.name,
);
}
Expand All @@ -55,20 +55,20 @@ class AppData {

AppData.projects = await Project.getAllProjects();

if (!sharedPreferences.containsKey("firstRun")) {
if (!sharedPreferences.containsKey('firstRun')) {
firstRun = AppData.projects.enabled().isEmpty;
} else {
firstRun = sharedPreferences.getBool("firstRun")!;
firstRun = sharedPreferences.getBool('firstRun')!;
}

if (sharedPreferences.containsKey("lastProject")) {
if (sharedPreferences.containsKey('lastProject')) {
try {
_current =
Project.fromName(sharedPreferences.getString("lastProject")!);
Project.fromName(sharedPreferences.getString('lastProject')!);
await (_current!.conn as LocalProject).loadParticipants();
await (_current!.conn as LocalProject).loadEntries();
} catch (e) {
sharedPreferences.remove("lastProject");
sharedPreferences.remove('lastProject');
}
}

Expand Down
6 changes: 2 additions & 4 deletions lib/models/bill_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BillData {
this.item,
required this.project,
}) {
title = item?.title ?? "";
title = item?.title ?? '';
date = item?.date ?? DateTime.now();
emitter = item?.emitter ??
project.currentParticipant ??
Expand All @@ -29,7 +29,7 @@ class BillData {
Item? item;
Project project;

String title = "";
String title = '';
DateTime date = DateTime.now();
late Participant emitter;
double amount = 0;
Expand Down Expand Up @@ -87,8 +87,6 @@ shares: ${shares.entries.map((e) => "${e.key.pseudo}:${e.value}").join(",")}""";
}
await item!.conn.save();

List<ItemPart> previous = item!.itemParts.toList();

for (var a in shares.entries) {
Participant p = a.key;
BillPart s = a.value;
Expand Down
4 changes: 2 additions & 2 deletions lib/models/item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ class Item extends Data {
itemParts.enabled().map((e) => e.participant).toList();

if (participants.length < 4) {
return participants.map((e) => e.pseudo).join(", ");
return participants.map((e) => e.pseudo).join(', ');
}
if (participants.length == project.participants.length) return 'All';

List<String> possibilites = [
participants.map((e) => e.pseudo).join(", "),
participants.map((e) => e.pseudo).join(', '),
'All except ${project.participants.where((element) => !participants.contains(element)).map((e) => e.pseudo).join(', ')}',
];

Expand Down
1 change: 0 additions & 1 deletion lib/models/project.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ class Project extends Data {
return Tuple2(res,
(DateTime.now().difference(st).inMilliseconds / 1000).toString());
} catch (e) {
print(e);
return Tuple2(false, e.toString());
}
}
Expand Down
5 changes: 2 additions & 3 deletions lib/screens/instances/instance_tile.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:splitr/data/local/instance.dart';

import '../../models/app_data.dart';
import '../../models/instance.dart';
Expand Down Expand Up @@ -47,9 +46,9 @@ class _InstanceTileState extends State<InstanceTile> {
onPressed: () async {
await confirmBox(
context: context,
title: "Remove ${widget.instance.name}",
title: 'Remove ${widget.instance.name}',
content:
"Are you sure you want to remove ${widget.instance.name}? You will not be able to sync or create projects with it.",
'Are you sure you want to remove ${widget.instance.name}? You will not be able to sync or create projects with it.',
onValidate: () async {
await widget.instance.conn.delete();
AppData.instances.remove(widget.instance);
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/instances/instances_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class _InstancesListPageState extends State<InstancesListPage> {
centerTitle: true,
elevation: 4,
title: const Text(
"Instances",
'Instances',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
Expand Down
Loading

0 comments on commit d0ad1c6

Please sign in to comment.