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

Search for messages #629

Merged
merged 2 commits into from
Sep 4, 2021
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
2 changes: 1 addition & 1 deletion lib/ui/nav_pages/home_page/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class HomePage extends StatelessWidget {
fit: BoxFit.cover,
height: 48,
),
onTap: (){
onTap: () {
model.nToWorkspace();
},
),
Expand Down
87 changes: 87 additions & 0 deletions lib/ui/view/dm_search/dm_search_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// ignore_for_file: prefer_const_constructors

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hng/ui/widgets/dm_search_widgets.dart';
import 'package:stacked/stacked.dart';
import 'dm_search_viewmodel.dart';

class DmSearch extends StatefulWidget {
const DmSearch({Key? key}) : super(key: key);

@override
_DmSearchState createState() => _DmSearchState();
}

class _DmSearchState extends State<DmSearch> {
TextEditingController searchCon = TextEditingController();
@override
Widget build(BuildContext context) {
return ViewModelBuilder<DmSearchViewModel>.reactive(
disposeViewModel: false,
initialiseSpecialViewModelsOnce: true,
viewModelBuilder: () => DmSearchViewModel(),
builder: (context, viewModel, child) {
return Scaffold(
// ignore: sized_box_for_whitespace
body: SafeArea(
// ignore: sized_box_for_whitespace
child: Container(
//height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(right: 31.0),
child: Row(
children: <Widget>[
IconButton(
icon: Icon(Icons.chevron_left),
onPressed: () {
Navigator.pop(context);
},
),
Text('Direct Message',
style: GoogleFonts.lato(
fontSize: 18,
fontWeight: FontWeight.w400,
fontStyle: FontStyle.normal,
)),
Spacer(),
GestureDetector(
onTap: () {},
child: Text('Done',
style: GoogleFonts.lato(
fontSize: 14,
fontWeight: FontWeight.w400,
fontStyle: FontStyle.normal,
)),
)
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 17.0),
child: TextField(
controller: searchCon,
decoration: InputDecoration(
hintText: 'To: Type the name of a channel or person',
hintStyle: GoogleFonts.lato(
color: Color(0xFF999999),
),
border: InputBorder.none,
),
),
),
Divider(),
ChannelorPerson(),
],
),
),
),
);
},
);
}
}
13 changes: 13 additions & 0 deletions lib/ui/view/dm_search/dm_search_viewmodel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:stacked/stacked.dart';

class DmSearchViewModel extends IndexTrackingViewModel {
static final DmSearchViewModel instance = DmSearchViewModel._internal();

factory DmSearchViewModel() {
return instance;
}

DmSearchViewModel._internal();

init() {}
}
121 changes: 121 additions & 0 deletions lib/ui/widgets/dm_search_widgets.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:google_fonts/google_fonts.dart';

class Users {
String? userName;
bool? status;
Users({this.userName, this.status = false});
}

class ChannelorPerson extends StatefulWidget {
const ChannelorPerson({Key? key}) : super(key: key);

@override
_ChannelorPersonState createState() => _ChannelorPersonState();
}

class _ChannelorPersonState extends State<ChannelorPerson> {
List<Users> names = [
Users(userName: 'Freshfish', status: true),
Users(userName: 'Fierce', status: false),
Users(userName: 'Dee', status: true),
Users(userName: 'ASAP_A1', status: true),
Users(userName: 'Happix', status: false),
Users(userName: 'Kara', status: true),
Users(userName: 'ChiSarah', status: true),
Users(userName: 'OyinkanUA', status: false),
Users(userName: 'damiAaron', status: true),
Users(userName: 'maxiron', status: true),
Users(userName: 'ChristieDesign', status: true),
Users(userName: 'Detective_Khalifah', status: true),
Users(userName: 'Engr_Jimmy', status: true),
];
bool isOnline = false;
@override
Widget build(BuildContext context) {
return Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: names.length,
itemBuilder: (context, index) {
return CustomTile(
userName: names[index].userName,
isOnline: names[index].status,
);
},
),
);
}
}

class CustomTile extends StatefulWidget {
final String? userName;
final bool? isOnline;

const CustomTile({Key? key, this.userName, this.isOnline = false})
: super(key: key);

@override
State<CustomTile> createState() => _CustomTileState();
}

class _CustomTileState extends State<CustomTile> {
bool isChecked = false;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(top: 5.0),
child: ListTile(
leading: Container(
width: 30.0,
height: 30.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(3.0),
// color: Colors.amberAccent,
image: const DecorationImage(
image: NetworkImage(
'https://images.unsplash.com/photo-1520583457224-aee11bad5112?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=401&q=80',
),
fit: BoxFit.fill,
),
),
),
title: Row(
children: [
Text(widget.userName!,
style: GoogleFonts.lato(
fontWeight: FontWeight.w700,
fontStyle: FontStyle.normal,
fontSize: 16.0,
)),
onlineStatus(isOnline: widget.isOnline!),
],
),
trailing: Checkbox(
value: isChecked,
onChanged: (value) {
setState(() {
isChecked = !isChecked;
});
}),
),
);
}
}

Container onlineStatus({bool isOnline = false}) {
return Container(
margin: const EdgeInsets.only(left: 17.0),
width: 8.0,
height: 8.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: isOnline ? const Color(0xFF007952) : Colors.white,
border: Border.all(
color: const Color(0xFF4D4D4D),
width: 1.5,
),
),
);
}
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.8.1"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -126,7 +126,7 @@ packages:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.1"
checked_yaml:
dependency: transitive
description:
Expand Down Expand Up @@ -407,7 +407,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.7.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -713,7 +713,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
version: "0.4.2"
timing:
dependency: transitive
description:
Expand Down