a complex case with react-router may better solved with "state based router" - angular-ui-router

I'm looking for a better solution for my special menu case.
Here's the case:
Let's say we have 6 pages:
A
B
C
C1
C2
C3
Here's how the menu changed when we go from page:C to page:C1
The Design is that C1/2/3 are all submenus, when we access these pages, the menu should display C1/2/3 with a return button.
Here's the requirements:
the Menu component should be reusable
the Menu component should automatic determine to show submenus(C1/2/3) with a return button or just ordinary menus.
then I wrote a Menu component...
It's usage:
/* Routes */
<Route path="A" ... />
<Route path="B" ... />
<Route path="C" ... />
<Route path="C/:Id">
<Route path="C1" />
<Route path="C2" />
<Route path="C3" />
</Route>
/* Menus */
<Menu {...this.props}>
<Item path="A">A</Item>
<Item path="B">B</Item>
<Item path="C">C</Item>
<SubMenu path="C/:Id">
<Item path="C1">C1</Item>
<Item path="C2">C2</Item>
<Item path="C3">C3</Item>
</SubMenu>
<Menu>
I use the "path" to match and highlight Item, this can be done by using react-router's routes props. But it is not done yet, next I need to add links:
/* Menus */
<Menu {...this.props}>
<Item path="A">
<Link to="A">A</Link>
</Item>
<Item path="B">
<Link to="B">B</Link>
</Item>
<Item path="C">
<Link to="C">C</Link>
</Item>
<SubMenu path="C/:Id">
<Item path="C1">
<XLink to="C/:Id/C1">C1</XLink>
</Item>
<Item path="C2">
<XLink to="C/:Id/C2">C2</XLink>
</Item>
<Item path="C3">
<XLink to="C/:Id/C3">C3</XLink>
</Item>
</SubMenu>
<Menu>
Because path "C/:Id" need an id, I need to automatic generate the url.
What I did is creating a XLink component which take routeParams to generate the real url we need link to.
For example, when we access C/00001/C1,we can get the routeParams: {Id: "00001"},and then we click <XLink to="C/:Id/C3">C3</XLink> it will replace :Id with "00001". Btw, XLink should support custom function to manually process the url.
Seems like problem solved but it's not good enough. Any good ideas ?
Since I came from an angular background, I think this case may be better solved by ui-router because it is based on "states", not url. The code may looks like this:
/* Menus */
<Menu {...this.props}>
...
<SubMenu state="C.detail">
<Item state="C.detail.C1">
<Link to="C.detail.C1">C1</Link>
</Item>
<Item state="C.detail.C2">
<Link to="C.detail.C2">C2</Link>
</Item>
<Item state="C.detail.C3">
<Link to="C.detail.C3">C3</Link>
</Item>
</SubMenu>
<Menu>
I don't have to process the route params,and I could use state for both highlight and linking.
I'm quite new to react-router, if I made terrible mistakes, pls tell me.

Related

android:windowBackground property makes background black (Xamarin.Android)

