Blackberry10 cascades - buttonclick

I am new to Blackberry 10 development. I have created a button, but I am not able to do the Push screen function from the current screen to next screen. Here is the code I am using:
onClicked:{
navigationPane.push(firstPage);
}
And I have also implemented a tab using
TabbedPane {
activePane: Page {
Label {
id: label
text: "What do you like more, kittens or puppies?"
}
}
sidebarState: SidebarState.VisibleCompact
onActiveTabChanged: {
}
Tab {
title: "Puppies"
onTriggered: label.text = "kittens"
NavigationPane {
id: navigationPane
//how to call a screen from this,i got stuck with this,can any some send me simple code for pushing a screen.?
}
}
Tab {
title: "Kittens"
onTriggered: label.text = "I love kittens!"
NavigationPane {
id: navigationPane
> **`//how to call a screen from this,i got stuck with this,can any some send me simple code for pushing a screen.?`**
}
}
}
In this tab I want to do a push screen function while clicking the tab's icon. Can anyone help me with these two functions?
Thanks.

here is the example for creating tabs for different screen,you are in main tab to go next qml as follows
Tab {
title: "Puppies"
NavigationPane {
id: navigationPane
Sample //this is one qml page as like Sample.qml
{
}
}
}
Tab {
title: "Kittens"
NavigationPane {
id: testpage
Test //this is one qml page as like Test.qml
{
}
}
}
you can access other qml files by setting the id:,

You have to declare a NavigationPane inside each Tab, and push inside it:
Tab {
title: "Puppies"
onTriggered: label.text = "kittens"
NavigationPane {
id: navigationPane
}
}

Related

How to select an item from a search file and place in textfield in another file

Using SwiftUI - Xcode 14.2 - iOS 16.0
I have tried different search tutorials to create a search file for my project but am unable to find out how to select the item in the search file and place that selected item in a textfield in another file. I have searched this site for other posts, i tried searching through Google, YouTube, etc...
In File 1, I have a textfield that that has a prompt 'start typing' and when selected, it directs you to the Search file to select the item you want, so it can be placed in place of the prompt.
File 1 (where the textfield is needed to paste the selected item):
VStack {
NavigationLink(destination: NameSearch()) {
TextField("Name", text: .constant(""), prompt: Text(" Start typing ")
.foregroundColor(.blue))
.multilineTextAlignment(.leading)
.padding()
}
}
Once I click on the 'start typing' prompt, it navigates to NameSearch.swift file, as seen below.
NameSearch.swift:
import SwiftUI
struct NameSearch: View {
let name = [
"Jane", "George", "Sam", "Henry", "Sally", "Liz", "John"
]
#State private var searchText = ""
var body: some View {
NavigationStack {
VStack {
// Search view
SearchBarView(searchText: $searchText)
List {
// Filtered list of names
ForEach(name.filter{$0.hasPrefix(searchText) || searchText == ""}, id:\.self) {
searchText in Text(searchText)
}
}
.navigationBarTitle(Text("Search Name"))
.resignKeyboardOnDragGesture()
}
}
}
}
struct NameSearch_Previews: PreviewProvider {
static var previews: some View {
Group {
NameSearch()
.environment(\.colorScheme, .light)
NameSearch()
.environment(\.colorScheme, .dark)
}
}
}
extension UIApplication {
func endEditing(_ force: Bool) {
self.windows
.filter{$0.isKeyWindow}
.first?
.endEditing(force)
}
}
struct ResignKeyboardOnDragGesture: ViewModifier {
var gesture = DragGesture().onChanged{_ in
UIApplication.shared.endEditing(true)
}
func body(content: Content) -> some View {
content.gesture(gesture)
}
}
extension View {
func resignKeyboardOnDragGesture() -> some View {
modifier(ResignKeyboardOnDragGesture())
}
}
struct SearchBarView: View {
#Binding var searchText: String
#State private var showCancelButton: Bool = false
var onCommit: () ->Void = {print("onCommit")}
var body: some View {
HStack {
HStack {
Image(systemName: "magnifyingglass")
// Search text field
ZStack (alignment: .leading) {
if searchText.isEmpty { // Separate text for placeholder to give it the proper color
Text("Search")
}
TextField("", text: $searchText, onEditingChanged: { isEditing in
self.showCancelButton = true
}, onCommit: onCommit).foregroundColor(.primary)
}
// Clear button
Button(action: {
self.searchText = ""
}) {
Image(systemName: "xmark.circle.fill").opacity(searchText == "" ? 0 : 1)
}
}
.padding(EdgeInsets(top: 8, leading: 6, bottom: 8, trailing: 6))
.foregroundColor(.secondary) // For magnifying glass and placeholder test
.background(Color(.tertiarySystemFill))
.cornerRadius(10.0)
if showCancelButton {
// Cancel button
Button("Cancel") {
UIApplication.shared.endEditing(true) // this must be placed before the other commands here
self.searchText = ""
self.showCancelButton = false
}
.foregroundColor(Color(.systemBlue))
}
}
.padding(.horizontal)
.navigationBarHidden(showCancelButton)
}
}
Question 1: How do I hide all the names from showing in the list so that I just see the search bar and the cancel button and an empty list?
Question 2: Once I type the name I am looking for, it should pop up and I want to select name - how can I do this?
once I type the name in search bar, it appears in the empty list
I select that name
it then takes me back to File 1
replaces the 'start typing' prompt with the name i just selected in the Search file.
Question 3: I have noticed in the Search file, I am getting a warning with the following code. How can I resolve it?
extension UIApplication {
func endEditing(_ force: Bool) {
self.windows
.filter{$0.isKeyWindow}
.first?
.endEditing(force)
}
}
The warning that appears is:
'windows' was deprecated in iOS 15.0: Use UIWindowScene.windows on a
relevant window scene instead
Firstly, thank you for providing a working example of your code.
As you're building for iOS 15+, you should probably be using the .searchable modifier rather than rolling your own.
The 2021 WWDC video introducing this feature is here https://developer.apple.com/wwdc21/10176
Some new features from 2022 here: https://developer.apple.com/wwdc22/10052

SwiftUI UISearchController replacement: search field, results and some scrollable content fail to coexist in a meaningful manner

Starting with this
var body: some View {
ScrollView {
VStack(spacing: 0.0) {
Some views here
}
}
.edgesIgnoringSafeArea(.top)
}
How would I add
List(suggestions, rowContent: { text in
NavigationLink(destination: ResultsPullerView(searchText: text)) {
Text(text)
}
})
.searchable(text: $searchText)
on top if that scrollable content?
Cause no matter how I hoax this together when
#State private var suggestions: [String] = []
gets populated (non empty) the search results are not squeezed in (or, better yet, shown on top of
"Some views here"
So what I want to achieve in different terms: search field is on top, scrollable content driven by the search results is underneath, drop down with search suggestions either temporarily squeeses scrollable content down or is overlaid on top like a modal sheet.
Thanks!
If you are looking for UIKit like search behaviour you have to display your results in an overlay:
1. Let's declare a screen to display the results:
struct SearchResultsScreen: View {
#Environment(\.isSearching) private var isSearching
var results: [String]?
var body: some View {
if isSearching, let results {
if results.isEmpty {
Text("nothing to see here")
} else {
List(results, id: \.self) { fruit in
NavigationLink(destination: Text(fruit)) {
Text(fruit)
}
}
}
}
}
}
2. Let's have an ObservableObject to handle the logic:
class Search: ObservableObject {
static private let fruit = [
"Apples 🍏",
"Cherries 🍒",
"Pears 🍐",
"Oranges 🍊",
"Pineapples 🍍",
"Bananas 🍌"
]
#Published var text: String = ""
var results: [String]? {
if text.isEmpty {
return nil
} else {
return Self.fruit.filter({ $0.contains(text)})
}
}
}
3. And lastly lets declare the main screen where the search bar is displayed:
struct ContentView: View {
#StateObject var search = Search()
var body: some View {
NavigationView {
LinearGradient(colors: [.orange, .red], startPoint: .topLeading, endPoint: .bottomTrailing)
.overlay(SearchResultsScreen(results: search.results))
.searchable(text: $search.text)
.navigationTitle("Find that fruit")
}
}
}

How stop auto refresh of egui screen

I have the following menu item
fn update(&mut self, ctx: &egui::Context, frame: &epi::Frame) {
//let Self { label, value } = self;
// Examples of how to create different panels and windows.
// Pick whichever suits you.
// Tip: a good default choice is to just keep the `CentralPanel`.
// For inspiration and more examples, go to https://emilk.github.io/egui
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// The top panel is often a good place for a menu bar:
egui::menu::bar(ui, |ui| {
ui.menu_button("File", |ui| {
if ui.button("Quit").clicked() {
frame.quit();
}
});
ui.menu_button("Items", |ui| {
if ui.button("Exchanges").clicked() {
println!("Exchanges");
ui.close_menu();
exchange_trans(ctx);
}
if ui.button("Coins").clicked() {
println!("Coins");
ui.close_menu();
}
if ui.button("Transactions").clicked() {
println!("Transactions");
ui.close_menu();
}
});
I call
'''
pub fn exchange_trans(ctx: &egui::Context) {
egui::SidePanel::left("side_panel").show(ctx, |ui| {
ui.heading("My egui Application");
ui.horizontal(|ui| {
ui.label("Your name: ");
ui.group(|ui| {
ui.label("Within a frame");
ui.set_min_height(200.0);
});
// ui.text_edit_singleline(&mut name);
});
}
'''
The problem is that a black screen shows up when it is available to select a menu item. When I select the Exchange menu item the screen blinks and then black to black. I think the refresh rate is set to continuous and I need it set to reactive. How do I do it or am I on the wrong track.
You don't have to disable update.
I would try to do as in the example
https://github.com/emilk/eframe_template/blob/master/src/app.rs
fn update(..) {
...
if my_variable {
egui::SidePanel::left("side_panel").show(ctx, |ui| {
ui.heading("My egui Application");
....
});
}
}
and from the menu changes my_variable to true of false - not executing the method exchange_trans(ctx); because it will be overwritten by the update
ui.menu_button("Items", |ui| {
if ui.button("Exchanges").clicked() {
println!("Exchanges");
ui.close_menu();
my_variable = !my_variable;

Deleting CoreData without onDelete in SwiftUI

my app shows CoreData as following in VStack. List isn't possible due to ScrollView.
VStack (spacing: 20) {
ForEach(groups) { group in
NavigationLink(destination: GroupView()) {
ZStack (alignment: .bottomLeading) {
Image(uiImage: (UIImage(data: group.groupThumbnail ?? self.image) ?? UIImage(named: "defaultGroupThumbnail"))!)
.resizable(capInsets: EdgeInsets())
.aspectRatio(contentMode: .fill)
.frame(height: 200, alignment: .center)
.cornerRadius(22)
VStack (alignment: .leading) {
Text("\(group.groupTitle ?? "Untitled")")
.font(.title)
.fontWeight(.heavy)
.multilineTextAlignment(.leading)
Text("Consists of 5 Flowers")
}
.padding([.leading, .bottom], 18.0)
.foregroundColor(.primary)
}
However, I can delete my entries with onDelete. Therefore, I am trying to find an alternative with .contextMenu.
.contextMenu {
Button (role: .destructive) {
withAnimation {
self.deleteGroups(at: IndexSet.init(arrayLiteral: 0)) // This is the code I copied from the video.
}
} label: {
Label("Delete", systemImage: "trash")
}
Button {
print()
} label: {
Label("Edit", systemImage: "square.and.pencil")
}
}
I saw a video in which somebody was able to delete his entry with the combination of these to codes
When tapping on "Delete", the entry should be deleted by this code:
func deleteGroups(at offsets: IndexSet) {
for offset in offsets {
let group = groups[offset]
viewContext.delete(group)
}
//try? viewContext.save()
}
But, whenever I click this "Delete" Button in context menu, the wrong one gets deleted. I can't get the code to delete the selected entry. If anyone can help me, that would be appreciated. Thanks in Advance!
Not that important but, is there a delete feature compared to "onDelete" (such as swiping to delete) I can still implement? And are there any possibilities for animation in my case?
Kind Regards
Just delete it in the normal way:
Button (role: .destructive) {
withAnimation {
viewContext.delete(group)
do {
try viewContext.save()
} catch {
// show error
}
}
} label: {
Label("Delete", systemImage: "trash")
}
FYI I also edited your question to fix your ForEach syntax.
ForEach(groups, id: \.self) { group in
.contextMenu {
Button (role: .destructive) {
for index in groups.indices{
if group == groups[index]{
withAnimation{
viewContext.delete(group)
}
}
}
} label: {
Label("Delete", systemImage: "trash")
}
Button {
print()
} label: {
Label("Edit", systemImage: "square.and.pencil")
}
}

How to check whether a text value content exists in a Bixby layout view

If a text property exists, I want to display an attribution link; if it is empty or undefined, display nothing.
if (relatedurl)
{section {
content {
attribution-link {
label {
template ("Related content: ")
}
url ("#{value(this.relatedurl)}")
}
}
}
This is displaying as empty while the same code without the if is displaying the attribution link properly.How do I formulate the test?
if (exists(this.relatedurl))
{
section {
content {
attribution-link {
label {
template ("Related content: ")
}
url ("#{value(this.relatedurl)}")=}
}
}
}
// if no relatedurl, don't print anything
per https://bixbydevelopers.com/dev/docs/dev-guide/developers/customizing-plan.using-el

Resources