mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 10:53:51 +02:00
Merge pull request #46 from Iconica-Development/feature/example
feat: example
This commit is contained in:
commit
5f890fe75f
12 changed files with 116 additions and 219 deletions
|
@ -1,7 +1,3 @@
|
||||||
# SPDX-FileCopyrightText: 2022 Iconica
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
# Miscellaneous
|
# Miscellaneous
|
||||||
*.class
|
*.class
|
||||||
*.log
|
*.log
|
||||||
|
@ -23,7 +19,7 @@ migrate_working_dir/
|
||||||
# The .vscode folder contains launch configuration and tasks you configure in
|
# 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
|
# VS Code which you may wish to be included in version control, so this line
|
||||||
# is commented out by default.
|
# is commented out by default.
|
||||||
.vscode/
|
#.vscode/
|
||||||
|
|
||||||
# Flutter/Dart/Pub related
|
# Flutter/Dart/Pub related
|
||||||
**/doc/api/
|
**/doc/api/
|
||||||
|
@ -31,7 +27,6 @@ migrate_working_dir/
|
||||||
.dart_tool/
|
.dart_tool/
|
||||||
.flutter-plugins
|
.flutter-plugins
|
||||||
.flutter-plugins-dependencies
|
.flutter-plugins-dependencies
|
||||||
.packages
|
|
||||||
.pub-cache/
|
.pub-cache/
|
||||||
.pub/
|
.pub/
|
||||||
/build/
|
/build/
|
||||||
|
@ -46,13 +41,3 @@ app.*.map.json
|
||||||
/android/app/debug
|
/android/app/debug
|
||||||
/android/app/profile
|
/android/app/profile
|
||||||
/android/app/release
|
/android/app/release
|
||||||
|
|
||||||
android
|
|
||||||
ios
|
|
||||||
web
|
|
||||||
windows
|
|
||||||
macos
|
|
||||||
linux
|
|
||||||
.metadata
|
|
||||||
|
|
||||||
pubspec.lock
|
|
|
@ -13,8 +13,7 @@ linter:
|
||||||
# The lint rules applied to this project can be customized in the
|
# The lint rules applied to this project can be customized in the
|
||||||
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
|
# 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
|
# included above or to enable additional rules. A list of all available lints
|
||||||
# and their documentation is published at
|
# and their documentation is published at https://dart.dev/lints.
|
||||||
# https://dart-lang.github.io/linter/lints/index.html.
|
|
||||||
#
|
#
|
||||||
# Instead of disabling a lint rule for the entire project in the
|
# 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
|
# section below, it can also be suppressed for a single line of code
|
75
packages/flutter_chat/example/lib/main.dart
Normal file
75
packages/flutter_chat/example/lib/main.dart
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_chat/flutter_chat.dart';
|
||||||
|
import 'package:flutter_chat_firebase/flutter_chat_firebase.dart';
|
||||||
|
|
||||||
|
void main(List<String> args) async {
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
await Firebase.initializeApp(
|
||||||
|
// Set your firebase app here
|
||||||
|
// options: FirebaseOptions(apiKey: 'apiKey', appId: 'appId', messagingSenderId: 'messagingSenderId', projectId: 'projectId')
|
||||||
|
);
|
||||||
|
|
||||||
|
runApp(const App());
|
||||||
|
}
|
||||||
|
|
||||||
|
class App extends StatelessWidget {
|
||||||
|
const App({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return const MaterialApp(
|
||||||
|
home: Home(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Home extends StatefulWidget {
|
||||||
|
const Home({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Home> createState() => _HomeState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HomeState extends State<Home> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
FirebaseAuth.instance.signInWithEmailAndPassword(
|
||||||
|
email: 'your email', password: 'your password');
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: SafeArea(
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.bottomRight,
|
||||||
|
child: ChatEntryWidget(
|
||||||
|
chatService: FirebaseChatService(),
|
||||||
|
onTap: _onTap,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onTap() {
|
||||||
|
Navigator.of(context).push(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => chatNavigatorUserStory(
|
||||||
|
ChatUserStoryConfiguration(
|
||||||
|
chatService: FirebaseChatService(),
|
||||||
|
chatOptionsBuilder: (ctx) => const ChatOptions(),
|
||||||
|
),
|
||||||
|
context),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
26
packages/flutter_chat/example/pubspec.yaml
Normal file
26
packages/flutter_chat/example/pubspec.yaml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
name: example
|
||||||
|
description: "A new Flutter project."
|
||||||
|
publish_to: "none"
|
||||||
|
version: 1.0.0+1
|
||||||
|
|
||||||
|
environment:
|
||||||
|
sdk: ">=3.2.5 <4.0.0"
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
flutter:
|
||||||
|
sdk: flutter
|
||||||
|
cupertino_icons: ^1.0.2
|
||||||
|
firebase_core: ^2.24.2
|
||||||
|
firebase_auth: ^4.16.0
|
||||||
|
flutter_chat:
|
||||||
|
path: ../
|
||||||
|
flutter_chat_firebase:
|
||||||
|
path: ../../flutter_chat_firebase
|
||||||
|
|
||||||
|
dev_dependencies:
|
||||||
|
flutter_test:
|
||||||
|
sdk: flutter
|
||||||
|
flutter_lints: ^2.0.0
|
||||||
|
|
||||||
|
flutter:
|
||||||
|
uses-material-design: true
|
|
@ -1,151 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2022 Iconica
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
|
|
||||||
import 'dart:async';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_chat_view/flutter_chat_view.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
runApp(const MaterialApp(home: MyStatefulWidget()));
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyStatefulWidget extends StatefulWidget {
|
|
||||||
const MyStatefulWidget({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
|
||||||
static final pietUser = ChatUserModel(
|
|
||||||
id: 'piet',
|
|
||||||
firstName: 'Piet',
|
|
||||||
lastName: 'Jansen',
|
|
||||||
imageUrl: 'https://xsgames.co/randomusers/avatar.php?g=female',
|
|
||||||
);
|
|
||||||
|
|
||||||
static final janUser = ChatUserModel(
|
|
||||||
firstName: 'Jan',
|
|
||||||
lastName: 'Jansen',
|
|
||||||
imageUrl: 'https://xsgames.co/randomusers/avatar.php?g=male',
|
|
||||||
);
|
|
||||||
|
|
||||||
static final messages = [
|
|
||||||
ChatTextMessageModel(
|
|
||||||
sender: pietUser,
|
|
||||||
text: 'Hoe gaat het?',
|
|
||||||
timestamp: DateTime.now(),
|
|
||||||
),
|
|
||||||
ChatTextMessageModel(
|
|
||||||
sender: janUser,
|
|
||||||
text: 'Met mij gaat het goed, dankje!',
|
|
||||||
timestamp: DateTime.now().subtract(const Duration(days: 2)),
|
|
||||||
),
|
|
||||||
ChatTextMessageModel(
|
|
||||||
sender: pietUser,
|
|
||||||
text: 'Mooi zo!',
|
|
||||||
timestamp: DateTime.now().subtract(const Duration(days: 1)),
|
|
||||||
),
|
|
||||||
ChatTextMessageModel(
|
|
||||||
sender: pietUser,
|
|
||||||
text: 'Hoe gaat het?',
|
|
||||||
timestamp: DateTime.now(),
|
|
||||||
),
|
|
||||||
ChatTextMessageModel(
|
|
||||||
sender: janUser,
|
|
||||||
text: 'Met mij gaat het goed, dankje!',
|
|
||||||
timestamp: DateTime.now().subtract(const Duration(days: 2)),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
static final chat = PersonalChatModel(
|
|
||||||
user: ChatUserModel(
|
|
||||||
firstName: 'Sjoerd',
|
|
||||||
lastName: 'Sjagerars',
|
|
||||||
imageUrl: 'https://xsgames.co/randomusers/avatar.php?g=female',
|
|
||||||
),
|
|
||||||
lastUsed: DateTime.now(),
|
|
||||||
messages: messages,
|
|
||||||
);
|
|
||||||
|
|
||||||
static final groupChat = GroupChatModel(
|
|
||||||
title: 'Group chat',
|
|
||||||
imageUrl: 'https://xsgames.co/randomusers/avatar.php?g=male',
|
|
||||||
users: [pietUser, janUser],
|
|
||||||
lastUsed: DateTime.now().subtract(const Duration(days: 1)),
|
|
||||||
messages: messages,
|
|
||||||
canBeDeleted: false,
|
|
||||||
);
|
|
||||||
|
|
||||||
Stream<List<ChatModel>> get chatStream => (() {
|
|
||||||
late StreamController<List<ChatModel>> controller;
|
|
||||||
controller = StreamController<List<ChatModel>>(
|
|
||||||
onListen: () {
|
|
||||||
controller.add([
|
|
||||||
groupChat,
|
|
||||||
chat,
|
|
||||||
]);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
return controller.stream;
|
|
||||||
})();
|
|
||||||
|
|
||||||
Stream<List<ChatTextMessageModel>> get messageStream => (() {
|
|
||||||
late StreamController<List<ChatTextMessageModel>> controller;
|
|
||||||
controller = StreamController<List<ChatTextMessageModel>>(
|
|
||||||
onListen: () {
|
|
||||||
controller.add(
|
|
||||||
messages,
|
|
||||||
);
|
|
||||||
|
|
||||||
Future.delayed(
|
|
||||||
const Duration(seconds: 5),
|
|
||||||
() => controller.add(
|
|
||||||
[
|
|
||||||
...messages,
|
|
||||||
...messages,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
return controller.stream;
|
|
||||||
})();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
// return ChatScreen(
|
|
||||||
// service: ,
|
|
||||||
// options: options,
|
|
||||||
// onPressChat: (chat) => Navigator.of(context).push(
|
|
||||||
// MaterialPageRoute(
|
|
||||||
// builder: (context) => ChatDetailScreen(
|
|
||||||
// userId: 'piet',
|
|
||||||
// chat: chat,
|
|
||||||
// chatMessages: messageStream,
|
|
||||||
// options: options,
|
|
||||||
// onMessageSubmit: (text) async {
|
|
||||||
// return Future.delayed(
|
|
||||||
// const Duration(
|
|
||||||
// milliseconds: 500,
|
|
||||||
// ),
|
|
||||||
// () => debugPrint('onMessageSubmit'),
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// onReadChat: (chat) async {},
|
|
||||||
// onUploadImage: (image) async {},
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// onDeleteChat: (chat) => Future.delayed(
|
|
||||||
// const Duration(
|
|
||||||
// milliseconds: 500,
|
|
||||||
// ),
|
|
||||||
// () => debugPrint('onDeleteChat'),
|
|
||||||
// ),
|
|
||||||
// onPressStartChat: () => debugPrint('onPressStartChat'),
|
|
||||||
// );
|
|
||||||
return const Text('Example ');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: 2022 Iconica
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
name: flutter_chat_view_example
|
|
||||||
description: A standard flutter package.
|
|
||||||
|
|
||||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
|
||||||
|
|
||||||
version: 1.0.0+1
|
|
||||||
|
|
||||||
environment:
|
|
||||||
sdk: ">=3.1.0 <4.0.0"
|
|
||||||
dependencies:
|
|
||||||
flutter:
|
|
||||||
sdk: flutter
|
|
||||||
flutter_chat_view:
|
|
||||||
path: ..
|
|
||||||
|
|
||||||
dev_dependencies:
|
|
||||||
flutter_test:
|
|
||||||
sdk: flutter
|
|
||||||
flutter_lints: ^2.0.0
|
|
||||||
|
|
||||||
flutter:
|
|
||||||
uses-material-design: true
|
|
|
@ -1,14 +0,0 @@
|
||||||
// This is a basic Flutter widget test.
|
|
||||||
//
|
|
||||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
|
||||||
// utility in the flutter_test package. For example, you can send tap and scroll
|
|
||||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
|
||||||
// tree, read text, and verify that the values of widget properties are correct.
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
test('blank test', () {
|
|
||||||
expect(true, isTrue);
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,11 +1,11 @@
|
||||||
// This is a generated file; do not edit or check into version control.
|
// This is a generated file; do not edit or check into version control.
|
||||||
FLUTTER_ROOT=/opt/homebrew/Caskroom/flutter/3.10.2/flutter
|
FLUTTER_ROOT=/opt/homebrew/Caskroom/flutter/3.10.2/flutter
|
||||||
FLUTTER_APPLICATION_PATH=/Users/mikedoornenbal/Documents/iconica/flutter_chat/packages/flutter_chat_view
|
FLUTTER_APPLICATION_PATH=/Users/mikedoornenbal/Documents/iconica/flutter_community_chat/packages/flutter_chat_view
|
||||||
COCOAPODS_PARALLEL_CODE_SIGN=true
|
COCOAPODS_PARALLEL_CODE_SIGN=true
|
||||||
FLUTTER_TARGET=lib/main.dart
|
FLUTTER_TARGET=lib/main.dart
|
||||||
FLUTTER_BUILD_DIR=build
|
FLUTTER_BUILD_DIR=build
|
||||||
FLUTTER_BUILD_NAME=0.6.0
|
FLUTTER_BUILD_NAME=1.0.0
|
||||||
FLUTTER_BUILD_NUMBER=0.6.0
|
FLUTTER_BUILD_NUMBER=1.0.0
|
||||||
EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386
|
EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386
|
||||||
EXCLUDED_ARCHS[sdk=iphoneos*]=armv7
|
EXCLUDED_ARCHS[sdk=iphoneos*]=armv7
|
||||||
DART_OBFUSCATION=false
|
DART_OBFUSCATION=false
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# This is a generated file; do not edit or check into version control.
|
# This is a generated file; do not edit or check into version control.
|
||||||
export "FLUTTER_ROOT=/opt/homebrew/Caskroom/flutter/3.10.2/flutter"
|
export "FLUTTER_ROOT=/opt/homebrew/Caskroom/flutter/3.10.2/flutter"
|
||||||
export "FLUTTER_APPLICATION_PATH=/Users/mikedoornenbal/Documents/iconica/flutter_chat/packages/flutter_chat_view"
|
export "FLUTTER_APPLICATION_PATH=/Users/mikedoornenbal/Documents/iconica/flutter_community_chat/packages/flutter_chat_view"
|
||||||
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
|
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
|
||||||
export "FLUTTER_TARGET=lib/main.dart"
|
export "FLUTTER_TARGET=lib/main.dart"
|
||||||
export "FLUTTER_BUILD_DIR=build"
|
export "FLUTTER_BUILD_DIR=build"
|
||||||
export "FLUTTER_BUILD_NAME=0.6.0"
|
export "FLUTTER_BUILD_NAME=1.0.0"
|
||||||
export "FLUTTER_BUILD_NUMBER=0.6.0"
|
export "FLUTTER_BUILD_NUMBER=1.0.0"
|
||||||
export "DART_OBFUSCATION=false"
|
export "DART_OBFUSCATION=false"
|
||||||
export "TRACK_WIDGET_CREATION=true"
|
export "TRACK_WIDGET_CREATION=true"
|
||||||
export "TREE_SHAKE_ICONS=false"
|
export "TREE_SHAKE_ICONS=false"
|
||||||
|
|
|
@ -79,6 +79,9 @@ class _ProfileScreenState extends State<ChatProfileScreen> {
|
||||||
width: size.width,
|
width: size.width,
|
||||||
child: ProfilePage(
|
child: ProfilePage(
|
||||||
user: user!,
|
user: user!,
|
||||||
|
itemBuilderOptions: ItemBuilderOptions(
|
||||||
|
readOnly: true,
|
||||||
|
),
|
||||||
service: ChatProfileService(),
|
service: ChatProfileService(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue