Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class-based SDK for Chat API #88

Merged
merged 14 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions example/.metadata

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export 'chat/__chats.dart';
export 'user/__user.dart';
export 'payload/__payloads.dart';
export 'space/__spaces.dart';
export 'pushapi/_pushapi.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import 'package:push_restapi_dart/push_restapi_dart.dart';

Future<void> testGetGroupMembers() async {
final result = await getGroupMembers(
chatId:
'5ed6ac1c59384fc447986141e5ff593b8fd446d63bd3a9a0f16e06e012bc86d3');
options: FetchChatGroupInfoType(
chatId:
'5ed6ac1c59384fc447986141e5ff593b8fd446d63bd3a9a0f16e06e012bc86d3'));

print('testGetGroupMembers result: $result');
}
11 changes: 11 additions & 0 deletions example/demo_app/lib/test_functions/chat/update_group_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:push_restapi_dart/push_restapi_dart.dart';

void testUpdateGroupConfig() async {
final result = await updateGroupConfig(
options: ChatUpdateConfigProfileType(
scheduleAt: DateTime.now().add(Duration(hours: 3)),
chatId: '64434400c9a61256451f025f1f8c7b34d9651af4a03ca063126e137572fb85ca',
));

print(result);
}
13 changes: 13 additions & 0 deletions example/demo_app/lib/test_functions/chat/update_group_profile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:push_restapi_dart/push_restapi_dart.dart';

void testUpdateGroupProfile() async {
final result = await updateGroupProfile(
options: ChatUpdateGroupProfileType(
groupImage:
'https://tmpfiles.org/dl/3250024/screenshot2023-11-26at8.51.05pm.png',
chatId:
'64434400c9a61256451f025f1f8c7b34d9651af4a03ca063126e137572fb85ca',
groupName: 'Group New name'));

print(result);
}
1 change: 1 addition & 0 deletions example/demo_app/lib/test_functions/pushapi/_pushapi.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'pushapi.dart';
22 changes: 22 additions & 0 deletions example/demo_app/lib/test_functions/pushapi/pushapi.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'dart:math';

import 'package:push_restapi_dart/push_restapi_dart.dart';
import 'package:web3dart/web3dart.dart' as web3;

import '../../__lib.dart';

testPushApi() async {
final web3.Credentials randomCredentials =
web3.EthPrivateKey.createRandom(Random.secure());
final signer = Web3Signer(randomCredentials);
final web3.Credentials randomCredentials2 =
web3.EthPrivateKey.createRandom(Random.secure());
final signer2 = Web3Signer(randomCredentials2);

final alice = await PushAPI.initialize(signer: signer);
final bob = await PushAPI.initialize(signer: signer2);

print('Push api : ${alice.pgpPublicKey}');

print('Push api bob: ${bob.pgpPublicKey}');
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ class ChatRoomProvider extends ChangeNotifier {
}

Future getLatestGroupMembers() async {
_members = await getGroupMembers(chatId: _currentChatid);
_members = await getGroupMembers(
options: FetchChatGroupInfoType(chatId: _currentChatid));
notifyListeners();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ class _EditGroupInfoScreenState extends ConsumerState<EditGroupInfoScreen> {
try {
showLoadingDialog();
await push.updateGroupProfile(
options: ChatUpdateGroupProfileType(
chatId: groupInfo!.chatId,
groupName: nameController.text.trim(),
groupImage:
selectedFile != null ? composeImage() : groupInfo!.groupImage,
selectedFile != null ? composeImage() : groupInfo!.groupImage!,
groupDescription: descriptionController.text.trim(),
);
));

await ref.read(chatRoomProvider).getLatestGroupInfo();
pop();
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/pubspec.yaml → example/demo_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies:


push_restapi_dart:
path: '../'
path: '../../'



Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
10 changes: 0 additions & 10 deletions example/lib/test_functions/chat/update_group_config.dart

This file was deleted.

12 changes: 0 additions & 12 deletions example/lib/test_functions/chat/update_group_profile.dart

This file was deleted.

44 changes: 44 additions & 0 deletions example/use_cases/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# 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/

# 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
45 changes: 45 additions & 0 deletions example/use_cases/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.

version:
revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: android
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: ios
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: linux
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: macos
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: web
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: windows
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
3 changes: 3 additions & 0 deletions example/use_cases/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# use_cases

A new Flutter project.
1 change: 1 addition & 0 deletions example/use_cases/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:flutter_lints/flutter.yaml
13 changes: 13 additions & 0 deletions example/use_cases/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
72 changes: 72 additions & 0 deletions example/use_cases/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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 {
namespace "com.example.use_cases"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.use_cases"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

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 '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
7 changes: 7 additions & 0 deletions example/use_cases/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool 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>
33 changes: 33 additions & 0 deletions example/use_cases/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="use_cases"
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 com.example.use_cases

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}
Loading