Skip to content

Commit

Permalink
Merge remote-tracking branch 'firestore/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Jun 24, 2023
2 parents e0f9ee4 + 8e1628e commit 45fe63e
Show file tree
Hide file tree
Showing 96 changed files with 3,380 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
.history
.svn/

# VS Code
# VS
.vs
.vscode

# IntelliJ related
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

dart format --fix
dart format . --fix
dart run lint_staged
2 changes: 1 addition & 1 deletion .pubignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ test/
.metadata
.gitignore
analysis_options.yaml
pub_login.sh
pub_login.sh
3 changes: 3 additions & 0 deletions packages/enhanced_cloud_firestore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.1

* Initial release.
111 changes: 111 additions & 0 deletions packages/enhanced_cloud_firestore/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# enhanced_cloud_firestore

A wrapper around the cloud firestore dart package with support for filtering, sorting, limiting, error handling and success scenarios

## Getting started

- Add [Firebase Core](https://pub.dev/packages/firebase_core) as a dependency in your pubspec.yaml file
- In your main.dart file, initialize a firebase app

## Usage

Read data in a collection

```dart
final res = EnhancedFirestore.read(collection: 'users');
```

Write data to a collection

```dart
final res = EnhancedFirestore.write(
collection: 'users',
payload: {
'name': 'John',
'email': '[email protected]',
'age': '45',
},
)
```

Update data in a collection

```dart
final res = EnhancedFirestore.update(
collection: 'users',
payload: {
'name': 'John Cena',
'email': '[email protected]',
'age': '46',
},
filters: [
{
'field': 'email',
'filter': FirestoreFilter.isEqualTo,
'value': '[email protected]',
}
]
)
```

Delete data in a collection

```dart
final res = EnhancedFirestore.delete(
collection: 'users',
filters: [
{
'field': 'email',
'filter': FirestoreFilter.isEqualTo,
'value': '[email protected]',
}
]
)
```

## Additional Parameters

#### All of the above four methods are able to take in the following parameters optionally:

---

- filters - An array of filters to apply on the collection. Specified as a json object list with the following keys -> <br>
- field - The document field to apply the filter on <br>
- filter - The filter type to apply (is an enum of type FirestoreFilter) <br>
- value - The field content to match against

---

- onSuccess - A function which will execute on success scenarios <br>

---

- onError - A function which will execute on error scenarios <br>

---

#### The read function can take in the following attributes other than those specified above

---

- sorts - An array of sorts to apply on the collection. Specified as a json object list with the following keys -> <br>
- field - The document field to apply the sort on <br>
- descending - A boolean value denoting the sort direction (specify as false to sort in ascending order )

---

- limit - A limit on the number of returned records <br>

---

## Caution

- An empty list of filters on an update function will result in the entire collection being updated

- An empty list of filters on a delete function will result in the entire collection being deleted

---

## Credits

Based on the original cloud_firestore package by Google (https://pub.dev/packages/cloud_firestore)
48 changes: 48 additions & 0 deletions packages/enhanced_cloud_firestore/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release

.env
16 changes: 16 additions & 0 deletions packages/enhanced_cloud_firestore/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# example

An example project which implements the enhanced_cloud_firestore package

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
29 changes: 29 additions & 0 deletions packages/enhanced_cloud_firestore/example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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
13 changes: 13 additions & 0 deletions packages/enhanced_cloud_firestore/example/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
57 changes: 57 additions & 0 deletions packages/enhanced_cloud_firestore/example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion flutter.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "sliitfoss.enhanced_cloud_firestore.example.example"
minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}

flutter {
source '../..'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sliitfoss.enhanced_cloud_firestore.example.example">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sliitfoss.enhanced_cloud_firestore.example.example">
<application
android:label="example"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package sliitfoss.enhanced_cloud_firestore.example.example;

import io.flutter.embedding.android.FlutterActivity;

public class MainActivity extends FlutterActivity {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 45fe63e

Please sign in to comment.