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

Polls #33

Open
wants to merge 6 commits into
base: release24
Choose a base branch
from
Open

Polls #33

wants to merge 6 commits into from

Conversation

ShmokeD
Copy link

@ShmokeD ShmokeD commented Jan 6, 2025

Add Polls
Calendar UI update## Description

Fixes #(issue number)

Type of Change

  • New feature
  • Bug fix
  • Documentation update
  • Refactoring
  • Hotfix
  • Security patch
  • UI/UX improvement

Changes Made

  • Change 1
  • Change 2
  • Change 3

Screenshots (if applicable)

How to Test

  1. Step 1
  2. Step 2
  3. Step 3

Additional Notes

@priyansh210
Copy link
Collaborator

  1. Add the changes made as points as mentioned in the PR template
  2. Add screenshots for the UI of the polls
  3. Mention the Edge cases tested/validated for the feature

}

@DataClassName('FileDB')
class FileTable extends Table {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if file message deleted? why not using foreign key?

Copy link
Collaborator

@priyansh210 priyansh210 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix changes, Also make sure to have smaller PR's next time : making it easier to review.

];

Map<String, Color> getDpColours(String name) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this function create a DP with a random background color and name initial for the Users which dont have a dp ?

Comment on lines +5 to +37
class ProfilePicture extends StatelessWidget {
final String dp, name;
final double size;

const ProfilePicture(
{super.key, required this.dp, required this.name, this.size = 20});

@override
Widget build(BuildContext context) {
Map<String, Color> colours = getDpColours(name);
Color backgroundColour = colours['background']!;
Color textColour = colours['text']!;

double width = size * 2.0;
return Container(
clipBehavior: Clip.hardEdge,
constraints: BoxConstraints(
minWidth: width, minHeight: width, maxHeight: width, maxWidth: width),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15), color: backgroundColour),
child: CachedNetworkImage(
imageUrl: dp,
fit: BoxFit.cover,
errorWidget: (_, __, ___) => Center(
child: Text(
name.substring(0, 1).toUpperCase(),
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: size, color: textColour),
)),
),
);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will remove the DP image or default_dp logic from the UI, your build function should ideally:
If : DP is filepath is present -> Fetch the DP from local storage or network
else : Display the text w the background (default DP)
And then build the container.

[Discuss with @Alok1721 ]

import 'package:zineapp2023/theme/color.dart';
import 'package:zineapp2023/screens/chat/chat_screen/chat_room.dart';

class ChatDescription extends StatelessWidget {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add in-code doc for the functionality of the class

required this.roomName,
required this.data,
required this.image,
super.key,
});

final String roomName;
final dynamic image;
List<ActiveMember> data;
final String image;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is image_url or file-path make sure the variable name reflets the same intent.

import 'package:zineapp2023/screens/chat/chat_screen/view_model/chat_room_view_model.dart';
import 'package:zineapp2023/theme/color.dart';

class ReplyCard extends StatelessWidget {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add in-code doc for the new class added

Comment on lines 3 to 175
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Colors.black38)),
padding: const EdgeInsets.only(left: 5, right: 5),
width: double.infinity,
child: Column(children: [
TextField(
controller: _titleController,
decoration: InputDecoration(hintText: "Title"),
),

..._controllers.map(
(controller) => PollOption(
controller: controller,
onDelete: onDelete,
),
),

Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
flex: 9,
child: IconButton(
onPressed: () => setState(() {
_controllers
.add(TextEditingController());
}),
icon: Icon(Icons.add))),
Flexible(
flex: 3,
child: InkWell(
onTap: () {
if (kDebugMode) {
print('inSendPoll');
}
chatVm.sendPoll(
_titleController.text,
_controllers
.map(
(TextEditingController
controller) =>
controller.text,
)
.toList());
},
child: SizedBox(
height: 50,
child: Center(child: Text('Send Poll')),
),
),
),
],
)
// FormField(builder: builder)
]))
],
),
)),
const SizedBox(
height: 5,
)
],
),
);
}
}

class PollOption extends StatelessWidget {
final TextEditingController controller;
final Function(TextEditingController) onDelete;
const PollOption(
{super.key, required this.controller, required this.onDelete});

@override
Widget build(BuildContext context) {
return Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
controller: controller,
decoration: InputDecoration(hintText: 'Option'),
),
),
),
IconButton(
onPressed: () {
onDelete(controller);
},
icon: Icon(
Icons.cancel,
color: greyText,
))
],
);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we able to add multiple options in the polls ?

// // print(tasks);

// Above code just set User's links to empty, if the key wasnt created

UserModel userMod = UserModel(
uid: uid,
id: user['id'],
email: user['email'],
name: user['name'],
dp: user['dpUrl'] ?? "1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename var to dpUrl if a filePath, applicable everywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants