NativeScript / NativeScript/docs

Better documentation for extending native classes

Đang mở
#141 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
JavaScript
Star
17
Fork
31
Merge trung bình
8 giờ 51 phút
Pull request đã merge (30 ngày)
2

Mô tả

Is your feature request related to a problem? Please describe.

I need to have access to a native method for the ListView component. The documentation is very unclear about how I would go about doing this. It says that I can subclass android components and has a short example of what this would look like, but the example is frankly very unhelpful:

let constructorCalled = false

@NativeClass
class MyButton extends android.widget.Button {
  constructor() {
    super()
    constructorCalled = true

    // necessary when extending TypeScript constructors
    return global.__native(this)
  }

  setEnabled(enabled: boolean): void {
    this.super.setEnabled(enabled)
  }
}

const button = new MyButton(context)

This example refers to the NativeClass decorator and the android.widget.Button class. Presumeable these would have to be imported from some nativescript modules, but there are no import statements at the top of the file. Where are these coming from? Also, how do I then use this class after extending the base class? If I want it to show up in a stack layout on my main page, for example, how would I do this using nativescript? What about with Vue? Or Svelte? Just instantiating it at the bottom of the file does nothing to tell the application where it should be placed. Also, do I need to place this code in some specific file or directory for it to be picked up by the rest of my code, like from the .xml file?

None of this is mentioned.

Describe the solution you'd like

I'd be satisfied if someone could answer my questions here, but I think the documentation could benefit a lot from this information being added to it directly.

Describe alternatives you've considered

I've searched through the docs, and searched the web too. Nothing is helpful.

Anything else?

No response

Please accept these terms

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu từ phần tài liệu hiện có chứa ví dụ TypeScript NativeClass và android.widget.Button. Làm rõ các import, vị trí của class và cách render một native view được phân lớp con trong một StackLayout, bao gồm cách sử dụng với NativeScript, Vue và Svelte; công việc được xem là hoàn thành khi trang trả lời các câu hỏi này bằng các ví dụ đầy đủ và giải thích XML liên quan như thế nào đến code.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
android, typescript
Lĩnh vực
documentation, mobile
Loại issue
Tài liệu
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.