I want to make the following image to be the background for the entire Xamarin.Android application:
I reference the image in Base application theme in styles.xml :
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
.....
<item name="android:windowBackground">#drawable/ic_app_background_image</item>
.....
</style>
The background applies to all the application but the image has dark background:
Also the number 51 has some strange things around it.
When I set the android:background="#drawable/ic_app_background_image" to the most outer LinearLayout of an activity it works fine, it shows the screen like that:
How can I fix the android:windowBackground property setting the background to black issue so I don't have to put android:background="#drawable/ic_app_background_image" in the LinearLayout of every activity?
You can try following method:
1.Create new file name as bg.xml in drawable folder (bg.xml)
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="#color/splash_background"/>
</item>
<item>
<bitmap
android:src="#drawable/splash_logo"
android:tileMode="disabled"
android:gravity="center"/>
</item>
</layer-list>
2.define background color in colors.xml
<color name="window_background">#F5F5F5</color>
<color name="splash_background">#FFFFFF</color>
3.define new style MyTheme.Splash in style.xml and use the bg in item android:windowBackground
<style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/bg</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
4.Usage in Activity
[Activity(Theme = "#style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
// other code
}
Update:
If you want to apply this style to all activities, you can just add the following code to your Base application theme. And we don't need to set for each activity. For example:
<!-- Base application theme. parent="Theme.AppCompat.Light.DarkActionBar" -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowBackground">#drawable/bg</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
The result is:
For more details, you can check: https://learn.microsoft.com/en-us/xamarin/android/user-interface/splash-screen

Icon based Xamarin Drawer Menu

I need to set up my drawer menu to display two icons side by side per row, each icon being a different menu item as opposed to one item per row.
basically it looks like this:
| Home |
| Inventory |
| Work Orders |
I want it to look like this... but with icons instead of words
| Home | Inventory |
| W.O. | Time Clock |
I tried using linear layout, and horizontal alignment with weight, however this didn't work... Here is the current xml:
<?xml version="1.0" encoding="utf-8" ?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_home"
android:title="Home" />
<item
android:id="#+id/nav_inventory"
android:title="Inventory" />
<item
android:id="#+id/nav_item_inventory_worksheet"
android:title="Item Inventory Worksheet" />
<item
android:id="#+id/nav_purchase_order_receiving"
android:title="Purchase Order Receiving" />
<item
android:id="#+id/nav_picklist"
android:title="Picklist" />
<item
android:id="#+id/nav_packing_slip"
android:title="Packing Slips"/>
<item
android:id="#+id/nav_work_order"
android:title="Work Orders"/>
<item
android:id="#+id/nav_timeclock"
android:title="Time Clock"/>
<item
android:id="#+id/nav_settings"
android:title="Settings" />
<item
android:id="#+id/nav_change_division"
android:title="Change Division" />
<item
android:id="#+id/nav_logout"
android:title="Logout"
android:gravity="bottom" />
</group>
</menu>
The answer was to set up a Relative Layout within the NavigationView which can then be customized with axml objects. While the AppMenu page will be hidden behind the Relative Layout setting app:menu="#menu/empty_menu" then having Empty_menu as a blank xml document.
ALSO if you decide you can have a setting to have a text based or icon based menu in this fashion which could easily be setup by setting the relative layout as hidden if the user setting is set this way

How to hide the "Title Bar" using Xamarin

I have 4 different activities on my app, in 2 of them it shows a white Title bar (with activity or package name) above my custom toolbar, but in other 2 this bar is hidden by the custom one.
I want to show only my custom toolbar and hide the default...
this is my "styles.xml" code:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:colorPrimary">#color/primaryColor</item>
<item name="android:colorPrimaryDark">#color/primaryDarkColor</item>
<item name="android:colorAccent">#color/secondaryColor</item>
<item name ="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
</style>
<style name="MyActionBar" parent="#android:style/Theme.Holo.NoActionBar">
<item name="android:background">#color/primaryColor</item>
<item name="android:textColor">#color/primaryTextColor</item>
</style>
</resources>
[Solved]
I just change the class my Activities was inheriting from AppCompatActivity to FragmentActivity (until now I have no issues came from this change)

How to change the Clear Icon in SearchView of Actionbar

I used the appcompat to implemented the actionbar, now I want to change the clear icon. And I have done this:
<item android:id="#+id/action_search_note"
android:title="#string/search_title"
android:orderInCategory="101"
android:icon="#drawable/ic_action_search"
snailnote:showAsAction="collapseActionView|ifRoom"
snailnote:actionViewClass="android.support.v7.widget.SearchView" />
my team:
<item name="searchViewCloseIcon">#drawable/search_clear_normal</item>
I also tried to add
<item name="android:searchViewCloseIcon">#drawable/search_clear_normal</item>
but it is giving an error, and I final removed it.
But it dosen't work, how should I change the clear icon in a right way.
<style name="AppTheme" parent="#style/Theme.Base.AppCompat.Light.DarkActionBar">
<item name="actionBarWidgetTheme">#style/YourActionBarWidget</item>
</style>
<style name="YourActionBarWidget" parent="#style/Theme.AppCompat">
<item name="searchViewCloseIcon">#drawable/xxx</item>
</style>
<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView">
<item name="closeIcon">#drawable/search_clear_normal </item>
</style>

Adding new column in Sales Order View Items in Magento Admin

In the admin interface of Magento I need to modify the tables in the Sales / Order / View order so that it shows, besides the products name, their manufacturer as well.
I'm trying to look for the file to modify to make that happen. I thought I would find a section with all the columns that are displayed in app/code/core/Mage/Sales/Block/Order/Item/Renderer/Default.php but by inspecting it there seem to be no reference to the columns/product attributes.
I also tried to modify
app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml
by changing
<?php echo $this->getColumnHtml($_item, 'name') ?>
into
<?php echo $this->getColumnHtml($_item, 'manufacturer') ?>
but it changed nothing, so I suppose that file is not involved...
Can anybody please point me to the right file to modify?
Thank you!
After quite a lot of browsing through the code and with some help from a collegue, we found out the two file to change for adding a column to such view:
app/design/adminhtml/default/default/template/sales/order/view/items.phtml
for adding the table header
app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml for filling the column with data.
I'm not really experienced with Magento but I guess that, in order to do a "clean job", one should not directly modify those files but override them instead.
EDIT
app/design/adminhtml/default/default/template/downloadable/sales/order/view/items/renderer/downloadable.phtml for filling the column with data for downloadable products.
For adding the table header and it's value add layout sales_order_view.xml in your theme or module with new argument.
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="order_items">
<arguments>
<argument name="columns" xsi:type="array">
<item name="product" xsi:type="string" translate="true">Product</item>
<item name="status" xsi:type="string" translate="true">Item Status</item>
<item name="price-original" xsi:type="string" translate="true">Original Price</item>
<item name="price" xsi:type="string" translate="true">Price</item>
<item name="ordered-qty" xsi:type="string" translate="true">Qty</item>
<item name="subtotal" xsi:type="string" translate="true">Subtotal</item>
<item name="tax-amount" xsi:type="string" translate="true">Tax Amount</item>
<item name="tax-percent" xsi:type="string" translate="true">Tax Percent</item>
<item name="discont" xsi:type="string" translate="true">Discount Amount</item>
<item name="total" xsi:type="string" translate="true">Row Total</item>
<item name="repair" xsi:type="string" translate="true">Repair</item>
</argument>
</arguments>
<block class="Namespace\Module\Block\Adminhtml\DefaultRenderer" as="default" template="Magento_Sales::order/view/items/renderer/default.phtml">
<arguments>
<argument name="columns" xsi:type="array">
<item name="product" xsi:type="string" translate="false">col-product</item>
<item name="status" xsi:type="string" translate="false">col-status</item>
<item name="price-original" xsi:type="string" translate="false">col-price-original</item>
<item name="price" xsi:type="string" translate="false">col-price</item>
<item name="qty" xsi:type="string" translate="false">col-ordered-qty</item>
<item name="subtotal" xsi:type="string" translate="false">col-subtotal</item>
<item name="tax-amount" xsi:type="string" translate="false">col-tax-amount</item>
<item name="tax-percent" xsi:type="string" translate="false">col-tax-percent</item>
<item name="discont" xsi:type="string" translate="false">col-discont</item>
<item name="total" xsi:type="string" translate="false">col-total</item>
<item name="repair" xsi:type="string" translate="false">col-repair</item>
</argument>
</arguments>
</block>
</referenceBlock>
</body>
`
I have added new column with name repair.
now you have to add value for that column. so you have to override '\Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer' file in your block and in getColumnHtml() method you have to add your value for that column.
http://magentocoder.jigneshpatel.co.in/create-custom-reports-in-magento-admin/
Should get you most of the way.
For adding the table header:
app/design/adminhtml/default/default/template/sales/order/view/items.phtml
app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml
These files are useful.
Admin grids are ofter controlled by their block.
For sales it's the Mage_Adminhtml_Block_Sales_Order_Grid class
modifying/overriding method _prepareColumns() should do the trick
I've no magento installation available, but I have some ideas.
Maybe the column is not defined inside a template file (phtml), but inside a xml layout file.
Just search in the layout/sales.xml file.
And maybe you have not disabled the magento cache, that's why you don't see any changes.

Resources