diff --git a/lib/src/views/_new_camera_preview_view.dart b/lib/src/views/_new_camera_preview_view.dart new file mode 100644 index 0000000..349413c --- /dev/null +++ b/lib/src/views/_new_camera_preview_view.dart @@ -0,0 +1,118 @@ +// import 'package:camera/camera.dart'; +// import 'camera_editor_view.dart'; +// import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:camerawesome/camerawesome_plugin.dart'; + +class CameraPreviewView extends StatelessWidget { + const CameraPreviewView({super.key}); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + title: 'Custom CamerAwesome UI', + home: CameraPage(), + ); + } +} + +class CameraPage extends StatelessWidget { + const CameraPage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: CameraAwesomeBuilder.awesome( + saveConfig: SaveConfig.photo(), + sensorConfig: SensorConfig.single( + sensor: Sensor.position(SensorPosition.back), + aspectRatio: CameraAspectRatios.ratio_1_1, + ), + previewFit: CameraPreviewFit.contain, + previewPadding: const EdgeInsets.only(left: 150, top: 100), + previewAlignment: Alignment.topRight, + // Buttons of CamerAwesome UI will use this theme + theme: AwesomeTheme( + bottomActionsBackgroundColor: Colors.cyan.withOpacity(0.5), + buttonTheme: AwesomeButtonTheme( + backgroundColor: Colors.cyan.withOpacity(0.5), + iconSize: 20, + foregroundColor: Colors.white, + padding: const EdgeInsets.all(16), + // Tap visual feedback (ripple, bounce...) + buttonBuilder: (child, onTap) { + return ClipOval( + child: Material( + color: Colors.transparent, + shape: const CircleBorder(), + child: InkWell( + splashColor: Colors.cyan, + highlightColor: Colors.cyan.withOpacity(0.5), + onTap: onTap, + child: child, + ), + ), + ); + }, + ), + ), + topActionsBuilder: (state) => AwesomeTopActions( + padding: EdgeInsets.zero, + state: state, + children: [ + Expanded( + child: AwesomeFilterWidget( + state: state, + filterListPosition: FilterListPosition.aboveButton, + filterListPadding: const EdgeInsets.only(top: 8), + ), + ), + ], + ), + middleContentBuilder: (state) { + return Column( + children: [ + const Spacer(), + Builder(builder: (context) { + return Container( + color: AwesomeThemeProvider.of(context) + .theme + .bottomActionsBackgroundColor, + child: const Align( + alignment: Alignment.bottomCenter, + child: Padding( + padding: EdgeInsets.only(bottom: 10, top: 10), + child: Text( + "Take your best shot!", + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontStyle: FontStyle.italic, + ), + ), + ), + ), + ); + }), + ], + ); + }, + bottomActionsBuilder: (state) => AwesomeBottomActions( + state: state, + left: AwesomeFlashButton( + state: state, + ), + right: AwesomeCameraSwitchButton( + state: state, + scale: 1.0, + onSwitchTap: (state) { + state.switchCameraSensor( + aspectRatio: state.sensorConfig.aspectRatio, + ); + }, + ), + ), + ), + ); + } +} diff --git a/lib/src/views/camera_preview_view.dart b/lib/src/views/camera_preview_view.dart index a9a9855..8bd18de 100644 --- a/lib/src/views/camera_preview_view.dart +++ b/lib/src/views/camera_preview_view.dart @@ -2,6 +2,7 @@ import 'package:camera/camera.dart'; import 'camera_editor_view.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +// import 'package:camerawesome/camerawesome_plugin.dart'; import 'dart:math'; class CameraPreviewView extends StatefulWidget { diff --git a/lib/src/views/chat_item_details_view.dart b/lib/src/views/chat_item_details_view.dart index a6782e8..1f04d37 100644 --- a/lib/src/views/chat_item_details_view.dart +++ b/lib/src/views/chat_item_details_view.dart @@ -1,21 +1,109 @@ import 'package:flutter/material.dart'; +class AlignedTextBox extends StatelessWidget { + const AlignedTextBox({super.key, required this.text, required this.right}); + final String text; + final bool right; + @override + Widget build(BuildContext context) { + return Align( + alignment: right ? Alignment.centerRight : Alignment.centerLeft, + child: Padding( + padding: EdgeInsets.all(10), + child: Container( + constraints: BoxConstraints( + maxWidth: MediaQuery.of(context).size.width * + 0.8, // Maximum 80% of the screen width + ), + padding: EdgeInsets.symmetric( + vertical: 4, horizontal: 10), // Add some padding around the text + decoration: BoxDecoration( + color: right + ? Colors.deepPurpleAccent + : Colors.blueAccent, // Set the background color + borderRadius: BorderRadius.circular(12.0), // Set border radius + ), + child: Text( + text, + style: TextStyle( + color: Colors.white, // Set text color for contrast + fontSize: 17, + ), + textAlign: TextAlign.left, // Center the text + ), + ), + ), + ); + } +} + /// Displays detailed information about a SampleItem. class SampleItemDetailsView extends StatelessWidget { const SampleItemDetailsView({super.key, required this.userId}); final int userId; - static const routeName = '/sample_item'; - @override Widget build(BuildContext context) { + List> messages = [ + ["Hallo", true], + ["Wie geht's?", false], + ["Das ist ein Test.", true], + ["Flutter ist großartig!", false], + ["Ich liebe Programmieren.", true], + ["Das Wetter ist schön.", false], + ["Hast du Pläne für heute?", true], + ["Ich mag Pizza.", false], + ["Lass uns einen Film schauen.", false], + ["Das ist interessant.", false], + ["Ich bin müde.", true], + ["Was machst du gerade?", true], + ["Ich habe ein neues Hobby.", true], + ["Das ist eine lange Nachricht.", false], + ["Ich freue mich auf das Wochenende.", true], + ["Das ist eine zufällige Nachricht.", false], + ["Ich lerne Dart.", true], + ["Wie war dein Tag?", true], + ["Ich genieße die Natur.", true], + ["Das ist ein schöner Ort.", false], + ["Meine letzte Nachricht.", false], + ]; + messages = messages.reversed.toList(); return Scaffold( appBar: AppBar( title: Text('Your Chat with $userId'), ), - body: const Center( - child: Text('Hallo!'), + body: Column( + children: [ + Expanded( + child: ListView.builder( + itemCount: messages.length, // Number of items in the list + reverse: true, + itemBuilder: (context, i) { + return AlignedTextBox( + text: messages[i][0], right: messages[i][1]); + }, + ), + ), + const SizedBox( + height: 10, + ), + Padding( + padding: const EdgeInsets.only(bottom: 40, left: 10, right: 10), + child: TextField( + decoration: InputDecoration( + // border: OutlineInputBorder(), + labelText: 'Enter your message', + suffixIcon: IconButton( + icon: Icon(Icons.send), + onPressed: () { + // Handle send action + }, + ), + ), + ), + ), + ], ), ); } diff --git a/lib/src/views/chat_list_view.dart b/lib/src/views/chat_list_view.dart index b67ca37..cae5d25 100644 --- a/lib/src/views/chat_list_view.dart +++ b/lib/src/views/chat_list_view.dart @@ -167,6 +167,9 @@ class _ChatListViewState extends State { // Extract initials from the username List nameParts = username.split(' '); String initials = nameParts.map((part) => part[0]).join().toUpperCase(); + if (initials.length > 2) { + initials = initials[0] + initials[1]; + } // Generate a color based on the initials (you can customize this logic) Color avatarColor = _getColorFromInitials(initials); diff --git a/pubspec.lock b/pubspec.lock index c1906fb..d28ad11 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -166,6 +166,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.5" + camerawesome: + dependency: "direct main" + description: + name: camerawesome + sha256: "3619d5605fb14ab72c815532c1d9f635512c75df07b5a742b60a9a4b03b6081e" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + carousel_slider: + dependency: transitive + description: + name: carousel_slider + sha256: "7b006ec356205054af5beaef62e2221160ea36b90fb70a35e4deacd49d0349ae" + url: "https://pub.dev" + source: hosted + version: "5.0.0" characters: dependency: transitive description: @@ -214,6 +230,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.19.0" + colorfilter_generator: + dependency: transitive + description: + name: colorfilter_generator + sha256: ccc2995e440b1d828d55d99150e7cad64624f3cb4a1e235000de3f93cf10d35c + url: "https://pub.dev" + source: hosted + version: "0.0.8" convert: dependency: transitive description: @@ -586,6 +610,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.11.1" + matrix2d: + dependency: transitive + description: + name: matrix2d + sha256: "188718dd3bc2a31e372cfd0791b0f77f4f13ea76164147342cc378d9132949e7" + url: "https://pub.dev" + source: hosted + version: "1.0.4" meta: dependency: transitive description: @@ -818,6 +850,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + rxdart: + dependency: transitive + description: + name: rxdart + sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962" + url: "https://pub.dev" + source: hosted + version: "0.28.0" shared_preferences: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 6ce8106..e202990 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,6 +11,7 @@ environment: dependencies: camera: ^0.11.0+2 + camerawesome: ^2.1.0 collection: ^1.18.0 cv: ^1.1.3 fixnum: ^1.1.1