<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ethar on Medium]]></title>
        <description><![CDATA[Stories by Ethar on Medium]]></description>
        <link>https://medium.com/@etharalrehaili?source=rss-9690d1b2f21c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_1t7h6-mcGe_RfQFM190yg.jpeg</url>
            <title>Stories by Ethar on Medium</title>
            <link>https://medium.com/@etharalrehaili?source=rss-9690d1b2f21c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 00:26:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@etharalrehaili/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AI Pair Programming]]></title>
            <link>https://medium.com/@etharalrehaili/ai-pair-programming-d2b372bfd108?source=rss-9690d1b2f21c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2b372bfd108</guid>
            <category><![CDATA[github-copilot]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[ai-pair-programming]]></category>
            <dc:creator><![CDATA[Ethar]]></dc:creator>
            <pubDate>Sat, 01 Nov 2025 13:21:48 GMT</pubDate>
            <atom:updated>2025-11-02T09:43:54.692Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KC70dWbUurai4wo8SJ8Q9Q.png" /></figure><p>AI Pair Programming platforms are designed to create <strong>real-time collaboration</strong> between developers and an intelligent <strong>AI assistant</strong> that understands the entire codebase.<br> These tools act like a second developer — helping with <strong>debugging, refactoring, and code explanation</strong> — while learning from your coding style and project structure.</p><h3>Why Developers Use AI Pair Programming</h3><p>AI pair programming tools are used to:</p><ul><li><strong>Boost productivity</strong> by generating or completing code automatically.</li><li><strong>Reduce boilerplate</strong> and repetitive patterns.</li><li><strong>Learn from AI suggestions</strong> and explanations.</li><li><strong>Improve code quality</strong> through optimized and cleaner implementations.</li></ul><h3>Gemini</h3><p><strong>Developed by:</strong> Google<br><strong>Best for:</strong> Android-focused developers using Android Studio<br><strong>Free tier:</strong> Yes, with limited usage<br><strong>Integration:</strong> Built directly into Android Studio (Tools → Gemini)</p><p><strong>Overview:</strong><br>Gemini is Google’s AI-powered coding companion tailored specifically for Android development. It assists developers by generating code, explaining concepts, and performing development tasks directly inside Android Studio. With context-awareness and deep IDE integration, it becomes a natural part of the Android developer workflow.</p><p><strong>Key Features:</strong></p><ul><li><strong>Inline code suggestions</strong> — writes or completes code intelligently.</li><li><strong>Gemini Chat panel</strong> — allows interactive conversations with AI about your code.</li><li><strong>AI-powered companion</strong> — helps debug, refactor, and understand code.</li><li><strong>Context-aware assistance</strong> — understands your project context within Android Studio.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*R1Xag6eUHYndWBb6bqR8Jg.png" /><figcaption>chat panel</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*Y33VDu3x7DCXRFENFIaZgw.png" /><figcaption>inline code suggestion</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_iaaoC8Omo19x-2s_hZ61Q.png" /><figcaption>suggestions</figcaption></figure><h3>GitHub Copilot</h3><p><strong>Developed by:</strong> GitHub + OpenAI<br><strong>Best for:</strong> Developers working across multiple languages and IDEs<br><strong>Free tier:</strong> Yes, with limited usage<br><strong>Integration:</strong> Available as a plugin for Android Studio and other editors</p><p><strong>Overview:</strong><br>GitHub Copilot is a versatile AI-powered coding assistant that integrates seamlessly into popular IDEs, including Android Studio. It suggests entire lines or functions in real time, helping developers code faster, understand complex snippets, and even optimize existing code.</p><p><strong>Key Features:</strong></p><ul><li><strong>Inline code suggestions</strong> — real-time AI autocompletion for code.</li><li><strong>Chat panel</strong> — interact with Copilot to ask questions about code or logic.</li><li><strong>Multi-language support</strong> — works across Python, Java, Kotlin, C++, and more.</li><li><strong>Code explanation and optimization</strong> — clarifies logic and improves readability.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kyhDC_tyxkOSpM1MsJ0EAg.png" /><figcaption>suggestions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uxKxniJi9LeCmlhBfQbCaQ.png" /><figcaption>chat panel</figcaption></figure><h3>Final Thoughts</h3><p>AI pair programming tools like <strong>Gemini</strong> and <strong>GitHub Copilot</strong> are transforming the development workflow — turning the IDE into an intelligent, collaborative workspace.<br> While Gemini offers <strong>deep Android integration</strong>, GitHub Copilot provides <strong>cross-language flexibility</strong>, making both tools essential companions for modern developers aiming for speed, quality, and learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2b372bfd108" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Documentation & Explanation]]></title>
            <link>https://medium.com/@etharalrehaili/ai-documentation-explanation-5ce34e5b109f?source=rss-9690d1b2f21c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ce34e5b109f</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[api-documentation]]></category>
            <category><![CDATA[technical-documentation]]></category>
            <category><![CDATA[documentation]]></category>
            <category><![CDATA[ai-tools]]></category>
            <dc:creator><![CDATA[Ethar]]></dc:creator>
            <pubDate>Fri, 31 Oct 2025 12:51:49 GMT</pubDate>
            <atom:updated>2025-11-02T12:19:06.182Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KPMhovE2EwwZscrau1gU6g.jpeg" /></figure><h3>How Tools Like Workik, DocuWriter.ai, AutoCodeDocs, and Swimm.io Are Changing the Way Developers Document Code</h3><p>In today’s fast-paced software world, writing clear and maintainable documentation is often the hardest part of a project. Developers love to build, but few enjoy stopping to explain how their code works. That’s where AI documentation tools step in.</p><p>AI documentation tools act as <strong>intelligent assistants</strong> that automatically generate readable documentation and explain complex codebases. They analyze your code, APIs, or workflows to understand their logic and structure, then produce clear, structured guides that make your projects easier to understand, maintain, and onboard new developers.</p><p>By automating this process, AI saves hours of manual effort and helps teams focus more on development than documentation.</p><h3><a href="https://workik.com/"><strong>Workik</strong></a></h3><p>is an <strong>AI-powered development workspace</strong> that brings coding, documentation, debugging, and automation together in one place.</p><p>You can integrate it with <strong>VS Code</strong> or <strong>JetBrains IDEs</strong>, and it supports multiple AI models including <strong>GPT, Gemini, Claude, DeepSeek, LLaMA</strong>, and <strong>Mistral. </strong>letting you pick the model that fits your workflow best.</p><h3><strong>Main Features</strong></h3><h4>Programming with AI</h4><p>Generate complete code modules from natural-language requirements, saving time and reducing human error.</p><h4>Learning with AI</h4><p>Describe any topic and let Workik build a <strong>custom learning course</strong> complete with lessons, quizzes, and projects.</p><h4>Database Tools</h4><p>Upload your schema (CSV/JSON) or connect to a live database. AI will create, modify, and even document the structure for you.</p><h4>AI Automation</h4><p>Automate DevOps tasks such as pull-requests, build pipelines, and more with minimal configuration.</p><h4>AI Code Documentation</h4><p>Connect your GitHub repository and let Workik auto-generate structured, editable documentation for your codebase.</p><h4>AI Database Documentation</h4><p>Automatically document database schemas and relationships across systems such as: <strong>MySQL, PostgreSQL, MongoDB, MS SQL, and MariaDB</strong></p><h3>Free &amp; Paid Plans</h3><p>Workik provides both a <strong>free tier</strong> with daily usage limits and <strong>paid plans</strong> for higher capacity and enterprise-grade features. This flexible model makes it suitable for both <strong>individual developers</strong> and <strong>teams</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mp280R-rSxbWnJ25CgPN-w.png" /><figcaption>File Upload</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XHcxXI0W1OOYwOEDLm5mqQ.png" /><figcaption>Workik Preview Mode</figcaption></figure><h3><a href="http://docuwriter.ai/"><strong>DocuWriter.ai</strong></a></h3><p>focuses purely on <strong>automated documentation generation</strong>. It reads your source code or Git repository and creates <strong>complete, multi-page technical docs</strong>, tests, UML diagrams, and even refactored code suggestions.</p><h3>Main Features</h3><h4>Code Documentation Generator</h4><p>Upload multiple files and generate structured documentation instantly.</p><h4>Swagger API Documentation</h4><p>Automatically build Swagger API docs for any language.</p><h4>Code Comment Generator</h4><p>Insert intelligent DocBlocks and annotations into your existing code.</p><h4>UML Diagram Generator (Beta)</h4><p>Visualize your project’s architecture and relationships.</p><h4>Code Test Generator</h4><p>Produce automated test cases for your functions.</p><h4>Code Refactor &amp; Optimization</h4><p>Get AI-powered suggestions for cleaner, faster code.</p><h4>Code Language Converter</h4><p>Translate code between programming languages while preserving logic.</p><h4>Git Integration</h4><p>Connect your GitHub or GitLab repos to generate full-tree documentation automatically.</p><h3>Free Trial</h3><p>DocuWriter.ai offers a <strong>free trial</strong> with all core features unlocked. no upfront payment required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eDl4L7la8Sbfp22BE-nxjA.png" /><figcaption>DocuWriter Home Page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S0atep4jovHsM3tnmTFidQ.png" /><figcaption>File Upload &amp; Documentation Types</figcaption></figure><h4><a href="https://autocodedocs.ai/"><strong>AutoCodeDocs</strong></a></h4><p>is an <strong>AI-powered documentation generator</strong> that automatically creates <strong>clear, structured, and professional documentation</strong> from your uploaded source code.<br>It can instantly produce <strong>README files</strong>, <strong>API references</strong>, and <strong>inline code comments</strong>, helping developers save time, improve project organization, and onboard team members faster.</p><p>With no integrations or setup required, AutoCodeDocs works out-of-the-box — simply <strong>upload your code</strong>, and it generates complete documentation in seconds.</p><h3>Main Features</h3><h4>Instant AI-Generated Documentation</h4><p>Upload your source code and get <strong>complete documentation in seconds</strong>, including project overviews, READMEs, and detailed API references.</p><h4>Explains Code in Plain English</h4><p>AutoCodeDocs uses AI to <strong>summarize and explain logic</strong> across your codebase.<br> It provides <strong>inline comments</strong> and <strong>clear explanations</strong> that make understanding complex code faster and easier.</p><h4>Automatic Code Comments</h4><p>Generate <strong>professional inline comments</strong> that describe each function, logic block, and best practice — ideal for improving code readability and maintainability.</p><h4>API Documentation Generator</h4><p>The AI creates <strong>structured API documentation</strong> with parameter descriptions, return types, and usage examples.<br> Output formats include <strong>Markdown</strong>, <strong>PDF</strong>, and more — making it easy to publish your docs anywhere.</p><h4>Multi-Language Support</h4><p>AutoCodeDocs supports <strong>JavaScript, Python, Java, Go</strong>, and <strong>20+ other languages</strong>, automatically analyzing and documenting your code regardless of tech stack.</p><h4>Export to Markdown</h4><p>Seamlessly <strong>export</strong> your documentation to integrate with internal <strong>wikis</strong>, <strong>developer portals</strong>, or <strong>knowledge bases</strong>.</p><h3>Simple Workflow</h3><ol><li>Upload your source code</li><li>AI analyzes your codebase</li><li>Generates documentation instantly</li><li>Export and share your docs anywhere</li></ol><h3>Free &amp; Paid Plans</h3><p><strong>AutoCodeDocs</strong> offers <strong>free</strong> and <strong>paid</strong> plans — the free tier covers small projects and single files, while paid plans unlock full-project documentation, advanced export options, and faster AI generation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vu70oUZmM62YkxsnXKAjMg.png" /><figcaption>AutoCodeDocs Home Page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x_3wIP8fOGdqxU_5F57VQQ.png" /><figcaption>File Upload &amp; Documentation Types</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PHVKUVkHwvVo6yrM0u1ohQ.png" /><figcaption>AutoCodeDocs Preview Mode</figcaption></figure><h3><a href="https://app.swimm.io/"><strong>Swimm.io</strong></a></h3><p>is an <strong>AI-powered static analysis and documentation platform</strong> that helps teams understand, modernize, and manage complex codebases. It automatically analyzes your source code to build a <strong>knowledge base</strong> that reveals architecture, dependencies, and hidden logic — making it easier to plan refactors or migrations.</p><h3>Main Features</h3><ul><li><strong>Analyze:</strong> Uses AI-driven static analysis to uncover architecture, design patterns, and hidden relationships in your code.</li><li><strong>Inventory:</strong> Automatically generates a living map of all programs, modules, and dependencies with human-readable explanations.</li><li><strong>Assess:</strong> Identifies critical logic and dependencies within legacy systems to simplify modernization efforts.</li><li><strong>Spec:</strong> Transforms analysis insights into actionable specifications, helping teams plan migrations and align around cleaner architecture.</li></ul><h3>Free &amp; Paid Plans</h3><p>Swimm.io offers <strong>custom enterprise plans</strong> and <strong>team subscriptions</strong> based on project size and analysis depth — designed for organizations managing large, complex codebases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ogck5z2G_5lHuSdnPgc2lg.png" /><figcaption>Swimm Home Page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2bORfkxg1m-u9x2Vrik6Dw.png" /><figcaption>Adding New Repository</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ehpVEsgsWkOKshbv_XAtmA.png" /><figcaption>Selecting the Repository</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xLZZMiDm-dmjI3XDMXb-Ig.png" /><figcaption>Code files to Doc</figcaption></figure><h3>Why These Tools Matter</h3><p><strong>Workik</strong>, <strong>DocuWriter.ai</strong>, <strong>AutoCodeDocs</strong>, and <strong>Swimm.io </strong>are reshaping how developers understand, maintain, and share their codebases.<br> They transform raw logic into organized, easy-to-read documentation — improving collaboration, onboarding, and long-term maintainability.</p><ul><li><strong>Workik</strong> stands out as a <strong>multi-purpose AI workspace</strong>, blending coding, documentation, learning, and automation in one environment.</li><li><strong>DocuWriter.ai</strong> shines as a <strong>specialized documentation engine</strong>, complete with UML generation, test creation, and optimization tools.</li><li><strong>AutoCodeDocs</strong> excels at <strong>simplicity and speed</strong>, providing instant, high-quality documentation without complex integrations or setup.</li><li><strong>Swimm.io</strong> focuses on <strong>AI-powered static analysis</strong>, building a knowledge base from your code to reveal architecture, dependencies, and hidden logic — ideal for understanding and modernizing large or legacy systems.</li></ul><p>Together, these tools represent a future where AI doesn’t replace developers — it <strong>empowers them to focus on creativity, architecture, and problem-solving</strong>.</p><h3>Final Thoughts</h3><p>AI documentation tools are no longer optional — they’re essential for modern development teams.<br><strong>Workik</strong> delivers an all-in-one AI workspace, <strong>DocuWriter.ai</strong> brings advanced automation and structure, <strong>AutoCodeDocs</strong> offers effortless and fast documentation generation, and <strong>Swimm.io</strong> enables deep system understanding through static analysis and architectural insights.</p><p>Whether you want an AI that writes, learns, and automates, or one that documents, analyzes, and modernizes — these platforms show how <strong>AI is transforming software development into a smarter, faster, and more collaborative process than ever before.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ce34e5b109f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[جلب بيانات مواعيد الصلاة في تطبيق أندرويد باستخدام Retrofit]]></title>
            <link>https://medium.com/@etharalrehaili/%D8%AC%D9%84%D8%A8-%D8%A8%D9%8A%D8%A7%D9%86%D8%A7%D8%AA-%D9%85%D9%88%D8%A7%D8%B9%D9%8A%D8%AF-%D8%A7%D9%84%D8%B5%D9%84%D8%A7%D8%A9-%D9%81%D9%8A-%D8%AA%D8%B7%D8%A8%D9%8A%D9%82-%D8%A3%D9%86%D8%AF%D8%B1%D9%88%D9%8A%D8%AF-%D8%A8%D8%A7%D8%B3%D8%AA%D8%AE%D8%AF%D8%A7%D9%85-retrofit-52974681dc71?source=rss-9690d1b2f21c------2</link>
            <guid isPermaLink="false">https://medium.com/p/52974681dc71</guid>
            <category><![CDATA[retrofit]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Ethar]]></dc:creator>
            <pubDate>Tue, 17 Jun 2025 01:08:22 GMT</pubDate>
            <atom:updated>2025-06-17T01:27:58.863Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*xQG4PhAVtwR7XS8_YCxalA.gif" /></figure><p>تعتمد العديد من تطبيقات الأندرويد الحديثة بشكل كبير على التعامل مع واجهات برمجة التطبيقات لجلب البيانات من الخوادم (السيرفرات) أو إرسالها إليها. ومن بين أشهر وأقوى الطرق لجلب هذه البيانات ومعالجتها تأتي مكتبة</p><p><strong>Retrofit</strong></p><p>التي تُعد أداة فعّالة ومفتوحة المصدر وتسهل التعامل مع RESTful APIs</p><p>تختصر الوقت وتقلل من الأخطاء، فهي تقوم بتحويل البيانات القادمة من الخادم إلى كائنات جاهزة للاستخدام داخل التطبيق، مما يسرّع عملية التطوير ويجعلها أكثر دقة</p><p>في هذه المقالة، سنتعلم كيف نستخدمها بلغة كوتلن لجلب البيانات خطوة بخطوة</p><p>كمثال تطبيقي عملي، سنقوم ببناء <strong>تطبيق بسيط</strong> <strong>يعرض مواعيد الصلاة</strong>، حيث يتمكّن المستخدم من اختيار المدينة التي يرغب بها، ليتم عرض مواعيد الصلاة الخاصة بها، معتمدين في ذلك على بيانات موقع</p><p><strong>Aladhan.com</strong></p><blockquote>مفهوم API ( Application Programming Interface )</blockquote><p>هو عبارة عن مجموعة من القواعد والتعليمات التي تتيح لتطبيقٍ ما التواصل مع تطبيق أو خدمة أخرى، يُمكن تشبيهه بجسر يربط بين نظامين مختلفين، حيث يُمكّن أحدهما من طلب معلومات أو أداء عمليات لدى الآخر</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*aDmpPhwT-tFJ5M1vYzdGXg.png" /></figure><blockquote>مفهوم Retrofit</blockquote><p>،وهي مكتبة مفتوحة المصدر تساعدنا في تسهيل عملية الإتصال بالخدمات الخارجية والتعامل مع البيانات بطريقة مرنة وسهلة</p><blockquote>لماذا نستخدم Retrofit ?</blockquote><ul><li><strong>تحويل البيانات تلقائيًا</strong><br> تستخدم مكتبات مثل Gson أو Moshi لتحويل بيانات JSON إلى كائنات Kotlin أو Java</li><li><strong>دعم جميع أنواع الطلبات</strong><br>توفر المكتبة إمكانية تنفيذ جميع أنواع طلبات HTTP ( GET , POST , PUT , DELETE ) بسهولة</li><li><strong>التوافق مع Kotlin Coroutines</strong><br>تتيح لك العمل بسلاسة مع Coroutines، مما يسهل إدارة العمليات غير المتزامنة ويزيد من سرعة التطبيق واستجابته</li></ul><h4>جلب وعرض البيانات باستخدام Retrofit</h4><blockquote>إنشاء مشروع جديد في Android Studio</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bqU26WTpFTAygrb2IocgVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*40bEUdiF2mbzZIu2VSfZxQ.png" /></figure><blockquote><em>إضافة Dependencies</em></blockquote><p>نقوم بإضافة المكتبات التالية في ملف build.gradle (Module: app)</p><pre>implementation(&quot;com.squareup.retrofit2:retrofit:2.9.0&quot;)<br>implementation(&quot;com.squareup.retrofit2:converter-gson:2.9.0&quot;)</pre><p>نحتاج إلى اتصال بالإنترنت لكي نستطيع جلب البيانات، لذا نضيف التصريح التالي في ملف<br>AndroidManifest.xml</p><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;</pre><ul><li>يمكننا التحقق من الاستجابة باستخدام الأداة المتوفرة على موقع<br><strong>Aladhan.com</strong></li><li>الرابط الذي نستخدمه للاختبار هو<br> <a href="https://api.aladhan.com/v1/timingsByCity/11-06-2025?city=Riyadh&amp;country=Saudi+Arabia">https://api.aladhan.com/v1/timingsByCity/11-06-2025?city=Riyadh&amp;country=Saudi+Arabia</a></li></ul><p>نموذج البيانات الذي تقوم واجهة برمجة التطبيقات بإرجاعه عند اختيار مدينة الرياض</p><pre>{<br>  &quot;code&quot;: 200,<br>  &quot;status&quot;: &quot;OK&quot;,<br>  &quot;data&quot;: {<br>    &quot;timings&quot;: {<br>      &quot;Fajr&quot;: &quot;03:32&quot;,<br>      &quot;Sunrise&quot;: &quot;05:03&quot;,<br>      &quot;Dhuhr&quot;: &quot;11:52&quot;,<br>      &quot;Asr&quot;: &quot;15:14&quot;,<br>      &quot;Sunset&quot;: &quot;18:42&quot;,<br>      &quot;Maghrib&quot;: &quot;18:42&quot;,<br>      &quot;Isha&quot;: &quot;20:12&quot;,<br>      &quot;Imsak&quot;: &quot;03:22&quot;,<br>      &quot;Midnight&quot;: &quot;23:52&quot;,<br>      &quot;Firstthird&quot;: &quot;22:09&quot;,<br>      &quot;Lastthird&quot;: &quot;01:36&quot;<br>    },<br>    &quot;date&quot;: {<br>      &quot;readable&quot;: &quot;11 Jun 2025&quot;,<br>      &quot;timestamp&quot;: &quot;1749614400&quot;,<br>      &quot;hijri&quot;: {<br>        &quot;date&quot;: &quot;15-12-1446&quot;,<br>        &quot;format&quot;: &quot;DD-MM-YYYY&quot;,<br>        &quot;day&quot;: &quot;15&quot;,<br>        &quot;weekday&quot;: {<br>          &quot;en&quot;: &quot;Al Arba&#39;a&quot;,<br>          &quot;ar&quot;: &quot;الأربعاء&quot;<br>        },<br>        &quot;month&quot;: {<br>          &quot;number&quot;: 12,<br>          &quot;en&quot;: &quot;Dhū al-Ḥijjah&quot;,<br>          &quot;ar&quot;: &quot;ذو الحجة&quot;,<br>          &quot;days&quot;: 29<br>        },<br>        &quot;year&quot;: &quot;1446&quot;,<br>        &quot;designation&quot;: {<br>          &quot;abbreviated&quot;: &quot;AH&quot;,<br>          &quot;expanded&quot;: &quot;Anno Hegirae&quot;<br>        },<br>        &quot;holidays&quot;: [],<br>        &quot;adjustedHolidays&quot;: [],<br>        &quot;method&quot;: &quot;HJCoSA&quot;<br>      },<br>      &quot;gregorian&quot;: {<br>        &quot;date&quot;: &quot;11-06-2025&quot;,<br>        &quot;format&quot;: &quot;DD-MM-YYYY&quot;,<br>        &quot;day&quot;: &quot;11&quot;,<br>        &quot;weekday&quot;: {<br>          &quot;en&quot;: &quot;Wednesday&quot;<br>        },<br>        &quot;month&quot;: {<br>          &quot;number&quot;: 6,<br>          &quot;en&quot;: &quot;June&quot;<br>        },<br>        &quot;year&quot;: &quot;2025&quot;,<br>        &quot;designation&quot;: {<br>          &quot;abbreviated&quot;: &quot;AD&quot;,<br>          &quot;expanded&quot;: &quot;Anno Domini&quot;<br>        },<br>        &quot;lunarSighting&quot;: false<br>      }<br>    },<br>    &quot;meta&quot;: {<br>      &quot;latitude&quot;: 8.8888888,<br>      &quot;longitude&quot;: 7.7777777,<br>      &quot;timezone&quot;: &quot;Asia/Riyadh&quot;,<br>      &quot;method&quot;: {<br>        &quot;id&quot;: 4,<br>        &quot;name&quot;: &quot;جامعة أم القرى، مكة&quot;,<br>        &quot;params&quot;: {<br>          &quot;Fajr&quot;: 18.5,<br>          &quot;Isha&quot;: &quot;90 min&quot;<br>        },<br>        &quot;location&quot;: {<br>          &quot;latitude&quot;: 21.3890824,<br>          &quot;longitude&quot;: 39.8579118<br>        }<br>      },<br>      &quot;latitudeAdjustmentMethod&quot;: &quot;ANGLE_BASED&quot;,<br>      &quot;midnightMode&quot;: &quot;STANDARD&quot;,<br>      &quot;school&quot;: &quot;STANDARD&quot;,<br>      &quot;offset&quot;: {<br>        &quot;Imsak&quot;: 0,<br>        &quot;Fajr&quot;: 0,<br>        &quot;Sunrise&quot;: 0,<br>        &quot;Dhuhr&quot;: 0,<br>        &quot;Asr&quot;: 0,<br>        &quot;Maghrib&quot;: 0,<br>        &quot;Sunset&quot;: 0,<br>        &quot;Isha&quot;: 0,<br>        &quot;Midnight&quot;: 0<br>      }<br>    }<br>  }<br>}</pre><blockquote>إنشاء موديلات البيانات (Data Models)</blockquote><p>لكي نتمكن من استقبال البيانات الواردة من واجهة برمجة التطبيقات وتحويلها إلى كائنات يسهل التعامل معها في لغة كوتلن، لا بد من إنشاء نماذج تمثل هيكل البيانات<br>ونظراً لأن الخدمة تُرجع كائناً يحتوي على مواعيد الصلاة والتاريخ، فسوف نعرف نماذج مبسطة على النحو التالي</p><pre>data class Date(<br>    val readable: String<br>)</pre><pre>data class Timings(<br>    val Fajr: String,<br>    val Sunrise: String,<br>    val Dhuhr: String,<br>    val Asr: String,<br>    val Maghrib: String,<br>    val Isha: String<br>)</pre><pre>data class PrayerTime(<br>    val timings: Timings,<br>    val date: Date<br>)</pre><pre>data class PrayerTimesResponse(<br>    val data: PrayerTime<br>)</pre><ul><li><strong>Date</strong>: يمثل التاريخ بشكل مقروء</li><li><strong>Timings</strong>: يحتوي على أوقات الصلوات المختلفة</li><li><strong>PrayerTime</strong>: يجمع بين التوقيتات والتاريخ</li><li><strong>PrayerTimesResponse</strong>: يمثل الجسم الكامل للاستجابة من واجهة برمجة التطبيقات، حيث يحتوي على بيانات الصلاة</li></ul><blockquote>إنشاء واجهة برمجة التطبيقات (ApiService)</blockquote><p>نقوم بإنشاء واجهة لبرمجة التطبيقات تُستخدم مع المكتبة لإرسال الطلبات واستقبال البيانات</p><pre>interface ApiService {<br>    @GET(&quot;v1/timingsByCity&quot;)<br>    suspend fun getPrayerTimes(<br>        @Query(&quot;city&quot;) city: String,<br>        @Query(&quot;country&quot;) country: String<br>    ): PrayerTimesResponse<br>}</pre><p>نقوم بتعريف واجهة بإسم interface ApiService<br>تحتوي الواجهة على دالة غير متزامنة باستخدام كلمة suspend<br>الدالة ترسل طلبًا لجلب مواعيد الصلاة بإستخدام @GET(&quot;v1/timingsByCity&quot;)<br>تأخذ الدالة اسم المدينة واسم الدولة كمعطيات باستخدام @Query</p><blockquote>إدارة الاتصال بواجهة برمجة التطبيقات (RetrofitInstance)</blockquote><p>لتسهيل استخدام المكتبة داخل التطبيق، ننشئ كائنًا وحيدًا يحتوي على إعدادات الاتصال</p><pre>object RetrofitInstance {<br>    val api: ApiService by lazy {<br>        Retrofit.Builder()<br>            .baseUrl(&quot;https://api.aladhan.com/&quot;)<br>            .addConverterFactory(GsonConverterFactory.create())<br>            .build()<br>            .create(ApiService::class.java)<br>    }<br>}</pre><p>نحدد عنوان السيرفر الأساسي عبر .baseUrl()</p><blockquote>إنشاء ViewModel</blockquote><pre>class PrayerTimeViewModel : ViewModel() {<br>var prayerTimes by mutableStateOf&lt;PrayerTimesResponse?&gt;(null)<br>        private set<br>    fun fetchPrayerTimes(city: String, country: String) {<br>        viewModelScope.launch {<br>            try {<br>                prayerTimes = RetrofitInstance.api.getPrayerTimes(<br>                    city = city,<br>                    country = country<br>                )<br>            } catch (e: Exception) {<br>                e.printStackTrace()<br>            }<br>        }<br>    }<br>}</pre><p><strong>ViewModel</strong>: هو عبارة عن طبقة من طبقات MVVM</p><p>يعمل كـ وسيط بين واجهة المستخدم والبيانات</p><p>تحتوي على دوال <strong>تُدير حالة البيانات</strong> و<strong>تجهيزها للعرض</strong> و<strong>تُحدث واجهة المستخدم</strong> عند تغيّر البيانات</p><p>prayerTimes: متغير نستخدمه لتخزين البيانات</p><p>fetchPrayerTimes(): دالة مسؤولة عن تنفيذ الطلب</p><blockquote>عرض البيانات في واجهة المستخدم باستخدام Jetpack Compose</blockquote><pre>@Composable<br>fun PrayerTimeScreen(viewModel: PrayerTimeViewModel) {<br>    var selectedCity by remember { mutableStateOf(&quot;المدينة المنورة&quot;) }<br>    val country = &quot;Saudi Arabia&quot;<br>// جلب أوقات الصلاة عند تغيير المدينة<br>    LaunchedEffect(selectedCity) {<br>        viewModel.fetchPrayerTimes(selectedCity, country)<br>    }<br>    val prayerTimesResponse = viewModel.prayerTimes<br>    CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {<br>        Column(modifier = Modifier.padding(16.dp)) {<br>            Text(text = &quot;اختر المدينة&quot;, style = MaterialTheme.typography.titleMedium)<br>            Spacer(modifier = Modifier.height(8.dp))<br>            val cities = listOf(&quot;المدينة المنورة&quot;, &quot;الرياض&quot;, &quot;جدة&quot;)<br>            cities.forEach { city -&gt;<br>                Row(<br>                    verticalAlignment = Alignment.CenterVertically,<br>                    modifier = Modifier<br>                        .fillMaxWidth()<br>                        .padding(vertical = 4.dp)<br>                ) {<br>                    RadioButton(<br>                        selected = (city == selectedCity),<br>                        onClick = { selectedCity = city }<br>                    )<br>                    Spacer(modifier = Modifier.width(8.dp))<br>                    Text(text = city)<br>                }<br>            }<br>            Spacer(modifier = Modifier.height(16.dp))<br>            if (prayerTimesResponse == null) {<br>                Box(<br>                    modifier = Modifier.fillMaxWidth(),<br>                    contentAlignment = Alignment.Center<br>                ) {<br>                    CircularProgressIndicator()<br>                }<br>            } else {<br>                val timings = prayerTimesResponse.data.timings<br>                val date = prayerTimesResponse.data.date.readable<br>                Text(<br>                    text = &quot;أوقات الصلاة في $selectedCity ليوم $date&quot;,<br>                    style = MaterialTheme.typography.bodyMedium,<br>                    modifier = Modifier.padding(bottom = 16.dp)<br>                )<br>                val prayers = listOf(<br>                    &quot;الفجر&quot; to timings.Fajr,<br>                    &quot;الشروق&quot; to timings.Sunrise,<br>                    &quot;الظهر&quot; to timings.Dhuhr,<br>                    &quot;العصر&quot; to timings.Asr,<br>                    &quot;المغرب&quot; to timings.Maghrib,<br>                    &quot;العشاء&quot; to timings.Isha<br>                )<br>                LazyColumn {<br>                    items(prayers) { (name, time) -&gt;<br>                        Row(<br>                            modifier = Modifier<br>                                .fillMaxWidth()<br>                                .padding(vertical = 8.dp),<br>                            horizontalArrangement = Arrangement.SpaceBetween<br>                        ) {<br>                            Text(text = name, style = MaterialTheme.typography.bodyMedium)<br>                            Text(text = time, style = MaterialTheme.typography.bodyMedium)<br>                        }<br>                        HorizontalDivider(<br>                            modifier = Modifier.fillMaxWidth(),<br>                            thickness = 1.dp,<br>                            color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.12f)<br>                        )<br>                    }<br>                }<br>            }<br>        }<br>    }<br>}</pre><blockquote>MainActivity</blockquote><pre>class MainActivity : ComponentActivity() {<br>private val viewModel: PrayerTimeViewModel by viewModels()<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        setContent {<br>            PrayerTimeScreen(viewModel = viewModel)<br>        }<br>    }<br>}</pre><blockquote>النتيجة النهائية</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*uJPKGxO1zqinZd5rkzTiRA.png" /><figcaption>اختيار المدينة وعرض مواعيد الصلاة الخاصة بها</figcaption></figure><blockquote>الخاتمة</blockquote><p>في ختام هذا المشروع، تعلّمنا كيفية <strong>جلب وعرض البيانات</strong> باستخدام مكتبة <strong>Retrofit</strong></p><p>إذا وجدت هذه المقالة مفيدة لا تنسى النقر على 👏 ومتابعتي لمزيد من المقالات حول تطوير تطبيقات أندرويد</p><p>تابعني على</p><p><a href="https://www.linkedin.com/in/ethar-alrehaili/">LinkedIn</a>، <a href="https://github.com/etharalrehaili">GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52974681dc71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[إنشاء قاعدة بيانات محلية في اندرويد باستخدام Room]]></title>
            <link>https://medium.com/@etharalrehaili/%D8%A5%D9%86%D8%B4%D8%A7%D8%A1-%D9%82%D8%A7%D8%B9%D8%AF%D8%A9-%D8%A8%D9%8A%D8%A7%D9%86%D8%A7%D8%AA-%D9%85%D8%AD%D9%84%D9%8A%D8%A9-%D9%81%D9%8A-%D8%A7%D9%86%D8%AF%D8%B1%D9%88%D9%8A%D8%AF-%D8%A8%D8%A7%D8%B3%D8%AA%D8%AE%D8%AF%D8%A7%D9%85-room-26f66f0b617a?source=rss-9690d1b2f21c------2</link>
            <guid isPermaLink="false">https://medium.com/p/26f66f0b617a</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[sqlite]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[room]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Ethar]]></dc:creator>
            <pubDate>Wed, 11 Jun 2025 22:29:50 GMT</pubDate>
            <atom:updated>2025-06-12T03:29:56.617Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*xQG4PhAVtwR7XS8_YCxalA.gif" /></figure><p>في عالم تطبيقات الهواتف الذكية، تعتبر <strong>إدارة البيانات المحلية</strong> من أهم الجوانب التي تؤثر على تجربة المستخدم وكفاءة التطبيق. عند تطوير تطبيقات أندرويد، كثيرًا ما نحتاج إلى حفظ البيانات على الجهاز نفسه لضمان توفرها في جميع الأوقات، حتى في حال إنقطاع الاتصال بالإنترنت</p><p>في هذه المقالة، سنتعرف على كيفية استخدام <strong>قاعدة البيانات المحلية</strong> في تطبيقات أندرويد بإستخدام مكتبة <strong>Room</strong></p><p>مع التركيز على المفاهيم الأساسية التالية</p><ul><li>Entity</li><li>DAO (Data Access Object)</li><li>Database</li><li>عمليات CRUD (إضافة، قراءة، تحديث، حذف)</li></ul><p>ولتبسيط هذه المفاهيم، سنقوم بتطبيقها عمليًا من خلال بناء مثال تطبيقي بسيط يتمثل في <strong>تطبيق مهام </strong>حيث يمكن للمستخدم إضافة مهام، تعديلها، حذفها، وتحديث حالة الإنجاز، مع تخزين هذه البيانات محليًا داخل الجهاز باستخدام مكتبة Room</p><blockquote>مفهوم قاعدة البيانات SQLite</blockquote><p>هو عبارة عن محرك قواعد بيانات خفيف ومدمج يستخدمه مطورو التطبيقات لحفظ البيانات بشكل محلي داخل تطبيقات أندرويد. وهو نظام إدارة قواعد بيانات علائقية بدون خادم ولا يتطلب أي تثبيت أو تكوين إضافي، مما يجعله سهل الاستخدام وفعالًا</p><blockquote>مفهوم قاعدة البيانات Room</blockquote><p>هي مكتبة قواعد بيانات عالية المستوى وموجهة للكائنات مخصصة لتطبيقات أندرويد، وهي مبنية فوق SQLite وتوفر طبقة تجريدية فوقها<br>مما يجعل التعامل مع قواعد البيانات في تطبيقات أندرويد أسهل وأكثر تنظيمًا</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*jT94pc71uD_A2TPN_E2ulg.png" /></figure><h3>إستخدام قاعدة البيانات Room</h3><blockquote>إنشاء مشروع جديد في Android Studio</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QcYryemxw_hV3CvqiMahrA.png" /><figcaption>مشروع جديد</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jWGuVGkLmzShzHhEupZh0g.png" /><figcaption>تسمية المشروع</figcaption></figure><blockquote>إضافة Dependencies</blockquote><p>نقوم بإضافة المكتبات التالية في ملف build.gradle (Module: app)</p><pre>implementation &quot;androidx.room:room-runtime:2.x.x&quot;<br>kapt &quot;androidx.room:room-compiler:2.x.x&quot;</pre><blockquote>إنشاء Entity</blockquote><pre>@Entity(tableName = &quot;todo&quot;)<br>data class Todo(<br>    @PrimaryKey(autoGenerate = true) val id: Int = 0,<br>    val title: String,<br>    val description: String?,<br>    val isDone: Boolean = false,<br>    val date: Long = System.currentTimeMillis()<br>)</pre><p><strong>Entity</strong>: هو تمثيل البيانات التي سنتعامل معها داخل التطبيق، مثل الجدول</p><p>نحتاج أن نحدد الخصائص التي تمثل أعمدة الجدول، مثل: العنوان، الوصف، حالة الإنجاز، والتاريخ</p><ul><li>@PrimaryKey تعني أن هذه الخاصية هي المفتاح الأساسي للجدول ولا يمكن تكراره</li><li>autoGenerate = true تعني أن قاعدة البيانات ستقوم بتوليد قيمة فريدة تلقائيًا عند إضافة كل سجل جديد</li></ul><blockquote>إنشاء DAO (Data Access Object)</blockquote><pre>@Dao<br>interface TodoDao {<br><br>    @Insert<br>    suspend fun insertTodo(todo: Todo)<br><br>    @Update<br>    suspend fun updateTodo(todo: Todo)<br><br>    @Delete<br>    suspend fun deleteTodo(todo: Todo)<br><br>    @Query(&quot;UPDATE todo SET isDone = :isDone WHERE id = :id&quot;)<br>    suspend fun setTodoDone(id: Int, isDone: Boolean)<br><br>    @Query(&quot;SELECT * FROM todo ORDER BY date DESC&quot;)<br>    suspend fun getAllTodos(): List&lt;Todo&gt;<br><br>}</pre><p><strong>DAO (Data Access Object)</strong>: هو عبارة عن طبقة مسؤولة عن التعامل مع قاعدة البيانات، حيث يحتوي على الدوال أو الوظائف المسؤولة عن تنفيذ عمليات الإدخال، التحديث، الحذف، والاستعلام عن البيانات</p><ul><li>@Insert: تضيف مهمة جديدة إلى قاعدة البيانات</li><li>@Update: تقوم بتحديث بيانات موجودة</li><li>@Delete: تحذف مهمة من قاعدة البيانات</li><li>@Query تُستخدم لكتابة إستعلامات مخصصة تُنفَّذ مباشرةً على قاعدة البيانات، وهي تتيح لك تنفيذ عمليات معقدة أو مخصصة مثل الإستعلام، التصفية، الترتيب، وغيرها. بما يمنحك مرونة أكبر في التعامل مع البيانات</li></ul><blockquote>إعداد قاعدة البيانات (Database)</blockquote><pre>@Database(<br>    entities = [Todo::class],<br>    version = 1<br>)<br>abstract class TodoDatabase : RoomDatabase() {<br><br>    abstract fun todoDao(): TodoDao<br><br>    companion object {<br>        @Volatile<br>        private var INSTANCE: TodoDatabase? = null<br><br>        fun getDatabase(context: Context): TodoDatabase {<br>            return INSTANCE ?: synchronized(this) {<br>                val instance = Room.databaseBuilder(<br>                    context.applicationContext,<br>                    TodoDatabase::class.java,<br>                    &quot;todo_database&quot;<br>                ).build()<br>                INSTANCE = instance<br>                instance<br>            }<br>        }<br>    }<br>}</pre><p><strong>Database</strong>: هي عبارة عن المكان الذي تُخزن فيه جميع البيانات بشكل دائم ومنظم، وتُستخدم لإدارة البيانات بطريقة سهلة وفعالة</p><ul><li>@Databaseتعلن أن هذا الكلاس يمثل قاعدة بيانات، وتحدد الجداول التي يحتويها</li></ul><blockquote>إنشاء Repository</blockquote><pre>class TodoRepository(private val dao: TodoDao) {<br><br>    suspend fun addTodo(todo: Todo) = dao.insertTodo(todo)<br><br>    suspend fun updateTodo(todo: Todo) = dao.updateTodo(todo)<br><br>    suspend fun deleteTodo(todo: Todo) = dao.deleteTodo(todo)<br><br>    suspend fun setTodoDone(id: Int, isDone: Boolean) = dao.setTodoDone(id, isDone)<br><br>    suspend fun getAllTodos(): List&lt;Todo&gt; = dao.getAllTodos()<br>}</pre><p><strong>Repository</strong>: هو عبارة عن طبقة وسيطة مسؤولة عن إدارة الوصول إلى البيانات، حيث تُجَمِّع وتُنسِّق بين مصادر البيانات المختلفة وتوفر واجهة موحدة للتعامل مع البيانات داخل التطبيق</p><blockquote>إنشاء ViewModel</blockquote><pre>class TodoViewModel(private val repository: TodoRepository) : ViewModel() {<br><br>    private val _todos = MutableStateFlow&lt;List&lt;Todo&gt;&gt;(emptyList())<br>    val todos = _todos.asStateFlow()<br><br>    fun loadTodos() {<br>        viewModelScope.launch {<br>            _todos.value = repository.getAllTodos()<br>        }<br>    }<br><br>    fun addTodo(todo: Todo) {<br>        viewModelScope.launch {<br>            repository.addTodo(todo)<br>            loadTodos()<br>        }<br>    }<br><br>    fun updateTodo(todo: Todo) {<br>        viewModelScope.launch {<br>            repository.updateTodo(todo)<br>            loadTodos()<br>        }<br>    }<br><br>    fun deleteTodo(todo: Todo) {<br>        viewModelScope.launch {<br>            repository.deleteTodo(todo)<br>            loadTodos()<br>        }<br>    }<br><br>    fun markDone(id: Int, isDone: Boolean) {<br>        viewModelScope.launch {<br>            repository.setTodoDone(id, isDone)<br>            loadTodos()<br>        }<br>    }<br><br>}</pre><p><strong>ViewModel</strong>: هو عبارة عن طبقة من طبقات MVVM</p><p>يعمل كـ وسيط بين واجهة المستخدم والبيانات</p><p>تحتوي على دوال <strong>تُدير حالة البيانات</strong> و<strong>تجهيزها للعرض</strong> و<strong>تُحدث واجهة المستخدم</strong> عند تغيّر البيانات</p><blockquote>إنشاء واجهة المستخدم باستخدام Jetpack Compose</blockquote><pre>@Composable<br>fun TodoForm(<br>    viewModel: TodoViewModel,<br>    editingTodo: Todo? = null,<br>    onSaveComplete: () -&gt; Unit = {}<br>) {<br>    var title by remember { mutableStateOf(editingTodo?.title ?: &quot;&quot;) }<br>    var description by remember { mutableStateOf(editingTodo?.description ?: &quot;&quot;) }<br><br>    val isEditing = editingTodo != null<br><br>    LaunchedEffect(editingTodo) {<br>        title = editingTodo?.title ?: &quot;&quot;<br>        description = editingTodo?.description ?: &quot;&quot;<br>    }<br><br>    Column {<br>        OutlinedTextField(<br>            value = title,<br>            onValueChange = { title = it },<br>            label = { Text(&quot;العنوان&quot;) },<br>            modifier = Modifier.fillMaxWidth()<br>        )<br><br>        Spacer(modifier = Modifier.height(8.dp))<br><br>        OutlinedTextField(<br>            value = description,<br>            onValueChange = { description = it },<br>            label = { Text(&quot;الوصف&quot;) },<br>            modifier = Modifier.fillMaxWidth()<br>        )<br><br>        Spacer(modifier = Modifier.height(8.dp))<br><br>        Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {<br>            Button(onClick = {<br>                if (isEditing) {<br>                    viewModel.updateTodo(editingTodo.copy(title = title, description = description))<br>                } else {<br>                    viewModel.addTodo(Todo(title = title, description = description))<br>                }<br>                onSaveComplete()<br>            }) {<br>                Text(&quot;حفظ&quot;)<br>            }<br><br>            if (isEditing) {<br>                Button(<br>                    onClick = {<br>                        viewModel.deleteTodo(editingTodo)<br>                        onSaveComplete()<br>                    },<br>                    colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.error)<br>                ) {<br>                    Text(&quot;حذف&quot;)<br>                }<br>            }<br>        }<br>    }<br>}</pre><pre>@Composable<br>fun TodoRow(<br>    todo: Todo,<br>    onClick: (Todo) -&gt; Unit,<br>    onToggleDone: () -&gt; Unit<br>) {<br>    val formattedDate = remember(todo.date) {<br>        SimpleDateFormat(&quot;yyyy-MM-dd HH:mm&quot;, Locale.getDefault()).format(Date(todo.date))<br>    }<br><br>    Row(<br>        modifier = Modifier<br>            .fillMaxWidth()<br>            .clickable { onClick(todo) }<br>            .padding(vertical = 8.dp),<br>        verticalAlignment = Alignment.CenterVertically<br>    ) {<br>        Checkbox(<br>            checked = todo.isDone,<br>            onCheckedChange = { onToggleDone() }<br>        )<br><br>        Spacer(modifier = Modifier.width(8.dp))<br><br>        Column {<br>            Text(<br>                text = todo.title,<br>                style = MaterialTheme.typography.bodyLarge,<br>                textDecoration = if (todo.isDone) TextDecoration.LineThrough else null<br>            )<br>            if (!todo.description.isNullOrBlank()) {<br>                Text(<br>                    text = todo.description,<br>                    style = MaterialTheme.typography.bodySmall<br>                )<br>            }<br><br>            Text(<br>                text = &quot;تاريخ الإنشاء: $formattedDate&quot;,<br>                style = MaterialTheme.typography.labelSmall,<br>                color = MaterialTheme.colorScheme.onSurfaceVariant<br>            )<br>        }<br>    }<br>}</pre><pre>@Composable<br>fun TodoScreen(viewModel: TodoViewModel) {<br>    val todos by viewModel.todos.collectAsState()<br>    var selectedTodo by remember { mutableStateOf&lt;Todo?&gt;(null) }<br><br>    LaunchedEffect(Unit) {<br>        viewModel.loadTodos()<br>    }<br><br>    CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {<br>        Column(modifier = Modifier.padding(16.dp)) {<br>            TodoForm(<br>                viewModel = viewModel,<br>                editingTodo = selectedTodo,<br>                onSaveComplete = {<br>                    selectedTodo = null<br>                }<br>            )<br><br>            Spacer(modifier = Modifier.height(24.dp))<br><br>            Text(&quot;قائمة المهام&quot;, style = MaterialTheme.typography.titleMedium)<br>            Spacer(modifier = Modifier.height(8.dp))<br><br>            LazyColumn {<br>                items(todos) { todo -&gt;<br>                    TodoRow(<br>                        todo = todo,<br>                        onClick = { selectedTodo = it },<br>                        onToggleDone = { viewModel.markDone(todo.id, !todo.isDone) }<br>                    )<br>                }<br>            }<br>        }<br>    }<br>}</pre><blockquote>MainActivity</blockquote><pre>class MainActivity : ComponentActivity() {<br><br>    private lateinit var viewModel: TodoViewModel<br><br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br><br>        // Initialize database, repository and ViewModel<br>        val database = TodoDatabase.getDatabase(this)<br>        val repository = TodoRepository(database.todoDao())<br>        viewModel = TodoViewModel(repository)<br><br>        setContent {<br>            MaterialTheme {<br>                TodoScreen(viewModel = viewModel)<br>            }<br>        }<br>    }<br>}</pre><blockquote>النتيجة النهائية</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*ADjPbsjo0Y9f3e7sJzp1ww.png" /><figcaption>التطبيق</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*jCBgvCBlLiaL_2YwHJ5fQw.png" /><figcaption>تعديل أو حذف المهام</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RtjA33TeEdRpPZA1JSLLjg.png" /><figcaption>App Inspection لعرض البيانات المحلية في اندرويد ستوديو</figcaption></figure><blockquote>الخاتمة</blockquote><p>بهذا المشروع تعلمنا كيفية إنشاء <strong>قاعدة بيانات محلية</strong> داخل التطبيق باستخدام مكتبة <strong>Room</strong></p><p>إذا وجدت هذه المقالة مفيدة لا تنسى النقر على 👏 ومتابعتي لمزيد من المقالات حول تطوير تطبيقات أندرويد</p><p>تابعني على</p><p><a href="https://www.linkedin.com/in/ethar-alrehaili/">LinkedIn</a>، <a href="https://github.com/etharalrehaili">GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26f66f0b617a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>