Skip to content

Commit

Permalink
Xoyrq ux daily (#1644)
Browse files Browse the repository at this point in the history
  • Loading branch information
beastoin authored Jan 6, 2025
2 parents b0c226d + 5de3e7a commit 020286c
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 64 deletions.
106 changes: 62 additions & 44 deletions app/lib/pages/conversations/widgets/search_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,51 +28,69 @@ class _SearchWidgetState extends State<SearchWidget> {
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
child: TextFormField(
controller: searchController,
focusNode: context.read<HomeProvider>().convoSearchFieldFocusNode,
onChanged: (value) {
var provider = Provider.of<ConversationProvider>(context, listen: false);
_debouncer.run(() async {
await provider.searchConversations(value);
});
setShowClearButton();
},
decoration: InputDecoration(
hintText: 'Search Conversations',
hintStyle: const TextStyle(color: Colors.white60, fontSize: 14),
filled: true,
fillColor: Colors.grey.shade900,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: TextFormField(
controller: searchController,
focusNode: context.read<HomeProvider>().convoSearchFieldFocusNode,
onChanged: (value) {
var provider = Provider.of<ConversationProvider>(context, listen: false);
_debouncer.run(() async {
await provider.searchConversations(value);
});
setShowClearButton();
},
decoration: InputDecoration(
hintText: 'Search Conversations',
hintStyle: const TextStyle(color: Colors.white60, fontSize: 14),
filled: true,
fillColor: Colors.grey.shade900,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
),
prefixIcon: const Icon(
Icons.search,
color: Colors.white60,
),
suffixIcon: showClearButton
? GestureDetector(
onTap: () async {
var provider = Provider.of<ConversationProvider>(context, listen: false);
await provider.searchConversations(""); // clear
searchController.clear();
setShowClearButton();
},
child: const Icon(
Icons.close,
color: Colors.white,
),
)
: null,
contentPadding: const EdgeInsets.symmetric(horizontal: 12),
),
style: const TextStyle(color: Colors.white),
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
),
prefixIcon: const Icon(
Icons.search,
color: Colors.white60,
),
suffixIcon: showClearButton
? GestureDetector(
onTap: () async {
var provider = Provider.of<ConversationProvider>(context, listen: false);
await provider.searchConversations(""); // clear
searchController.clear();
setShowClearButton();
},
child: const Icon(
Icons.close,
color: Colors.white,
),
)
: null,
contentPadding: const EdgeInsets.symmetric(horizontal: 12),
),
style: const TextStyle(color: Colors.white),
Consumer<ConversationProvider>(
builder: (BuildContext context, ConversationProvider convoProvider, Widget? child) {
return IconButton(
onPressed: convoProvider.toggleDiscardConversations,
icon: Icon(
convoProvider.showDiscardedConversations ? Icons.filter_alt_off_sharp : Icons.filter_alt_sharp,
color: Colors.white,
size: 24,
),
);
}),
],
),
);
}
Expand Down
3 changes: 1 addition & 2 deletions app/lib/pages/home/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,14 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker
child: const Text('Apps', style: TextStyle(color: Colors.white, fontSize: 18)),
);
} else {
return Flexible(
return Expanded(
child: Row(
children: [
const Spacer(),
SpeechLanguageSheet(
recordingLanguage: provider.recordingLanguage,
setRecordingLanguage: (language) {
provider.setRecordingLanguage(language);

// Notify capture provider
if (context.mounted) {
context.read<CaptureProvider>().onRecordProfileSettingChanged();
Expand Down
18 changes: 5 additions & 13 deletions app/lib/pages/home/widgets/speech_language_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,30 +99,22 @@ class SpeechLanguageSheet extends StatelessWidget {
);
},
child: Container(
width: MediaQuery.of(context).size.width * 0.18,
height: MediaQuery.of(context).size.height * 0.0375,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.grey.shade900,
),
padding: const EdgeInsets.only(left: 8, right: 2),
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 4),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.language,
color: Colors.white,
size: 20,
),
const Spacer(
flex: 2,
size: 24,
),
const SizedBox(width: 4),
Text(
SharedPreferencesUtil().recordingsLanguage.toUpperCase(),
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w500, fontSize: 14),
textAlign: TextAlign.center,
),
const Spacer(
flex: 3,
style: const TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold),
),
],
),
Expand Down
46 changes: 41 additions & 5 deletions app/lib/providers/conversation_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ConversationProvider extends ChangeNotifier implements IWalServiceListener
Map<DateTime, List<ServerConversation>> groupedConversations = {};

bool isLoadingConversations = false;
bool hasNonDiscardedConversations = true;
bool showDiscardedConversations = false;

String previousQuery = '';
int totalSearchPages = 1;
Expand Down Expand Up @@ -75,8 +75,9 @@ class ConversationProvider extends ChangeNotifier implements IWalServiceListener
previousQuery = "";
currentSearchPage = 0;
totalSearchPages = 0;
searchedConversations = conversations;
groupSearchConvosByDate();
searchedConversations = [];
groupConversationsByDate();

notifyListeners();
return;
}
Expand Down Expand Up @@ -148,12 +149,31 @@ class ConversationProvider extends ChangeNotifier implements IWalServiceListener
}
}

void toggleDiscardConversations() {
showDiscardedConversations = !showDiscardedConversations;

if (previousQuery.isNotEmpty) {
groupSearchConvosByDate();
} else {
groupConversationsByDate();
}

MixpanelManager().showDiscardedMemoriesToggled(showDiscardedConversations);
}

void setLoadingConversations(bool value) {
isLoadingConversations = value;
notifyListeners();
}

Future getInitialConversations() async {
// reset search
previousQuery = "";
currentSearchPage = 0;
totalSearchPages = 0;
searchedConversations = [];

// fetch convos
conversations = await getConversationsFromServer();

processingConversations = conversations.where((m) => m.status == ConversationStatus.processing).toList();
Expand All @@ -171,9 +191,25 @@ class ConversationProvider extends ChangeNotifier implements IWalServiceListener
notifyListeners();
}

List<ServerConversation> _filterOutConvos(List<ServerConversation> convos) {
var havingFilters = true;
if (showDiscardedConversations) {
havingFilters = false;
}
if (!havingFilters) {
return convos;
}
return convos.where((convo) {
if (!showDiscardedConversations && (convo.discarded && !convo.isNew)) {
return false;
}
return true;
}).toList();
}

void _groupSearchConvosByDateWithoutNotify() {
groupedConversations = {};
for (var conversation in searchedConversations) {
for (var conversation in _filterOutConvos(searchedConversations)) {
var date = DateTime(conversation.createdAt.year, conversation.createdAt.month, conversation.createdAt.day);
if (!groupedConversations.containsKey(date)) {
groupedConversations[date] = [];
Expand All @@ -189,7 +225,7 @@ class ConversationProvider extends ChangeNotifier implements IWalServiceListener

void _groupConversationsByDateWithoutNotify() {
groupedConversations = {};
for (var conversation in conversations) {
for (var conversation in _filterOutConvos(conversations)) {
var date = DateTime(conversation.createdAt.year, conversation.createdAt.month, conversation.createdAt.day);
if (!groupedConversations.containsKey(date)) {
groupedConversations[date] = [];
Expand Down

0 comments on commit 020286c

Please sign in to comment.